diff --git a/sdk/kusto/azure-mgmt-kusto/_meta.json b/sdk/kusto/azure-mgmt-kusto/_meta.json index 8bf49b74dbb6..d03b6dcaf431 100644 --- a/sdk/kusto/azure-mgmt-kusto/_meta.json +++ b/sdk/kusto/azure-mgmt-kusto/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.7.2", + "autorest": "3.8.4", "use": [ - "@autorest/python@5.12.0", - "@autorest/modelerfour@4.19.3" + "@autorest/python@6.1.5", + "@autorest/modelerfour@4.23.5" ], - "commit": "efd3d669a86d2e123f57ac3a43e5af4bb9e3a29f", + "commit": "6567e6d1c5f645bc50202d6ee34f279077cb462b", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/azure-kusto/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "autorest_command": "autorest specification/azure-kusto/resource-manager/readme.md --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.1.5 --use=@autorest/modelerfour@4.23.5 --version=3.8.4 --version-tolerant=False", "readme": "specification/azure-kusto/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/__init__.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/__init__.py index 37ab98770d3e..b20153daff8f 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/__init__.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['KustoManagementClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +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__ = ["KustoManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/_configuration.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/_configuration.py index b36053b3cc5d..bae853214d50 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/_configuration.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/_configuration.py @@ -19,25 +19,26 @@ from azure.core.credentials import TokenCredential -class KustoManagementClientConfiguration(Configuration): +class KustoManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for KustoManagementClient. 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: Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Gets 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 "2022-07-07". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(KustoManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2022-07-07") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,24 +46,25 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2022-02-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-kusto/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-kusto/{}".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 = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/_kusto_management_client.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/_kusto_management_client.py index 6982105841f0..6b9922457ce3 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/_kusto_management_client.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/_kusto_management_client.py @@ -7,63 +7,82 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +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 KustoManagementClientConfiguration -from .operations import AttachedDatabaseConfigurationsOperations, ClusterPrincipalAssignmentsOperations, ClustersOperations, DataConnectionsOperations, DatabasePrincipalAssignmentsOperations, DatabasesOperations, ManagedPrivateEndpointsOperations, Operations, OperationsResultsLocationOperations, OperationsResultsOperations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, ScriptsOperations +from ._serialization import Deserializer, Serializer +from .operations import ( + AttachedDatabaseConfigurationsOperations, + ClusterPrincipalAssignmentsOperations, + ClustersOperations, + DataConnectionsOperations, + DatabasePrincipalAssignmentsOperations, + DatabasesOperations, + ManagedPrivateEndpointsOperations, + Operations, + OperationsResultsLocationOperations, + OperationsResultsOperations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + ScriptsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class KustoManagementClient: - """The Azure Kusto management API provides a RESTful set of web services that interact with Azure Kusto services to manage your clusters and databases. The API enables you to create, update, and delete clusters and databases. + +class KustoManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """The Azure Kusto management API provides a RESTful set of web services that interact with Azure + Kusto services to manage your clusters and databases. The API enables you to create, update, + and delete clusters and databases. :ivar clusters: ClustersOperations operations - :vartype clusters: kusto_management_client.operations.ClustersOperations + :vartype clusters: azure.mgmt.kusto.operations.ClustersOperations :ivar cluster_principal_assignments: ClusterPrincipalAssignmentsOperations operations :vartype cluster_principal_assignments: - kusto_management_client.operations.ClusterPrincipalAssignmentsOperations + azure.mgmt.kusto.operations.ClusterPrincipalAssignmentsOperations :ivar databases: DatabasesOperations operations - :vartype databases: kusto_management_client.operations.DatabasesOperations + :vartype databases: azure.mgmt.kusto.operations.DatabasesOperations :ivar attached_database_configurations: AttachedDatabaseConfigurationsOperations operations :vartype attached_database_configurations: - kusto_management_client.operations.AttachedDatabaseConfigurationsOperations + azure.mgmt.kusto.operations.AttachedDatabaseConfigurationsOperations :ivar managed_private_endpoints: ManagedPrivateEndpointsOperations operations :vartype managed_private_endpoints: - kusto_management_client.operations.ManagedPrivateEndpointsOperations + azure.mgmt.kusto.operations.ManagedPrivateEndpointsOperations :ivar database_principal_assignments: DatabasePrincipalAssignmentsOperations operations :vartype database_principal_assignments: - kusto_management_client.operations.DatabasePrincipalAssignmentsOperations + azure.mgmt.kusto.operations.DatabasePrincipalAssignmentsOperations :ivar scripts: ScriptsOperations operations - :vartype scripts: kusto_management_client.operations.ScriptsOperations + :vartype scripts: azure.mgmt.kusto.operations.ScriptsOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations :vartype private_endpoint_connections: - kusto_management_client.operations.PrivateEndpointConnectionsOperations + azure.mgmt.kusto.operations.PrivateEndpointConnectionsOperations :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: - kusto_management_client.operations.PrivateLinkResourcesOperations + :vartype private_link_resources: azure.mgmt.kusto.operations.PrivateLinkResourcesOperations :ivar data_connections: DataConnectionsOperations operations - :vartype data_connections: kusto_management_client.operations.DataConnectionsOperations + :vartype data_connections: azure.mgmt.kusto.operations.DataConnectionsOperations :ivar operations: Operations operations - :vartype operations: kusto_management_client.operations.Operations + :vartype operations: azure.mgmt.kusto.operations.Operations :ivar operations_results: OperationsResultsOperations operations - :vartype operations_results: kusto_management_client.operations.OperationsResultsOperations + :vartype operations_results: azure.mgmt.kusto.operations.OperationsResultsOperations :ivar operations_results_location: OperationsResultsLocationOperations operations :vartype operations_results_location: - kusto_management_client.operations.OperationsResultsLocationOperations - :param credential: Credential needed for the client to connect to Azure. + azure.mgmt.kusto.operations.OperationsResultsLocationOperations + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2022-07-07". 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. """ @@ -75,7 +94,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = KustoManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = KustoManagementClientConfiguration( + 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)} @@ -83,25 +104,38 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.clusters = ClustersOperations(self._client, self._config, self._serialize, self._deserialize) - self.cluster_principal_assignments = ClusterPrincipalAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.cluster_principal_assignments = ClusterPrincipalAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.databases = DatabasesOperations(self._client, self._config, self._serialize, self._deserialize) - self.attached_database_configurations = AttachedDatabaseConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.managed_private_endpoints = ManagedPrivateEndpointsOperations(self._client, self._config, self._serialize, self._deserialize) - self.database_principal_assignments = DatabasePrincipalAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.attached_database_configurations = AttachedDatabaseConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.managed_private_endpoints = ManagedPrivateEndpointsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.database_principal_assignments = DatabasePrincipalAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.scripts = ScriptsOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) - self.data_connections = DataConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.data_connections = DataConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.operations_results = OperationsResultsOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations_results_location = OperationsResultsLocationOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request, # type: HttpRequest - **kwargs: Any - ) -> HttpResponse: + self.operations_results = OperationsResultsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations_results_location = OperationsResultsLocationOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -110,7 +144,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/_patch.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/_patch.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/_serialization.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/_serialization.py new file mode 100644 index 000000000000..7c1dedb5133d --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/_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/kusto/azure-mgmt-kusto/azure/mgmt/kusto/_vendor.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/_vendor.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/_version.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/_version.py index f30401ec2040..e32dc6ec4218 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/_version.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.2.0" +VERSION = "2.0.0b1" diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/__init__.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/__init__.py index bc8f0ef99515..1eb5d69bf942 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/__init__.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._kusto_management_client import KustoManagementClient -__all__ = ['KustoManagementClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +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__ = ["KustoManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/_configuration.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/_configuration.py index ee409ddb329c..bfabe6fbc934 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/_configuration.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/_configuration.py @@ -19,25 +19,26 @@ from azure.core.credentials_async import AsyncTokenCredential -class KustoManagementClientConfiguration(Configuration): +class KustoManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for KustoManagementClient. 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: Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Gets 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 "2022-07-07". 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(KustoManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2022-07-07") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,23 +46,22 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2022-02-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-kusto/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-kusto/{}".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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/_kusto_management_client.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/_kusto_management_client.py index 4c1a25d8519d..e10367b792a7 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/_kusto_management_client.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/_kusto_management_client.py @@ -7,63 +7,82 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING 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 KustoManagementClientConfiguration -from .operations import AttachedDatabaseConfigurationsOperations, ClusterPrincipalAssignmentsOperations, ClustersOperations, DataConnectionsOperations, DatabasePrincipalAssignmentsOperations, DatabasesOperations, ManagedPrivateEndpointsOperations, Operations, OperationsResultsLocationOperations, OperationsResultsOperations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, ScriptsOperations +from .operations import ( + AttachedDatabaseConfigurationsOperations, + ClusterPrincipalAssignmentsOperations, + ClustersOperations, + DataConnectionsOperations, + DatabasePrincipalAssignmentsOperations, + DatabasesOperations, + ManagedPrivateEndpointsOperations, + Operations, + OperationsResultsLocationOperations, + OperationsResultsOperations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + ScriptsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class KustoManagementClient: - """The Azure Kusto management API provides a RESTful set of web services that interact with Azure Kusto services to manage your clusters and databases. The API enables you to create, update, and delete clusters and databases. + +class KustoManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """The Azure Kusto management API provides a RESTful set of web services that interact with Azure + Kusto services to manage your clusters and databases. The API enables you to create, update, + and delete clusters and databases. :ivar clusters: ClustersOperations operations - :vartype clusters: kusto_management_client.aio.operations.ClustersOperations + :vartype clusters: azure.mgmt.kusto.aio.operations.ClustersOperations :ivar cluster_principal_assignments: ClusterPrincipalAssignmentsOperations operations :vartype cluster_principal_assignments: - kusto_management_client.aio.operations.ClusterPrincipalAssignmentsOperations + azure.mgmt.kusto.aio.operations.ClusterPrincipalAssignmentsOperations :ivar databases: DatabasesOperations operations - :vartype databases: kusto_management_client.aio.operations.DatabasesOperations + :vartype databases: azure.mgmt.kusto.aio.operations.DatabasesOperations :ivar attached_database_configurations: AttachedDatabaseConfigurationsOperations operations :vartype attached_database_configurations: - kusto_management_client.aio.operations.AttachedDatabaseConfigurationsOperations + azure.mgmt.kusto.aio.operations.AttachedDatabaseConfigurationsOperations :ivar managed_private_endpoints: ManagedPrivateEndpointsOperations operations :vartype managed_private_endpoints: - kusto_management_client.aio.operations.ManagedPrivateEndpointsOperations + azure.mgmt.kusto.aio.operations.ManagedPrivateEndpointsOperations :ivar database_principal_assignments: DatabasePrincipalAssignmentsOperations operations :vartype database_principal_assignments: - kusto_management_client.aio.operations.DatabasePrincipalAssignmentsOperations + azure.mgmt.kusto.aio.operations.DatabasePrincipalAssignmentsOperations :ivar scripts: ScriptsOperations operations - :vartype scripts: kusto_management_client.aio.operations.ScriptsOperations + :vartype scripts: azure.mgmt.kusto.aio.operations.ScriptsOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations :vartype private_endpoint_connections: - kusto_management_client.aio.operations.PrivateEndpointConnectionsOperations + azure.mgmt.kusto.aio.operations.PrivateEndpointConnectionsOperations :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: - kusto_management_client.aio.operations.PrivateLinkResourcesOperations + :vartype private_link_resources: azure.mgmt.kusto.aio.operations.PrivateLinkResourcesOperations :ivar data_connections: DataConnectionsOperations operations - :vartype data_connections: kusto_management_client.aio.operations.DataConnectionsOperations + :vartype data_connections: azure.mgmt.kusto.aio.operations.DataConnectionsOperations :ivar operations: Operations operations - :vartype operations: kusto_management_client.aio.operations.Operations + :vartype operations: azure.mgmt.kusto.aio.operations.Operations :ivar operations_results: OperationsResultsOperations operations - :vartype operations_results: kusto_management_client.aio.operations.OperationsResultsOperations + :vartype operations_results: azure.mgmt.kusto.aio.operations.OperationsResultsOperations :ivar operations_results_location: OperationsResultsLocationOperations operations :vartype operations_results_location: - kusto_management_client.aio.operations.OperationsResultsLocationOperations - :param credential: Credential needed for the client to connect to Azure. + azure.mgmt.kusto.aio.operations.OperationsResultsLocationOperations + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2022-07-07". 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. """ @@ -75,7 +94,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = KustoManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = KustoManagementClientConfiguration( + 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)} @@ -83,25 +104,38 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.clusters = ClustersOperations(self._client, self._config, self._serialize, self._deserialize) - self.cluster_principal_assignments = ClusterPrincipalAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.cluster_principal_assignments = ClusterPrincipalAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.databases = DatabasesOperations(self._client, self._config, self._serialize, self._deserialize) - self.attached_database_configurations = AttachedDatabaseConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.managed_private_endpoints = ManagedPrivateEndpointsOperations(self._client, self._config, self._serialize, self._deserialize) - self.database_principal_assignments = DatabasePrincipalAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.attached_database_configurations = AttachedDatabaseConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.managed_private_endpoints = ManagedPrivateEndpointsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.database_principal_assignments = DatabasePrincipalAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.scripts = ScriptsOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) - self.data_connections = DataConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.data_connections = DataConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.operations_results = OperationsResultsOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations_results_location = OperationsResultsLocationOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + self.operations_results = OperationsResultsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations_results_location = OperationsResultsLocationOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -110,7 +144,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + 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 diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/_patch.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/_patch.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/__init__.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/__init__.py index 766e81238756..38f45e09b0cb 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/__init__.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/__init__.py @@ -20,18 +20,24 @@ from ._operations_results_operations import OperationsResultsOperations from ._operations_results_location_operations import OperationsResultsLocationOperations +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', - 'ClusterPrincipalAssignmentsOperations', - 'DatabasesOperations', - 'AttachedDatabaseConfigurationsOperations', - 'ManagedPrivateEndpointsOperations', - 'DatabasePrincipalAssignmentsOperations', - 'ScriptsOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'DataConnectionsOperations', - 'Operations', - 'OperationsResultsOperations', - 'OperationsResultsLocationOperations', + "ClustersOperations", + "ClusterPrincipalAssignmentsOperations", + "DatabasesOperations", + "AttachedDatabaseConfigurationsOperations", + "ManagedPrivateEndpointsOperations", + "DatabasePrincipalAssignmentsOperations", + "ScriptsOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "DataConnectionsOperations", + "Operations", + "OperationsResultsOperations", + "OperationsResultsLocationOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_attached_database_configurations_operations.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_attached_database_configurations_operations.py index 8482b3470c7d..e6658b93c814 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_attached_database_configurations_operations.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_attached_database_configurations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,157 +6,258 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse 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 from ..._vendor import _convert_request -from ...operations._attached_database_configurations_operations import build_check_name_availability_request, build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_cluster_request -T = TypeVar('T') +from ...operations._attached_database_configurations_operations import ( + build_check_name_availability_request, + 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 AttachedDatabaseConfigurationsOperations: - """AttachedDatabaseConfigurationsOperations 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 AttachedDatabaseConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~kusto_management_client.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.kusto.aio.KustoManagementClient`'s + :attr:`attached_database_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") + + @overload + async def check_name_availability( + self, + resource_group_name: str, + cluster_name: str, + resource_name: _models.AttachedDatabaseConfigurationsCheckNameRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the attached database configuration resource name is valid and is not already in + use. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: ~azure.mgmt.kusto.models.AttachedDatabaseConfigurationsCheckNameRequest + :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: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, + resource_group_name: str, + cluster_name: str, + resource_name: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the attached database configuration resource name is valid and is not already in + use. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: 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: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def check_name_availability( self, resource_group_name: str, cluster_name: str, - resource_name: "_models.AttachedDatabaseConfigurationsCheckNameRequest", + resource_name: Union[_models.AttachedDatabaseConfigurationsCheckNameRequest, IO], **kwargs: Any - ) -> "_models.CheckNameResult": + ) -> _models.CheckNameResult: """Checks that the attached database configuration resource name is valid and is not already in use. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param resource_name: The name of the resource. - :type resource_name: - ~kusto_management_client.models.AttachedDatabaseConfigurationsCheckNameRequest + :param resource_name: The name of the resource. Is either a model type or a IO type. Required. + :type resource_name: ~azure.mgmt.kusto.models.AttachedDatabaseConfigurationsCheckNameRequest 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: CheckNameResult, or the result of cls(response) - :rtype: ~kusto_management_client.models.CheckNameResult - :raises: ~azure.core.exceptions.HttpResponseError + :return: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(resource_name, 'AttachedDatabaseConfigurationsCheckNameRequest') + 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.CheckNameResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource_name, (IO, bytes)): + _content = resource_name + else: + _json = self._serialize.body(resource_name, "AttachedDatabaseConfigurationsCheckNameRequest") request = build_check_name_availability_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, - template_url=self.check_name_availability.metadata['url'], + 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) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameResult', pipeline_response) + deserialized = self._deserialize("CheckNameResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurationCheckNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurationCheckNameAvailability"} # type: ignore @distributed_trace def list_by_cluster( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.AttachedDatabaseConfigurationListResult"]: + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.AttachedDatabaseConfiguration"]: """Returns the list of attached database configurations of the given Kusto cluster. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto 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 AttachedDatabaseConfigurationListResult or the - result of cls(response) + :return: An iterator like instance of either AttachedDatabaseConfiguration or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~kusto_management_client.models.AttachedDatabaseConfigurationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kusto.models.AttachedDatabaseConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AttachedDatabaseConfigurationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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.AttachedDatabaseConfigurationListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_cluster_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, - template_url=self.list_by_cluster.metadata['url'], + 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) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_cluster_request( - resource_group_name=resource_group_name, - cluster_name=cluster_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -169,7 +271,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -178,98 +282,126 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_cluster.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations'} # type: ignore + list_by_cluster.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - cluster_name: str, - attached_database_configuration_name: str, - **kwargs: Any - ) -> "_models.AttachedDatabaseConfiguration": + self, resource_group_name: str, cluster_name: str, attached_database_configuration_name: str, **kwargs: Any + ) -> _models.AttachedDatabaseConfiguration: """Returns an attached database configuration. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str :param attached_database_configuration_name: The name of the attached database configuration. + Required. :type attached_database_configuration_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AttachedDatabaseConfiguration, or the result of cls(response) - :rtype: ~kusto_management_client.models.AttachedDatabaseConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :return: AttachedDatabaseConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.AttachedDatabaseConfiguration + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AttachedDatabaseConfiguration"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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.AttachedDatabaseConfiguration] - request = build_get_request( resource_group_name=resource_group_name, cluster_name=cluster_name, attached_database_configuration_name=attached_database_configuration_name, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + 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) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AttachedDatabaseConfiguration', pipeline_response) + deserialized = self._deserialize("AttachedDatabaseConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, cluster_name: str, attached_database_configuration_name: str, - parameters: "_models.AttachedDatabaseConfiguration", + parameters: Union[_models.AttachedDatabaseConfiguration, IO], **kwargs: Any - ) -> "_models.AttachedDatabaseConfiguration": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AttachedDatabaseConfiguration"] + ) -> _models.AttachedDatabaseConfiguration: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'AttachedDatabaseConfiguration') + 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.AttachedDatabaseConfiguration] - request = build_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AttachedDatabaseConfiguration") + + request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, attached_database_configuration_name=attached_database_configuration_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + 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) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -277,21 +409,102 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AttachedDatabaseConfiguration', pipeline_response) + deserialized = self._deserialize("AttachedDatabaseConfiguration", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AttachedDatabaseConfiguration', pipeline_response) + deserialized = self._deserialize("AttachedDatabaseConfiguration", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AttachedDatabaseConfiguration', pipeline_response) + deserialized = self._deserialize("AttachedDatabaseConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + attached_database_configuration_name: str, + parameters: _models.AttachedDatabaseConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AttachedDatabaseConfiguration]: + """Creates or updates an attached database configuration. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param attached_database_configuration_name: The name of the attached database configuration. + Required. + :type attached_database_configuration_name: str + :param parameters: The database parameters supplied to the CreateOrUpdate operation. Required. + :type parameters: ~azure.mgmt.kusto.models.AttachedDatabaseConfiguration + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AttachedDatabaseConfiguration or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.AttachedDatabaseConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + attached_database_configuration_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AttachedDatabaseConfiguration]: + """Creates or updates an attached database configuration. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param attached_database_configuration_name: The name of the attached database configuration. + Required. + :type attached_database_configuration_name: str + :param parameters: The database parameters supplied to the CreateOrUpdate 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 AttachedDatabaseConfiguration or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.AttachedDatabaseConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -299,19 +512,25 @@ async def begin_create_or_update( resource_group_name: str, cluster_name: str, attached_database_configuration_name: str, - parameters: "_models.AttachedDatabaseConfiguration", + parameters: Union[_models.AttachedDatabaseConfiguration, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.AttachedDatabaseConfiguration"]: + ) -> AsyncLROPoller[_models.AttachedDatabaseConfiguration]: """Creates or updates an attached database configuration. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str :param attached_database_configuration_name: The name of the attached database configuration. + Required. :type attached_database_configuration_name: str - :param parameters: The database parameters supplied to the CreateOrUpdate operation. - :type parameters: ~kusto_management_client.models.AttachedDatabaseConfiguration + :param parameters: The database parameters supplied to the CreateOrUpdate operation. Is either + a model type or a IO type. Required. + :type parameters: ~azure.mgmt.kusto.models.AttachedDatabaseConfiguration 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 @@ -323,77 +542,90 @@ async def begin_create_or_update( :return: An instance of AsyncLROPoller that returns either AttachedDatabaseConfiguration or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~kusto_management_client.models.AttachedDatabaseConfiguration] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.AttachedDatabaseConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AttachedDatabaseConfiguration"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AttachedDatabaseConfiguration] + 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, attached_database_configuration_name=attached_database_configuration_name, parameters=parameters, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AttachedDatabaseConfiguration', pipeline_response) + deserialized = self._deserialize("AttachedDatabaseConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}"} # type: ignore - async def _delete_initial( - self, - resource_group_name: str, - cluster_name: str, - attached_database_configuration_name: str, - **kwargs: Any + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, cluster_name: str, attached_database_configuration_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', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( + 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, attached_database_configuration_name=attached_database_configuration_name, subscription_id=self._config.subscription_id, - template_url=self._delete_initial.metadata['url'], + 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) + 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 + ) - 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]: @@ -403,24 +635,21 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}"} # type: ignore @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - cluster_name: str, - attached_database_configuration_name: str, - **kwargs: Any + self, resource_group_name: str, cluster_name: str, attached_database_configuration_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the attached database configuration with the given name. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str :param attached_database_configuration_name: The name of the attached database configuration. + Required. :type attached_database_configuration_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. @@ -432,41 +661,46 @@ async def begin_delete( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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, attached_database_configuration_name=attached_database_configuration_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) - 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, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}"} # type: ignore diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_cluster_principal_assignments_operations.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_cluster_principal_assignments_operations.py index 4683a7b46c99..5aa72701d2f7 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_cluster_principal_assignments_operations.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_cluster_principal_assignments_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,195 +6,317 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse 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 from ..._vendor import _convert_request -from ...operations._cluster_principal_assignments_operations import build_check_name_availability_request, build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._cluster_principal_assignments_operations import ( + build_check_name_availability_request, + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ClusterPrincipalAssignmentsOperations: - """ClusterPrincipalAssignmentsOperations 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 ClusterPrincipalAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~kusto_management_client.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.kusto.aio.KustoManagementClient`'s + :attr:`cluster_principal_assignments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + async def check_name_availability( + self, + resource_group_name: str, + cluster_name: str, + principal_assignment_name: _models.ClusterPrincipalAssignmentCheckNameRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the principal assignment name is valid and is not already in use. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param principal_assignment_name: The name of the principal assignment. Required. + :type principal_assignment_name: + ~azure.mgmt.kusto.models.ClusterPrincipalAssignmentCheckNameRequest + :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: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, + resource_group_name: str, + cluster_name: str, + principal_assignment_name: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the principal assignment name is valid and is not already in use. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param principal_assignment_name: The name of the principal assignment. Required. + :type principal_assignment_name: 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: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def check_name_availability( self, resource_group_name: str, cluster_name: str, - principal_assignment_name: "_models.ClusterPrincipalAssignmentCheckNameRequest", + principal_assignment_name: Union[_models.ClusterPrincipalAssignmentCheckNameRequest, IO], **kwargs: Any - ) -> "_models.CheckNameResult": + ) -> _models.CheckNameResult: """Checks that the principal assignment name is valid and is not already in use. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param principal_assignment_name: The name of the principal assignment. + :param principal_assignment_name: The name of the principal assignment. Is either a model type + or a IO type. Required. :type principal_assignment_name: - ~kusto_management_client.models.ClusterPrincipalAssignmentCheckNameRequest + ~azure.mgmt.kusto.models.ClusterPrincipalAssignmentCheckNameRequest 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: CheckNameResult, or the result of cls(response) - :rtype: ~kusto_management_client.models.CheckNameResult - :raises: ~azure.core.exceptions.HttpResponseError + :return: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(principal_assignment_name, 'ClusterPrincipalAssignmentCheckNameRequest') + 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.CheckNameResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(principal_assignment_name, (IO, bytes)): + _content = principal_assignment_name + else: + _json = self._serialize.body(principal_assignment_name, "ClusterPrincipalAssignmentCheckNameRequest") request = build_check_name_availability_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, - template_url=self.check_name_availability.metadata['url'], + 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) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameResult', pipeline_response) + deserialized = self._deserialize("CheckNameResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/checkPrincipalAssignmentNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/checkPrincipalAssignmentNameAvailability"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - cluster_name: str, - principal_assignment_name: str, - **kwargs: Any - ) -> "_models.ClusterPrincipalAssignment": + self, resource_group_name: str, cluster_name: str, principal_assignment_name: str, **kwargs: Any + ) -> _models.ClusterPrincipalAssignment: """Gets a Kusto cluster principalAssignment. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param principal_assignment_name: The name of the Kusto principalAssignment. + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. :type principal_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ClusterPrincipalAssignment, or the result of cls(response) - :rtype: ~kusto_management_client.models.ClusterPrincipalAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :return: ClusterPrincipalAssignment or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.ClusterPrincipalAssignment + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterPrincipalAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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.ClusterPrincipalAssignment] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, principal_assignment_name=principal_assignment_name, - template_url=self.get.metadata['url'], + 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) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ClusterPrincipalAssignment', pipeline_response) + deserialized = self._deserialize("ClusterPrincipalAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments/{principalAssignmentName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments/{principalAssignmentName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, cluster_name: str, principal_assignment_name: str, - parameters: "_models.ClusterPrincipalAssignment", + parameters: Union[_models.ClusterPrincipalAssignment, IO], **kwargs: Any - ) -> "_models.ClusterPrincipalAssignment": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterPrincipalAssignment"] + ) -> _models.ClusterPrincipalAssignment: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ClusterPrincipalAssignment') + 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.ClusterPrincipalAssignment] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ClusterPrincipalAssignment") + + request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, principal_assignment_name=principal_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + 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) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -201,18 +324,97 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ClusterPrincipalAssignment', pipeline_response) + deserialized = self._deserialize("ClusterPrincipalAssignment", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ClusterPrincipalAssignment', pipeline_response) + deserialized = self._deserialize("ClusterPrincipalAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments/{principalAssignmentName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments/{principalAssignmentName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + principal_assignment_name: str, + parameters: _models.ClusterPrincipalAssignment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ClusterPrincipalAssignment]: + """Create a Kusto cluster principalAssignment. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. + :type principal_assignment_name: str + :param parameters: The Kusto cluster principalAssignment's parameters supplied for the + operation. Required. + :type parameters: ~azure.mgmt.kusto.models.ClusterPrincipalAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ClusterPrincipalAssignment or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.ClusterPrincipalAssignment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + principal_assignment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ClusterPrincipalAssignment]: + """Create a Kusto cluster principalAssignment. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. + :type principal_assignment_name: str + :param parameters: The Kusto cluster principalAssignment's parameters supplied for the + 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 ClusterPrincipalAssignment or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.ClusterPrincipalAssignment] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -220,20 +422,24 @@ async def begin_create_or_update( resource_group_name: str, cluster_name: str, principal_assignment_name: str, - parameters: "_models.ClusterPrincipalAssignment", + parameters: Union[_models.ClusterPrincipalAssignment, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ClusterPrincipalAssignment"]: + ) -> AsyncLROPoller[_models.ClusterPrincipalAssignment]: """Create a Kusto cluster principalAssignment. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param principal_assignment_name: The name of the Kusto principalAssignment. + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. :type principal_assignment_name: str :param parameters: The Kusto cluster principalAssignment's parameters supplied for the - operation. - :type parameters: ~kusto_management_client.models.ClusterPrincipalAssignment + operation. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.kusto.models.ClusterPrincipalAssignment 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 @@ -244,78 +450,90 @@ async def begin_create_or_update( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either ClusterPrincipalAssignment or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~kusto_management_client.models.ClusterPrincipalAssignment] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.ClusterPrincipalAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterPrincipalAssignment"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ClusterPrincipalAssignment] + 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, principal_assignment_name=principal_assignment_name, parameters=parameters, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ClusterPrincipalAssignment', pipeline_response) + deserialized = self._deserialize("ClusterPrincipalAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments/{principalAssignmentName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments/{principalAssignmentName}"} # type: ignore - async def _delete_initial( - self, - resource_group_name: str, - cluster_name: str, - principal_assignment_name: str, - **kwargs: Any + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, cluster_name: str, principal_assignment_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', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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, principal_assignment_name=principal_assignment_name, - template_url=self._delete_initial.metadata['url'], + 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) + 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 + ) - 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]: @@ -325,24 +543,20 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments/{principalAssignmentName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments/{principalAssignmentName}"} # type: ignore @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - cluster_name: str, - principal_assignment_name: str, - **kwargs: Any + self, resource_group_name: str, cluster_name: str, principal_assignment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a Kusto cluster principalAssignment. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param principal_assignment_name: The name of the Kusto principalAssignment. + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. :type principal_assignment_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. @@ -354,92 +568,105 @@ async def begin_delete( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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, principal_assignment_name=principal_assignment_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) - 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, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments/{principalAssignmentName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments/{principalAssignmentName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ClusterPrincipalAssignmentListResult"]: + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ClusterPrincipalAssignment"]: """Lists all Kusto cluster principalAssignments. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto 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 ClusterPrincipalAssignmentListResult or the result - of cls(response) + :return: An iterator like instance of either ClusterPrincipalAssignment or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~kusto_management_client.models.ClusterPrincipalAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kusto.models.ClusterPrincipalAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterPrincipalAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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.ClusterPrincipalAssignmentListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_name=cluster_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -453,7 +680,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -462,8 +691,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments"} # type: ignore diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_clusters_operations.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_clusters_operations.py index 64eeac6d6c30..a674b1cd37d7 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_clusters_operations.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/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,133 +6,186 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse 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 from ..._vendor import _convert_request -from ...operations._clusters_operations import build_add_language_extensions_request_initial, build_check_name_availability_request, build_create_or_update_request_initial, build_delete_request_initial, build_detach_follower_databases_request_initial, build_diagnose_virtual_network_request_initial, build_get_request, build_list_by_resource_group_request, build_list_follower_databases_request, build_list_language_extensions_request, build_list_outbound_network_dependencies_endpoints_request, build_list_request, build_list_skus_by_resource_request, build_list_skus_request, build_remove_language_extensions_request_initial, build_start_request_initial, build_stop_request_initial, build_update_request_initial -T = TypeVar('T') +from ...operations._clusters_operations import ( + build_add_language_extensions_request, + build_check_name_availability_request, + build_create_or_update_request, + build_delete_request, + build_detach_follower_databases_request, + build_diagnose_virtual_network_request, + build_get_request, + build_list_by_resource_group_request, + build_list_follower_databases_request, + build_list_language_extensions_request, + build_list_outbound_network_dependencies_endpoints_request, + build_list_request, + build_list_skus_by_resource_request, + build_list_skus_request, + build_remove_language_extensions_request, + build_start_request, + build_stop_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class 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: ~kusto_management_client.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.kusto.aio.KustoManagementClient`'s + :attr:`clusters` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> "_models.Cluster": + async def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> _models.Cluster: """Gets a Kusto cluster. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto 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) - :rtype: ~kusto_management_client.models.Cluster - :raises: ~azure.core.exceptions.HttpResponseError + :return: Cluster or the result of cls(response) + :rtype: ~azure.mgmt.kusto.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', {})) + 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, - template_url=self.get.metadata['url'], + 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) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Cluster', pipeline_response) + deserialized = self._deserialize("Cluster", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, cluster_name: str, - parameters: "_models.Cluster", + parameters: Union[_models.Cluster, IO], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **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', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Cluster] - _json = self._serialize.body(parameters, '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, "Cluster") - request = build_create_or_update_request_initial( + request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, - content_type=content_type, - json=_json, if_match=if_match, if_none_match=if_none_match, - template_url=self._create_or_update_initial.metadata['url'], + 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) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -139,44 +193,98 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Cluster', pipeline_response) + deserialized = self._deserialize("Cluster", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Cluster', pipeline_response) + deserialized = self._deserialize("Cluster", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + parameters: _models.Cluster, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Cluster]: + """Create or update a Kusto cluster. - @distributed_trace_async + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param parameters: The Kusto cluster parameters supplied to the CreateOrUpdate operation. + Required. + :type parameters: ~azure.mgmt.kusto.models.Cluster + :param if_match: The ETag of the cluster. Omit this value to always overwrite the current + cluster. Specify the last-seen ETag value to prevent accidentally overwriting concurrent + changes. Default value is None. + :type if_match: str + :param if_none_match: Set to '*' to allow a new cluster to be created, but to prevent updating + an existing cluster. Other values will result in a 412 Pre-condition Failed response. Default + value is None. + :type if_none_match: 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. + :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.kusto.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload async def begin_create_or_update( self, resource_group_name: str, cluster_name: str, - parameters: "_models.Cluster", + parameters: IO, if_match: Optional[str] = None, if_none_match: Optional[str] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.Cluster"]: + ) -> AsyncLROPoller[_models.Cluster]: """Create or update a Kusto cluster. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str :param parameters: The Kusto cluster parameters supplied to the CreateOrUpdate operation. - :type parameters: ~kusto_management_client.models.Cluster + Required. + :type parameters: IO :param if_match: The ETag of the cluster. Omit this value to always overwrite the current cluster. Specify the last-seen ETag value to prevent accidentally overwriting concurrent - changes. + changes. Default value is None. :type if_match: str :param if_none_match: Set to '*' to allow a new cluster to be created, but to prevent updating - an existing cluster. Other values will result in a 412 Pre-condition Failed response. + an existing cluster. Other values will result in a 412 Pre-condition Failed response. Default + value is None. :type if_none_match: str + :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 @@ -187,84 +295,153 @@ async def begin_create_or_update( 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[~kusto_management_client.models.Cluster] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Cluster"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + parameters: Union[_models.Cluster, IO], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.Cluster]: + """Create or update a Kusto cluster. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param parameters: The Kusto cluster parameters supplied to the CreateOrUpdate operation. Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.kusto.models.Cluster or IO + :param if_match: The ETag of the cluster. Omit this value to always overwrite the current + cluster. Specify the last-seen ETag value to prevent accidentally overwriting concurrent + changes. Default value is None. + :type if_match: str + :param if_none_match: Set to '*' to allow a new cluster to be created, but to prevent updating + an existing cluster. Other values will result in a 412 Pre-condition Failed response. Default + value is None. + :type if_none_match: str + :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.kusto.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Cluster] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, parameters=parameters, if_match=if_match, if_none_match=if_none_match, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('Cluster', pipeline_response) + deserialized = self._deserialize("Cluster", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}"} # type: ignore async def _update_initial( self, resource_group_name: str, cluster_name: str, - parameters: "_models.ClusterUpdate", + parameters: Union[_models.ClusterUpdate, IO], if_match: Optional[str] = None, **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', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ClusterUpdate') + 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] - request = build_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ClusterUpdate") + + request = build_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self._update_initial.metadata['url'], + 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) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -273,47 +450,137 @@ async def _update_initial( response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('Cluster', pipeline_response) + deserialized = self._deserialize("Cluster", pipeline_response) if response.status_code == 201: - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - - deserialized = self._deserialize('Cluster', pipeline_response) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Cluster", pipeline_response) if response.status_code == 202: - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - - deserialized = self._deserialize('Cluster', pipeline_response) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Cluster", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_name: str, + parameters: _models.ClusterUpdate, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Cluster]: + """Update a Kusto cluster. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param parameters: The Kusto cluster parameters supplied to the Update operation. Required. + :type parameters: ~azure.mgmt.kusto.models.ClusterUpdate + :param if_match: The ETag of the cluster. Omit this value to always overwrite the current + cluster. Specify the last-seen ETag value to prevent accidentally overwriting concurrent + changes. Default value is None. + :type if_match: 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. + :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.kusto.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_name: str, + parameters: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Cluster]: + """Update a Kusto cluster. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param parameters: The Kusto cluster parameters supplied to the Update operation. Required. + :type parameters: IO + :param if_match: The ETag of the cluster. Omit this value to always overwrite the current + cluster. Specify the last-seen ETag value to prevent accidentally overwriting concurrent + changes. Default value is None. + :type if_match: str + :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.kusto.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( self, resource_group_name: str, cluster_name: str, - parameters: "_models.ClusterUpdate", + parameters: Union[_models.ClusterUpdate, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.Cluster"]: + ) -> AsyncLROPoller[_models.Cluster]: """Update a Kusto cluster. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param parameters: The Kusto cluster parameters supplied to the Update operation. - :type parameters: ~kusto_management_client.models.ClusterUpdate + :param parameters: The Kusto cluster parameters supplied to the Update operation. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.kusto.models.ClusterUpdate or IO :param if_match: The ETag of the cluster. Omit this value to always overwrite the current cluster. Specify the last-seen ETag value to prevent accidentally overwriting concurrent - changes. + changes. Default value is None. :type if_match: str + :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 @@ -324,75 +591,89 @@ async def begin_update( 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[~kusto_management_client.models.Cluster] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Cluster"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Cluster] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, parameters=parameters, if_match=if_match, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('Cluster', pipeline_response) + deserialized = self._deserialize("Cluster", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}"} # type: ignore - async def _delete_initial( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any + 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 + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_delete_request_initial( + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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, - template_url=self._delete_initial.metadata['url'], + 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) + 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 + ) - 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]: @@ -402,21 +683,16 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}"} # type: ignore @distributed_trace_async - async def begin_delete( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a Kusto cluster. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto 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. @@ -428,67 +704,82 @@ async def begin_delete( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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) - 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, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}"} # type: ignore - async def _stop_initial( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any + async def _stop_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 + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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_stop_request_initial( + request = build_stop_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, - template_url=self._stop_initial.metadata['url'], + api_version=api_version, + template_url=self._stop_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -498,21 +789,16 @@ async def _stop_initial( if cls: return cls(pipeline_response, None, {}) - _stop_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/stop'} # type: ignore - + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/stop"} # type: ignore @distributed_trace_async - async def begin_stop( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_stop(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Stops a Kusto cluster. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto 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. @@ -524,67 +810,82 @@ async def begin_stop( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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._stop_initial( + raw_result = await self._stop_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) - 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, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_stop.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/stop'} # type: ignore + begin_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/stop"} # type: ignore - async def _start_initial( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any + async def _start_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 + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_start_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_start_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, - template_url=self._start_initial.metadata['url'], + api_version=api_version, + template_url=self._start_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -594,21 +895,16 @@ async def _start_initial( if cls: return cls(pipeline_response, None, {}) - _start_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/start'} # type: ignore - + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/start"} # type: ignore @distributed_trace_async - async def begin_start( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_start(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Starts a Kusto cluster. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto 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. @@ -620,92 +916,105 @@ async def begin_start( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, 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) - 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, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/start'} # type: ignore + begin_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/start"} # type: ignore @distributed_trace def list_follower_databases( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.FollowerDatabaseListResult"]: + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.FollowerDatabaseDefinition"]: """Returns a list of databases that are owned by this cluster and were followed by another cluster. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto 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 FollowerDatabaseListResult or the result of + :return: An iterator like instance of either FollowerDatabaseDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~kusto_management_client.models.FollowerDatabaseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kusto.models.FollowerDatabaseDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FollowerDatabaseListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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.FollowerDatabaseListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_follower_databases_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, - template_url=self.list_follower_databases.metadata['url'], + api_version=api_version, + template_url=self.list_follower_databases.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_follower_databases_request( - resource_group_name=resource_group_name, - cluster_name=cluster_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -719,7 +1028,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -728,41 +1039,59 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_follower_databases.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/listFollowerDatabases'} # type: ignore + list_follower_databases.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/listFollowerDatabases"} # type: ignore - async def _detach_follower_databases_initial( + async def _detach_follower_databases_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, - follower_database_to_remove: "_models.FollowerDatabaseDefinition", + follower_database_to_remove: Union[_models.FollowerDatabaseDefinition, 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', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(follower_database_to_remove, 'FollowerDatabaseDefinition') + 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(follower_database_to_remove, (IO, bytes)): + _content = follower_database_to_remove + else: + _json = self._serialize.body(follower_database_to_remove, "FollowerDatabaseDefinition") - request = build_detach_follower_databases_request_initial( + request = build_detach_follower_databases_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, - template_url=self._detach_follower_databases_initial.metadata['url'], + content=_content, + template_url=self._detach_follower_databases_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -772,25 +1101,99 @@ async def _detach_follower_databases_initial( if cls: return cls(pipeline_response, None, {}) - _detach_follower_databases_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/detachFollowerDatabases'} # type: ignore + _detach_follower_databases_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/detachFollowerDatabases"} # type: ignore + @overload + async def begin_detach_follower_databases( + self, + resource_group_name: str, + cluster_name: str, + follower_database_to_remove: _models.FollowerDatabaseDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Detaches all followers of a database owned by this cluster. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param follower_database_to_remove: The follower databases properties to remove. Required. + :type follower_database_to_remove: ~azure.mgmt.kusto.models.FollowerDatabaseDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_detach_follower_databases( + self, + resource_group_name: str, + cluster_name: str, + follower_database_to_remove: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Detaches all followers of a database owned by this cluster. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param follower_database_to_remove: The follower databases properties to remove. Required. + :type follower_database_to_remove: 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_detach_follower_databases( self, resource_group_name: str, cluster_name: str, - follower_database_to_remove: "_models.FollowerDatabaseDefinition", + follower_database_to_remove: Union[_models.FollowerDatabaseDefinition, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Detaches all followers of a database owned by this cluster. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param follower_database_to_remove: The follower databases properties to remove. - :type follower_database_to_remove: ~kusto_management_client.models.FollowerDatabaseDefinition + :param follower_database_to_remove: The follower databases properties to remove. Is either a + model type or a IO type. Required. + :type follower_database_to_remove: ~azure.mgmt.kusto.models.FollowerDatabaseDefinition 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 @@ -801,70 +1204,85 @@ async def begin_detach_follower_databases( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[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._detach_follower_databases_initial( + raw_result = await self._detach_follower_databases_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, follower_database_to_remove=follower_database_to_remove, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", 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, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_detach_follower_databases.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/detachFollowerDatabases'} # type: ignore + begin_detach_follower_databases.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/detachFollowerDatabases"} # type: ignore async def _diagnose_virtual_network_initial( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> Optional["_models.DiagnoseVirtualNetworkResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DiagnoseVirtualNetworkResult"]] + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> Optional[_models.DiagnoseVirtualNetworkResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_diagnose_virtual_network_request_initial( + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DiagnoseVirtualNetworkResult]] + + request = build_diagnose_virtual_network_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, - template_url=self._diagnose_virtual_network_initial.metadata['url'], + api_version=api_version, + template_url=self._diagnose_virtual_network_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -873,29 +1291,26 @@ async def _diagnose_virtual_network_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DiagnoseVirtualNetworkResult', pipeline_response) + deserialized = self._deserialize("DiagnoseVirtualNetworkResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _diagnose_virtual_network_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/diagnoseVirtualNetwork'} # type: ignore - + _diagnose_virtual_network_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/diagnoseVirtualNetwork"} # type: ignore @distributed_trace_async async def begin_diagnose_virtual_network( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> AsyncLROPoller["_models.DiagnoseVirtualNetworkResult"]: + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.DiagnoseVirtualNetworkResult]: """Diagnoses network connectivity status for external resources on which the service is dependent on. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto 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. @@ -908,89 +1323,102 @@ async def begin_diagnose_virtual_network( :return: An instance of AsyncLROPoller that returns either DiagnoseVirtualNetworkResult or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~kusto_management_client.models.DiagnoseVirtualNetworkResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.DiagnoseVirtualNetworkResult] + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnoseVirtualNetworkResult"] - 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[_models.DiagnoseVirtualNetworkResult] + 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._diagnose_virtual_network_initial( + raw_result = await self._diagnose_virtual_network_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) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DiagnoseVirtualNetworkResult', pipeline_response) + deserialized = self._deserialize("DiagnoseVirtualNetworkResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **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) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_diagnose_virtual_network.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/diagnoseVirtualNetwork'} # type: ignore + begin_diagnose_virtual_network.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/diagnoseVirtualNetwork"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ClusterListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Cluster"]: """Lists all Kusto clusters within a resource group. :param resource_group_name: The name of the resource group containing the Kusto cluster. + 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[~kusto_management_client.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.kusto.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', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - template_url=self.list_by_resource_group.metadata['url'], + 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) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1004,7 +1432,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1013,48 +1443,54 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters'} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.ClusterListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Cluster"]: """Lists all Kusto clusters within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ClusterListResult or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~kusto_management_client.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.kusto.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', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, - template_url=self.list.metadata['url'], + 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) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1068,7 +1504,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1077,48 +1515,54 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/clusters'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/clusters"} # type: ignore @distributed_trace - def list_skus( - self, - **kwargs: Any - ) -> AsyncIterable["_models.SkuDescriptionList"]: + def list_skus(self, **kwargs: Any) -> AsyncIterable["_models.SkuDescription"]: """Lists eligible SKUs for Kusto resource provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SkuDescriptionList or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~kusto_management_client.models.SkuDescriptionList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SkuDescription or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kusto.models.SkuDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SkuDescriptionList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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.SkuDescriptionList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_skus_request( subscription_id=self._config.subscription_id, - template_url=self.list_skus.metadata['url'], + api_version=api_version, + template_url=self.list_skus.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_skus_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1132,7 +1576,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1141,114 +1587,180 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_skus.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/skus'} # type: ignore + list_skus.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/skus"} # type: ignore - @distributed_trace_async + @overload async def check_name_availability( self, location: str, - cluster_name: "_models.ClusterCheckNameRequest", + cluster_name: _models.ClusterCheckNameRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CheckNameResult": + ) -> _models.CheckNameResult: + """Checks that the cluster name is valid and is not already in use. + + :param location: Azure location (region) name. Required. + :type location: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: ~azure.mgmt.kusto.models.ClusterCheckNameRequest + :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: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, location: str, cluster_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the cluster name is valid and is not already in use. + + :param location: Azure location (region) name. Required. + :type location: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: 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: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, location: str, cluster_name: Union[_models.ClusterCheckNameRequest, IO], **kwargs: Any + ) -> _models.CheckNameResult: """Checks that the cluster name is valid and is not already in use. - :param location: Azure location (region) name. + :param location: Azure location (region) name. Required. :type location: str - :param cluster_name: The name of the cluster. - :type cluster_name: ~kusto_management_client.models.ClusterCheckNameRequest + :param cluster_name: The name of the cluster. Is either a model type or a IO type. Required. + :type cluster_name: ~azure.mgmt.kusto.models.ClusterCheckNameRequest 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: CheckNameResult, or the result of cls(response) - :rtype: ~kusto_management_client.models.CheckNameResult - :raises: ~azure.core.exceptions.HttpResponseError + :return: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(cluster_name, 'ClusterCheckNameRequest') + 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.CheckNameResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(cluster_name, (IO, bytes)): + _content = cluster_name + else: + _json = self._serialize.body(cluster_name, "ClusterCheckNameRequest") request = build_check_name_availability_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + 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) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameResult', pipeline_response) + deserialized = self._deserialize("CheckNameResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/locations/{location}/checkNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/locations/{location}/checkNameAvailability"} # type: ignore @distributed_trace def list_skus_by_resource( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ListResourceSkusResult"]: + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.AzureResourceSku"]: """Returns the SKUs available for the provided resource. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto 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 ListResourceSkusResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~kusto_management_client.models.ListResourceSkusResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either AzureResourceSku or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kusto.models.AzureResourceSku] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListResourceSkusResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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.ListResourceSkusResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_skus_by_resource_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, - template_url=self.list_skus_by_resource.metadata['url'], + api_version=api_version, + template_url=self.list_skus_by_resource.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_skus_by_resource_request( - resource_group_name=resource_group_name, - cluster_name=cluster_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1262,7 +1774,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1271,59 +1785,65 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_skus_by_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/skus'} # type: ignore + list_skus_by_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/skus"} # type: ignore @distributed_trace def list_outbound_network_dependencies_endpoints( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.OutboundNetworkDependenciesEndpointListResult"]: + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.OutboundNetworkDependenciesEndpoint"]: """Gets the network endpoints of all outbound dependencies of a Kusto cluster. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto 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 OutboundNetworkDependenciesEndpointListResult or - the result of cls(response) + :return: An iterator like instance of either OutboundNetworkDependenciesEndpoint or the result + of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~kusto_management_client.models.OutboundNetworkDependenciesEndpointListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kusto.models.OutboundNetworkDependenciesEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OutboundNetworkDependenciesEndpointListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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.OutboundNetworkDependenciesEndpointListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_outbound_network_dependencies_endpoints_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, - template_url=self.list_outbound_network_dependencies_endpoints.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_outbound_network_dependencies_endpoints.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_outbound_network_dependencies_endpoints_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_name=cluster_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1337,7 +1857,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1346,59 +1868,63 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_outbound_network_dependencies_endpoints.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/outboundNetworkDependenciesEndpoints'} # type: ignore + list_outbound_network_dependencies_endpoints.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/outboundNetworkDependenciesEndpoints"} # type: ignore @distributed_trace def list_language_extensions( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.LanguageExtensionsList"]: + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.LanguageExtension"]: """Returns a list of language extensions that can run within KQL queries. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto 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 LanguageExtensionsList or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~kusto_management_client.models.LanguageExtensionsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either LanguageExtension or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kusto.models.LanguageExtension] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LanguageExtensionsList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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.LanguageExtensionsList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_language_extensions_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, - template_url=self.list_language_extensions.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_language_extensions.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_language_extensions_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_name=cluster_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1412,7 +1938,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1421,41 +1949,59 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_language_extensions.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/listLanguageExtensions'} # type: ignore + list_language_extensions.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/listLanguageExtensions"} # type: ignore - async def _add_language_extensions_initial( + async def _add_language_extensions_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, - language_extensions_to_add: "_models.LanguageExtensionsList", + language_extensions_to_add: Union[_models.LanguageExtensionsList, 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', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(language_extensions_to_add, 'LanguageExtensionsList') + 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] - request = build_add_language_extensions_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(language_extensions_to_add, (IO, bytes)): + _content = language_extensions_to_add + else: + _json = self._serialize.body(language_extensions_to_add, "LanguageExtensionsList") + + request = build_add_language_extensions_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, - template_url=self._add_language_extensions_initial.metadata['url'], + content=_content, + template_url=self._add_language_extensions_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1465,25 +2011,99 @@ async def _add_language_extensions_initial( if cls: return cls(pipeline_response, None, {}) - _add_language_extensions_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/addLanguageExtensions'} # type: ignore + _add_language_extensions_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/addLanguageExtensions"} # type: ignore + + @overload + async def begin_add_language_extensions( + self, + resource_group_name: str, + cluster_name: str, + language_extensions_to_add: _models.LanguageExtensionsList, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Add a list of language extensions that can run within KQL queries. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param language_extensions_to_add: The language extensions to add. Required. + :type language_extensions_to_add: ~azure.mgmt.kusto.models.LanguageExtensionsList + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_add_language_extensions( + self, + resource_group_name: str, + cluster_name: str, + language_extensions_to_add: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Add a list of language extensions that can run within KQL queries. + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param language_extensions_to_add: The language extensions to add. Required. + :type language_extensions_to_add: 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_add_language_extensions( self, resource_group_name: str, cluster_name: str, - language_extensions_to_add: "_models.LanguageExtensionsList", + language_extensions_to_add: Union[_models.LanguageExtensionsList, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Add a list of language extensions that can run within KQL queries. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param language_extensions_to_add: The language extensions to add. - :type language_extensions_to_add: ~kusto_management_client.models.LanguageExtensionsList + :param language_extensions_to_add: The language extensions to add. Is either a model type or a + IO type. Required. + :type language_extensions_to_add: ~azure.mgmt.kusto.models.LanguageExtensionsList 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 @@ -1494,76 +2114,101 @@ async def begin_add_language_extensions( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[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._add_language_extensions_initial( + raw_result = await self._add_language_extensions_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, language_extensions_to_add=language_extensions_to_add, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", 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, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_add_language_extensions.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/addLanguageExtensions'} # type: ignore + begin_add_language_extensions.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/addLanguageExtensions"} # type: ignore - async def _remove_language_extensions_initial( + async def _remove_language_extensions_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, - language_extensions_to_remove: "_models.LanguageExtensionsList", + language_extensions_to_remove: Union[_models.LanguageExtensionsList, 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', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(language_extensions_to_remove, 'LanguageExtensionsList') + 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] - request = build_remove_language_extensions_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(language_extensions_to_remove, (IO, bytes)): + _content = language_extensions_to_remove + else: + _json = self._serialize.body(language_extensions_to_remove, "LanguageExtensionsList") + + request = build_remove_language_extensions_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, - template_url=self._remove_language_extensions_initial.metadata['url'], + content=_content, + template_url=self._remove_language_extensions_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1573,25 +2218,99 @@ async def _remove_language_extensions_initial( if cls: return cls(pipeline_response, None, {}) - _remove_language_extensions_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/removeLanguageExtensions'} # type: ignore + _remove_language_extensions_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/removeLanguageExtensions"} # type: ignore + + @overload + async def begin_remove_language_extensions( + self, + resource_group_name: str, + cluster_name: str, + language_extensions_to_remove: _models.LanguageExtensionsList, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Remove a list of language extensions that can run within KQL queries. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param language_extensions_to_remove: The language extensions to remove. Required. + :type language_extensions_to_remove: ~azure.mgmt.kusto.models.LanguageExtensionsList + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_remove_language_extensions( + self, + resource_group_name: str, + cluster_name: str, + language_extensions_to_remove: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Remove a list of language extensions that can run within KQL queries. + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param language_extensions_to_remove: The language extensions to remove. Required. + :type language_extensions_to_remove: 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_remove_language_extensions( self, resource_group_name: str, cluster_name: str, - language_extensions_to_remove: "_models.LanguageExtensionsList", + language_extensions_to_remove: Union[_models.LanguageExtensionsList, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Remove a list of language extensions that can run within KQL queries. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param language_extensions_to_remove: The language extensions to remove. - :type language_extensions_to_remove: ~kusto_management_client.models.LanguageExtensionsList + :param language_extensions_to_remove: The language extensions to remove. Is either a model type + or a IO type. Required. + :type language_extensions_to_remove: ~azure.mgmt.kusto.models.LanguageExtensionsList 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 @@ -1602,43 +2321,48 @@ async def begin_remove_language_extensions( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[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._remove_language_extensions_initial( + raw_result = await self._remove_language_extensions_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, language_extensions_to_remove=language_extensions_to_remove, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", 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, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_remove_language_extensions.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/removeLanguageExtensions'} # type: ignore + begin_remove_language_extensions.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/removeLanguageExtensions"} # type: ignore diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_data_connections_operations.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_data_connections_operations.py index f67b082ac521..0eb324571aa8 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_data_connections_operations.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_data_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,119 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse 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 from ..._vendor import _convert_request -from ...operations._data_connections_operations import build_check_name_availability_request, build_create_or_update_request_initial, build_data_connection_validation_request_initial, build_delete_request_initial, build_get_request, build_list_by_database_request, build_update_request_initial -T = TypeVar('T') +from ...operations._data_connections_operations import ( + build_check_name_availability_request, + build_create_or_update_request, + build_data_connection_validation_request, + build_delete_request, + build_get_request, + build_list_by_database_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DataConnectionsOperations: - """DataConnectionsOperations 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 DataConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~kusto_management_client.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.kusto.aio.KustoManagementClient`'s + :attr:`data_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_database( - self, - resource_group_name: str, - cluster_name: str, - database_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.DataConnectionListResult"]: + self, resource_group_name: str, cluster_name: str, database_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DataConnection"]: """Returns the list of data connections of the given Kusto database. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataConnectionListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~kusto_management_client.models.DataConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataConnection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kusto.models.DataConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataConnectionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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.DataConnectionListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_database_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, - template_url=self.list_by_database.metadata['url'], + api_version=api_version, + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_database_request( - resource_group_name=resource_group_name, - cluster_name=cluster_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -113,7 +132,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -122,43 +143,61 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections'} # type: ignore + list_by_database.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections"} # type: ignore async def _data_connection_validation_initial( self, resource_group_name: str, cluster_name: str, database_name: str, - parameters: "_models.DataConnectionValidation", + parameters: Union[_models.DataConnectionValidation, IO], **kwargs: Any - ) -> Optional["_models.DataConnectionValidationListResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DataConnectionValidationListResult"]] + ) -> Optional[_models.DataConnectionValidationListResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'DataConnectionValidation') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DataConnectionValidationListResult]] - request = build_data_connection_validation_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataConnectionValidation") + + request = build_data_connection_validation_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._data_connection_validation_initial.metadata['url'], + content=_content, + template_url=self._data_connection_validation_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -167,35 +206,82 @@ async def _data_connection_validation_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DataConnectionValidationListResult', pipeline_response) + deserialized = self._deserialize("DataConnectionValidationListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _data_connection_validation_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnectionValidation'} # type: ignore + _data_connection_validation_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnectionValidation"} # type: ignore + @overload + async def begin_data_connection_validation( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + parameters: _models.DataConnectionValidation, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DataConnectionValidationListResult]: + """Checks that the data connection parameters are valid. - @distributed_trace_async + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param parameters: The data connection parameters supplied to the CreateOrUpdate operation. + Required. + :type parameters: ~azure.mgmt.kusto.models.DataConnectionValidation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DataConnectionValidationListResult + or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.DataConnectionValidationListResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload async def begin_data_connection_validation( self, resource_group_name: str, cluster_name: str, database_name: str, - parameters: "_models.DataConnectionValidation", + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DataConnectionValidationListResult"]: + ) -> AsyncLROPoller[_models.DataConnectionValidationListResult]: """Checks that the data connection parameters are valid. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str :param parameters: The data connection parameters supplied to the CreateOrUpdate operation. - :type parameters: ~kusto_management_client.models.DataConnectionValidation + 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 @@ -207,51 +293,158 @@ async def begin_data_connection_validation( :return: An instance of AsyncLROPoller that returns either DataConnectionValidationListResult or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~kusto_management_client.models.DataConnectionValidationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.DataConnectionValidationListResult] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataConnectionValidationListResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @distributed_trace_async + async def begin_data_connection_validation( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + parameters: Union[_models.DataConnectionValidation, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.DataConnectionValidationListResult]: + """Checks that the data connection parameters are valid. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param parameters: The data connection parameters supplied to the CreateOrUpdate operation. Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.kusto.models.DataConnectionValidation 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 DataConnectionValidationListResult + or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.DataConnectionValidationListResult] + :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.DataConnectionValidationListResult] + 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._data_connection_validation_initial( + raw_result = await self._data_connection_validation_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, parameters=parameters, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DataConnectionValidationListResult', pipeline_response) + deserialized = self._deserialize("DataConnectionValidationListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **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) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_data_connection_validation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnectionValidation'} # type: ignore + begin_data_connection_validation.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnectionValidation"} # type: ignore + + @overload + async def check_name_availability( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + data_connection_name: _models.DataConnectionCheckNameRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the data connection name is valid and is not already in use. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param data_connection_name: The name of the data connection. Required. + :type data_connection_name: ~azure.mgmt.kusto.models.DataConnectionCheckNameRequest + :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: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + data_connection_name: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the data connection name is valid and is not already in use. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param data_connection_name: The name of the data connection. Required. + :type data_connection_name: 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: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def check_name_availability( @@ -259,121 +452,153 @@ async def check_name_availability( resource_group_name: str, cluster_name: str, database_name: str, - data_connection_name: "_models.DataConnectionCheckNameRequest", + data_connection_name: Union[_models.DataConnectionCheckNameRequest, IO], **kwargs: Any - ) -> "_models.CheckNameResult": + ) -> _models.CheckNameResult: """Checks that the data connection name is valid and is not already in use. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str - :param data_connection_name: The name of the data connection. - :type data_connection_name: ~kusto_management_client.models.DataConnectionCheckNameRequest + :param data_connection_name: The name of the data connection. Is either a model type or a IO + type. Required. + :type data_connection_name: ~azure.mgmt.kusto.models.DataConnectionCheckNameRequest 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: CheckNameResult, or the result of cls(response) - :rtype: ~kusto_management_client.models.CheckNameResult - :raises: ~azure.core.exceptions.HttpResponseError + :return: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(data_connection_name, 'DataConnectionCheckNameRequest') + 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.CheckNameResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(data_connection_name, (IO, bytes)): + _content = data_connection_name + else: + _json = self._serialize.body(data_connection_name, "DataConnectionCheckNameRequest") request = build_check_name_availability_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + 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) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameResult', pipeline_response) + deserialized = self._deserialize("CheckNameResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/checkNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/checkNameAvailability"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - cluster_name: str, - database_name: str, - data_connection_name: str, - **kwargs: Any - ) -> "_models.DataConnection": + self, resource_group_name: str, cluster_name: str, database_name: str, data_connection_name: str, **kwargs: Any + ) -> _models.DataConnection: """Returns a data connection. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str - :param data_connection_name: The name of the data connection. + :param data_connection_name: The name of the data connection. Required. :type data_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataConnection, or the result of cls(response) - :rtype: ~kusto_management_client.models.DataConnection - :raises: ~azure.core.exceptions.HttpResponseError + :return: DataConnection or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.DataConnection + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataConnection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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.DataConnection] - request = build_get_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, data_connection_name=data_connection_name, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + 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) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataConnection', pipeline_response) + deserialized = self._deserialize("DataConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore async def _create_or_update_initial( self, @@ -381,33 +606,53 @@ async def _create_or_update_initial( cluster_name: str, database_name: str, data_connection_name: str, - parameters: "_models.DataConnection", + parameters: Union[_models.DataConnection, IO], **kwargs: Any - ) -> "_models.DataConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataConnection"] + ) -> _models.DataConnection: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'DataConnection') + 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.DataConnection] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataConnection") - request = build_create_or_update_request_initial( + request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, data_connection_name=data_connection_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + 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) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -415,21 +660,106 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DataConnection', pipeline_response) + deserialized = self._deserialize("DataConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DataConnection', pipeline_response) + deserialized = self._deserialize("DataConnection", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('DataConnection', pipeline_response) + deserialized = self._deserialize("DataConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + data_connection_name: str, + parameters: _models.DataConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DataConnection]: + """Creates or updates a data connection. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param data_connection_name: The name of the data connection. Required. + :type data_connection_name: str + :param parameters: The data connection parameters supplied to the CreateOrUpdate operation. + Required. + :type parameters: ~azure.mgmt.kusto.models.DataConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DataConnection or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.DataConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + data_connection_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DataConnection]: + """Creates or updates a data connection. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param data_connection_name: The name of the data connection. Required. + :type data_connection_name: str + :param parameters: The data connection parameters supplied to the CreateOrUpdate 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 DataConnection or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.DataConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -438,21 +768,26 @@ async def begin_create_or_update( cluster_name: str, database_name: str, data_connection_name: str, - parameters: "_models.DataConnection", + parameters: Union[_models.DataConnection, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.DataConnection"]: + ) -> AsyncLROPoller[_models.DataConnection]: """Creates or updates a data connection. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str - :param data_connection_name: The name of the data connection. + :param data_connection_name: The name of the data connection. Required. :type data_connection_name: str - :param parameters: The data connection parameters supplied to the CreateOrUpdate operation. - :type parameters: ~kusto_management_client.models.DataConnection + :param parameters: The data connection parameters supplied to the CreateOrUpdate operation. Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.kusto.models.DataConnection 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 @@ -463,52 +798,56 @@ async def begin_create_or_update( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either DataConnection or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~kusto_management_client.models.DataConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.DataConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataConnection] + 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, database_name=database_name, data_connection_name=data_connection_name, parameters=parameters, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DataConnection', pipeline_response) + deserialized = self._deserialize("DataConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore async def _update_initial( self, @@ -516,33 +855,53 @@ async def _update_initial( cluster_name: str, database_name: str, data_connection_name: str, - parameters: "_models.DataConnection", + parameters: Union[_models.DataConnection, IO], **kwargs: Any - ) -> "_models.DataConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataConnection"] + ) -> _models.DataConnection: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'DataConnection') + 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.DataConnection] - request = build_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataConnection") + + request = build_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, data_connection_name=data_connection_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + 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) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -551,25 +910,112 @@ async def _update_initial( response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('DataConnection', pipeline_response) + deserialized = self._deserialize("DataConnection", pipeline_response) if response.status_code == 201: - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - - deserialized = self._deserialize('DataConnection', pipeline_response) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("DataConnection", pipeline_response) if response.status_code == 202: - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - - deserialized = self._deserialize('DataConnection', pipeline_response) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("DataConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + data_connection_name: str, + parameters: _models.DataConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DataConnection]: + """Updates a data connection. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param data_connection_name: The name of the data connection. Required. + :type data_connection_name: str + :param parameters: The data connection parameters supplied to the Update operation. Required. + :type parameters: ~azure.mgmt.kusto.models.DataConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DataConnection or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.DataConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + data_connection_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DataConnection]: + """Updates a data connection. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param data_connection_name: The name of the data connection. Required. + :type data_connection_name: str + :param parameters: The data connection parameters supplied to the Update 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 DataConnection or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.DataConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -578,21 +1024,26 @@ async def begin_update( cluster_name: str, database_name: str, data_connection_name: str, - parameters: "_models.DataConnection", + parameters: Union[_models.DataConnection, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.DataConnection"]: + ) -> AsyncLROPoller[_models.DataConnection]: """Updates a data connection. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str - :param data_connection_name: The name of the data connection. + :param data_connection_name: The name of the data connection. Required. :type data_connection_name: str - :param parameters: The data connection parameters supplied to the Update operation. - :type parameters: ~kusto_management_client.models.DataConnection + :param parameters: The data connection parameters supplied to the Update operation. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.kusto.models.DataConnection 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 @@ -603,80 +1054,92 @@ async def begin_update( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either DataConnection or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~kusto_management_client.models.DataConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.DataConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataConnection] + 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, database_name=database_name, data_connection_name=data_connection_name, parameters=parameters, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DataConnection', pipeline_response) + deserialized = self._deserialize("DataConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore - async def _delete_initial( - self, - resource_group_name: str, - cluster_name: str, - database_name: str, - data_connection_name: str, - **kwargs: Any + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, cluster_name: str, database_name: str, data_connection_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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_initial( + request = build_delete_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, data_connection_name=data_connection_name, subscription_id=self._config.subscription_id, - template_url=self._delete_initial.metadata['url'], + 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) + 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 + ) - 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]: @@ -686,27 +1149,22 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - cluster_name: str, - database_name: str, - data_connection_name: str, - **kwargs: Any + self, resource_group_name: str, cluster_name: str, database_name: str, data_connection_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the data connection with the given name. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str - :param data_connection_name: The name of the data connection. + :param data_connection_name: The name of the data connection. Required. :type data_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. @@ -718,42 +1176,47 @@ async def begin_delete( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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, database_name=database_name, data_connection_name=data_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) - 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, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_database_principal_assignments_operations.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_database_principal_assignments_operations.py index 094d8831fdcc..a1b45b94f34a 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_database_principal_assignments_operations.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_database_principal_assignments_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,123 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse 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 from ..._vendor import _convert_request -from ...operations._database_principal_assignments_operations import build_check_name_availability_request, build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._database_principal_assignments_operations import ( + build_check_name_availability_request, + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DatabasePrincipalAssignmentsOperations: - """DatabasePrincipalAssignmentsOperations 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 DatabasePrincipalAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~kusto_management_client.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.kusto.aio.KustoManagementClient`'s + :attr:`database_principal_assignments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + async def check_name_availability( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + principal_assignment_name: _models.DatabasePrincipalAssignmentCheckNameRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the database principal assignment is valid and is not already in use. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param principal_assignment_name: The name of the resource. Required. + :type principal_assignment_name: + ~azure.mgmt.kusto.models.DatabasePrincipalAssignmentCheckNameRequest + :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: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + principal_assignment_name: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the database principal assignment is valid and is not already in use. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param principal_assignment_name: The name of the resource. Required. + :type principal_assignment_name: 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: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def check_name_availability( @@ -54,63 +130,87 @@ async def check_name_availability( resource_group_name: str, cluster_name: str, database_name: str, - principal_assignment_name: "_models.DatabasePrincipalAssignmentCheckNameRequest", + principal_assignment_name: Union[_models.DatabasePrincipalAssignmentCheckNameRequest, IO], **kwargs: Any - ) -> "_models.CheckNameResult": + ) -> _models.CheckNameResult: """Checks that the database principal assignment is valid and is not already in use. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str - :param principal_assignment_name: The name of the resource. + :param principal_assignment_name: The name of the resource. Is either a model type or a IO + type. Required. :type principal_assignment_name: - ~kusto_management_client.models.DatabasePrincipalAssignmentCheckNameRequest + ~azure.mgmt.kusto.models.DatabasePrincipalAssignmentCheckNameRequest 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: CheckNameResult, or the result of cls(response) - :rtype: ~kusto_management_client.models.CheckNameResult - :raises: ~azure.core.exceptions.HttpResponseError + :return: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameResult] - _json = self._serialize.body(principal_assignment_name, 'DatabasePrincipalAssignmentCheckNameRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(principal_assignment_name, (IO, bytes)): + _content = principal_assignment_name + else: + _json = self._serialize.body(principal_assignment_name, "DatabasePrincipalAssignmentCheckNameRequest") request = build_check_name_availability_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + 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) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameResult', pipeline_response) + deserialized = self._deserialize("CheckNameResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/checkPrincipalAssignmentNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/checkPrincipalAssignmentNameAvailability"} # type: ignore @distributed_trace_async async def get( @@ -120,56 +220,69 @@ async def get( database_name: str, principal_assignment_name: str, **kwargs: Any - ) -> "_models.DatabasePrincipalAssignment": + ) -> _models.DatabasePrincipalAssignment: """Gets a Kusto cluster database principalAssignment. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str - :param principal_assignment_name: The name of the Kusto principalAssignment. + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. :type principal_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DatabasePrincipalAssignment, or the result of cls(response) - :rtype: ~kusto_management_client.models.DatabasePrincipalAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :return: DatabasePrincipalAssignment or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.DatabasePrincipalAssignment + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabasePrincipalAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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.DatabasePrincipalAssignment] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, principal_assignment_name=principal_assignment_name, - template_url=self.get.metadata['url'], + 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) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DatabasePrincipalAssignment', pipeline_response) + deserialized = self._deserialize("DatabasePrincipalAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}"} # type: ignore async def _create_or_update_initial( self, @@ -177,33 +290,53 @@ async def _create_or_update_initial( cluster_name: str, database_name: str, principal_assignment_name: str, - parameters: "_models.DatabasePrincipalAssignment", + parameters: Union[_models.DatabasePrincipalAssignment, IO], **kwargs: Any - ) -> "_models.DatabasePrincipalAssignment": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabasePrincipalAssignment"] + ) -> _models.DatabasePrincipalAssignment: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'DatabasePrincipalAssignment') + 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.DatabasePrincipalAssignment] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DatabasePrincipalAssignment") + + request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, principal_assignment_name=principal_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + 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) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -211,41 +344,91 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DatabasePrincipalAssignment', pipeline_response) + deserialized = self._deserialize("DatabasePrincipalAssignment", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DatabasePrincipalAssignment', pipeline_response) + deserialized = self._deserialize("DatabasePrincipalAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + principal_assignment_name: str, + parameters: _models.DatabasePrincipalAssignment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DatabasePrincipalAssignment]: + """Creates a Kusto cluster database principalAssignment. - @distributed_trace_async + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. + :type principal_assignment_name: str + :param parameters: The Kusto principalAssignments parameters supplied for the operation. + Required. + :type parameters: ~azure.mgmt.kusto.models.DatabasePrincipalAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DatabasePrincipalAssignment or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.DatabasePrincipalAssignment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload async def begin_create_or_update( self, resource_group_name: str, cluster_name: str, database_name: str, principal_assignment_name: str, - parameters: "_models.DatabasePrincipalAssignment", + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DatabasePrincipalAssignment"]: + ) -> AsyncLROPoller[_models.DatabasePrincipalAssignment]: """Creates a Kusto cluster database principalAssignment. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str - :param principal_assignment_name: The name of the Kusto principalAssignment. + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. :type principal_assignment_name: str :param parameters: The Kusto principalAssignments parameters supplied for the operation. - :type parameters: ~kusto_management_client.models.DatabasePrincipalAssignment + 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 @@ -257,54 +440,100 @@ async def begin_create_or_update( :return: An instance of AsyncLROPoller that returns either DatabasePrincipalAssignment or the result of cls(response) :rtype: - ~azure.core.polling.AsyncLROPoller[~kusto_management_client.models.DatabasePrincipalAssignment] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.DatabasePrincipalAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabasePrincipalAssignment"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + principal_assignment_name: str, + parameters: Union[_models.DatabasePrincipalAssignment, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.DatabasePrincipalAssignment]: + """Creates a Kusto cluster database principalAssignment. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. + :type principal_assignment_name: str + :param parameters: The Kusto principalAssignments parameters supplied for the operation. Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.kusto.models.DatabasePrincipalAssignment 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 DatabasePrincipalAssignment or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.DatabasePrincipalAssignment] + :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.DatabasePrincipalAssignment] + 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, database_name=database_name, principal_assignment_name=principal_assignment_name, parameters=parameters, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DatabasePrincipalAssignment', pipeline_response) + deserialized = self._deserialize("DatabasePrincipalAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}"} # type: ignore - async def _delete_initial( + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, @@ -312,25 +541,38 @@ async def _delete_initial( principal_assignment_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', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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, database_name=database_name, principal_assignment_name=principal_assignment_name, - template_url=self._delete_initial.metadata['url'], + 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) + 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 + ) - 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]: @@ -340,8 +582,7 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}"} # type: ignore @distributed_trace_async async def begin_delete( @@ -355,12 +596,13 @@ async def begin_delete( """Deletes a Kusto principalAssignment. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str - :param principal_assignment_name: The name of the Kusto principalAssignment. + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. :type principal_assignment_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. @@ -372,98 +614,109 @@ async def begin_delete( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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, database_name=database_name, principal_assignment_name=principal_assignment_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) - 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, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - cluster_name: str, - database_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.DatabasePrincipalAssignmentListResult"]: + self, resource_group_name: str, cluster_name: str, database_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DatabasePrincipalAssignment"]: """Lists all Kusto cluster database principalAssignments. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabasePrincipalAssignmentListResult or the - result of cls(response) + :return: An iterator like instance of either DatabasePrincipalAssignment or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~kusto_management_client.models.DatabasePrincipalAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kusto.models.DatabasePrincipalAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabasePrincipalAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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.DatabasePrincipalAssignmentListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, - template_url=self.list.metadata['url'], + 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) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_name=cluster_name, - database_name=database_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -477,7 +730,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -486,8 +741,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments"} # type: ignore diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_databases_operations.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_databases_operations.py index 3843207a8421..d636574fe8d9 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_databases_operations.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_databases_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,154 +6,256 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse 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 from ..._vendor import _convert_request -from ...operations._databases_operations import build_add_principals_request, build_check_name_availability_request, build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_cluster_request, build_list_principals_request, build_remove_principals_request, build_update_request_initial -T = TypeVar('T') +from ...operations._databases_operations import ( + build_add_principals_request, + build_check_name_availability_request, + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_cluster_request, + build_list_principals_request, + build_remove_principals_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DatabasesOperations: - """DatabasesOperations 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 DatabasesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~kusto_management_client.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.kusto.aio.KustoManagementClient`'s + :attr:`databases` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + async def check_name_availability( + self, + resource_group_name: str, + cluster_name: str, + resource_name: _models.CheckNameRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the databases resource name is valid and is not already in use. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: ~azure.mgmt.kusto.models.CheckNameRequest + :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: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, + resource_group_name: str, + cluster_name: str, + resource_name: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the databases resource name is valid and is not already in use. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: 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: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def check_name_availability( self, resource_group_name: str, cluster_name: str, - resource_name: "_models.CheckNameRequest", + resource_name: Union[_models.CheckNameRequest, IO], **kwargs: Any - ) -> "_models.CheckNameResult": + ) -> _models.CheckNameResult: """Checks that the databases resource name is valid and is not already in use. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param resource_name: The name of the resource. - :type resource_name: ~kusto_management_client.models.CheckNameRequest + :param resource_name: The name of the resource. Is either a model type or a IO type. Required. + :type resource_name: ~azure.mgmt.kusto.models.CheckNameRequest 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: CheckNameResult, or the result of cls(response) - :rtype: ~kusto_management_client.models.CheckNameResult - :raises: ~azure.core.exceptions.HttpResponseError + :return: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(resource_name, 'CheckNameRequest') + 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.CheckNameResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource_name, (IO, bytes)): + _content = resource_name + else: + _json = self._serialize.body(resource_name, "CheckNameRequest") request = build_check_name_availability_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, - template_url=self.check_name_availability.metadata['url'], + 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) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameResult', pipeline_response) + deserialized = self._deserialize("CheckNameResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/checkNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/checkNameAvailability"} # type: ignore @distributed_trace def list_by_cluster( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.DatabaseListResult"]: + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Database"]: """Returns the list of databases of the given Kusto cluster. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto 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 DatabaseListResult or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~kusto_management_client.models.DatabaseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Database or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kusto.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabaseListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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.DatabaseListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_cluster_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, - template_url=self.list_by_cluster.metadata['url'], + 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) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_cluster_request( - resource_group_name=resource_group_name, - cluster_name=cluster_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -166,7 +269,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -175,98 +280,127 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_cluster.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases'} # type: ignore + list_by_cluster.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - cluster_name: str, - database_name: str, - **kwargs: Any - ) -> "_models.Database": + self, resource_group_name: str, cluster_name: str, database_name: str, **kwargs: Any + ) -> _models.Database: """Returns a database. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Database, or the result of cls(response) - :rtype: ~kusto_management_client.models.Database - :raises: ~azure.core.exceptions.HttpResponseError + :return: Database or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.Database + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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.Database] - request = build_get_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + 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) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Database', pipeline_response) + deserialized = self._deserialize("Database", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, cluster_name: str, database_name: str, - parameters: "_models.Database", + parameters: Union[_models.Database, IO], + caller_role: Union[str, "_models.CallerRole"] = "Admin", **kwargs: Any - ) -> "_models.Database": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] + ) -> _models.Database: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Database') + 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.Database] - request = build_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Database") + + request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, + caller_role=caller_role, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + 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) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -274,21 +408,108 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Database', pipeline_response) + deserialized = self._deserialize("Database", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Database', pipeline_response) + deserialized = self._deserialize("Database", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('Database', pipeline_response) + deserialized = self._deserialize("Database", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + parameters: _models.Database, + caller_role: Union[str, "_models.CallerRole"] = "Admin", + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Database]: + """Creates or updates a database. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param parameters: The database parameters supplied to the CreateOrUpdate operation. Required. + :type parameters: ~azure.mgmt.kusto.models.Database + :param caller_role: By default, any user who run operation on a database become an Admin on it. + This property allows the caller to exclude the caller from Admins list. Known values are: + "Admin" and "None". Default value is "Admin". + :type caller_role: str or ~azure.mgmt.kusto.models.CallerRole + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Database or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + parameters: IO, + caller_role: Union[str, "_models.CallerRole"] = "Admin", + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Database]: + """Creates or updates a database. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param parameters: The database parameters supplied to the CreateOrUpdate operation. Required. + :type parameters: IO + :param caller_role: By default, any user who run operation on a database become an Admin on it. + This property allows the caller to exclude the caller from Admins list. Known values are: + "Admin" and "None". Default value is "Admin". + :type caller_role: str or ~azure.mgmt.kusto.models.CallerRole + :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 Database or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -296,19 +517,29 @@ async def begin_create_or_update( resource_group_name: str, cluster_name: str, database_name: str, - parameters: "_models.Database", + parameters: Union[_models.Database, IO], + caller_role: Union[str, "_models.CallerRole"] = "Admin", **kwargs: Any - ) -> AsyncLROPoller["_models.Database"]: + ) -> AsyncLROPoller[_models.Database]: """Creates or updates a database. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str - :param parameters: The database parameters supplied to the CreateOrUpdate operation. - :type parameters: ~kusto_management_client.models.Database + :param parameters: The database parameters supplied to the CreateOrUpdate operation. Is either + a model type or a IO type. Required. + :type parameters: ~azure.mgmt.kusto.models.Database or IO + :param caller_role: By default, any user who run operation on a database become an Admin on it. + This property allows the caller to exclude the caller from Admins list. Known values are: + "Admin" and "None". Default value is "Admin". + :type caller_role: str or ~azure.mgmt.kusto.models.CallerRole + :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 @@ -319,83 +550,110 @@ async def begin_create_or_update( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Database or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~kusto_management_client.models.Database] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Database] + 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, database_name=database_name, parameters=parameters, + caller_role=caller_role, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('Database', pipeline_response) + deserialized = self._deserialize("Database", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}"} # type: ignore async def _update_initial( self, resource_group_name: str, cluster_name: str, database_name: str, - parameters: "_models.Database", + parameters: Union[_models.Database, IO], + caller_role: Union[str, "_models.CallerRole"] = "Admin", **kwargs: Any - ) -> "_models.Database": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] + ) -> _models.Database: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Database') + 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.Database] - request = build_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Database") + + request = build_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, + caller_role=caller_role, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + 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) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -404,25 +662,116 @@ async def _update_initial( response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('Database', pipeline_response) + deserialized = self._deserialize("Database", pipeline_response) if response.status_code == 201: - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - - deserialized = self._deserialize('Database', pipeline_response) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Database", pipeline_response) if response.status_code == 202: - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - - deserialized = self._deserialize('Database', pipeline_response) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Database", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + parameters: _models.Database, + caller_role: Union[str, "_models.CallerRole"] = "Admin", + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Database]: + """Updates a database. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param parameters: The database parameters supplied to the Update operation. Required. + :type parameters: ~azure.mgmt.kusto.models.Database + :param caller_role: By default, any user who run operation on a database become an Admin on it. + This property allows the caller to exclude the caller from Admins list. Known values are: + "Admin" and "None". Default value is "Admin". + :type caller_role: str or ~azure.mgmt.kusto.models.CallerRole + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Database or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + parameters: IO, + caller_role: Union[str, "_models.CallerRole"] = "Admin", + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Database]: + """Updates a database. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param parameters: The database parameters supplied to the Update operation. Required. + :type parameters: IO + :param caller_role: By default, any user who run operation on a database become an Admin on it. + This property allows the caller to exclude the caller from Admins list. Known values are: + "Admin" and "None". Default value is "Admin". + :type caller_role: str or ~azure.mgmt.kusto.models.CallerRole + :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 Database or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -430,19 +779,29 @@ async def begin_update( resource_group_name: str, cluster_name: str, database_name: str, - parameters: "_models.Database", + parameters: Union[_models.Database, IO], + caller_role: Union[str, "_models.CallerRole"] = "Admin", **kwargs: Any - ) -> AsyncLROPoller["_models.Database"]: + ) -> AsyncLROPoller[_models.Database]: """Updates a database. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str - :param parameters: The database parameters supplied to the Update operation. - :type parameters: ~kusto_management_client.models.Database + :param parameters: The database parameters supplied to the Update operation. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.kusto.models.Database or IO + :param caller_role: By default, any user who run operation on a database become an Admin on it. + This property allows the caller to exclude the caller from Admins list. Known values are: + "Admin" and "None". Default value is "Admin". + :type caller_role: str or ~azure.mgmt.kusto.models.CallerRole + :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 @@ -453,77 +812,91 @@ async def begin_update( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Database or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~kusto_management_client.models.Database] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Database] + 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, database_name=database_name, parameters=parameters, + caller_role=caller_role, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('Database', pipeline_response) + deserialized = self._deserialize("Database", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}"} # type: ignore - async def _delete_initial( - self, - resource_group_name: str, - cluster_name: str, - database_name: str, - **kwargs: Any + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, cluster_name: str, database_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', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( + 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, database_name=database_name, subscription_id=self._config.subscription_id, - template_url=self._delete_initial.metadata['url'], + 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) + 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 + ) - 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]: @@ -533,24 +906,20 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}"} # type: ignore @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - cluster_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, cluster_name: str, database_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the database with the given name. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_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. @@ -562,97 +931,106 @@ async def begin_delete( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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, database_name=database_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) - 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, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}"} # type: ignore @distributed_trace def list_principals( - self, - resource_group_name: str, - cluster_name: str, - database_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.DatabasePrincipalListResult"]: + self, resource_group_name: str, cluster_name: str, database_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DatabasePrincipal"]: """Returns a list of database principals of the given Kusto cluster and database. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabasePrincipalListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~kusto_management_client.models.DatabasePrincipalListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DatabasePrincipal or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kusto.models.DatabasePrincipal] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabasePrincipalListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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.DatabasePrincipalListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_principals_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, - template_url=self.list_principals.metadata['url'], + api_version=api_version, + template_url=self.list_principals.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_principals_request( - resource_group_name=resource_group_name, - cluster_name=cluster_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -666,7 +1044,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -675,11 +1055,71 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_principals.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/listPrincipals'} # type: ignore + list_principals.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/listPrincipals"} # type: ignore + + @overload + async def add_principals( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + database_principals_to_add: _models.DatabasePrincipalListRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabasePrincipalListResult: + """Add Database principals permissions. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param database_principals_to_add: List of database principals to add. Required. + :type database_principals_to_add: ~azure.mgmt.kusto.models.DatabasePrincipalListRequest + :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: DatabasePrincipalListResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.DatabasePrincipalListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def add_principals( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + database_principals_to_add: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabasePrincipalListResult: + """Add Database principals permissions. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param database_principals_to_add: List of database principals to add. Required. + :type database_principals_to_add: 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: DatabasePrincipalListResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.DatabasePrincipalListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def add_principals( @@ -687,62 +1127,148 @@ async def add_principals( resource_group_name: str, cluster_name: str, database_name: str, - database_principals_to_add: "_models.DatabasePrincipalListRequest", + database_principals_to_add: Union[_models.DatabasePrincipalListRequest, IO], **kwargs: Any - ) -> "_models.DatabasePrincipalListResult": + ) -> _models.DatabasePrincipalListResult: """Add Database principals permissions. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str - :param database_principals_to_add: List of database principals to add. - :type database_principals_to_add: ~kusto_management_client.models.DatabasePrincipalListRequest + :param database_principals_to_add: List of database principals to add. Is either a model type + or a IO type. Required. + :type database_principals_to_add: ~azure.mgmt.kusto.models.DatabasePrincipalListRequest 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: DatabasePrincipalListResult, or the result of cls(response) - :rtype: ~kusto_management_client.models.DatabasePrincipalListResult - :raises: ~azure.core.exceptions.HttpResponseError + :return: DatabasePrincipalListResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.DatabasePrincipalListResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabasePrincipalListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DatabasePrincipalListResult] - _json = self._serialize.body(database_principals_to_add, 'DatabasePrincipalListRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(database_principals_to_add, (IO, bytes)): + _content = database_principals_to_add + else: + _json = self._serialize.body(database_principals_to_add, "DatabasePrincipalListRequest") request = build_add_principals_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.add_principals.metadata['url'], + content=_content, + template_url=self.add_principals.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DatabasePrincipalListResult', pipeline_response) + deserialized = self._deserialize("DatabasePrincipalListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - add_principals.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/addPrincipals'} # type: ignore + add_principals.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/addPrincipals"} # type: ignore + + @overload + async def remove_principals( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + database_principals_to_remove: _models.DatabasePrincipalListRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabasePrincipalListResult: + """Remove Database principals permissions. + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param database_principals_to_remove: List of database principals to remove. Required. + :type database_principals_to_remove: ~azure.mgmt.kusto.models.DatabasePrincipalListRequest + :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: DatabasePrincipalListResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.DatabasePrincipalListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def remove_principals( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + database_principals_to_remove: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabasePrincipalListResult: + """Remove Database principals permissions. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param database_principals_to_remove: List of database principals to remove. Required. + :type database_principals_to_remove: 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: DatabasePrincipalListResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.DatabasePrincipalListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def remove_principals( @@ -750,60 +1276,84 @@ async def remove_principals( resource_group_name: str, cluster_name: str, database_name: str, - database_principals_to_remove: "_models.DatabasePrincipalListRequest", + database_principals_to_remove: Union[_models.DatabasePrincipalListRequest, IO], **kwargs: Any - ) -> "_models.DatabasePrincipalListResult": + ) -> _models.DatabasePrincipalListResult: """Remove Database principals permissions. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str - :param database_principals_to_remove: List of database principals to remove. - :type database_principals_to_remove: - ~kusto_management_client.models.DatabasePrincipalListRequest + :param database_principals_to_remove: List of database principals to remove. Is either a model + type or a IO type. Required. + :type database_principals_to_remove: ~azure.mgmt.kusto.models.DatabasePrincipalListRequest 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: DatabasePrincipalListResult, or the result of cls(response) - :rtype: ~kusto_management_client.models.DatabasePrincipalListResult - :raises: ~azure.core.exceptions.HttpResponseError + :return: DatabasePrincipalListResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.DatabasePrincipalListResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabasePrincipalListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DatabasePrincipalListResult] - _json = self._serialize.body(database_principals_to_remove, 'DatabasePrincipalListRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(database_principals_to_remove, (IO, bytes)): + _content = database_principals_to_remove + else: + _json = self._serialize.body(database_principals_to_remove, "DatabasePrincipalListRequest") request = build_remove_principals_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.remove_principals.metadata['url'], + content=_content, + template_url=self.remove_principals.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DatabasePrincipalListResult', pipeline_response) + deserialized = self._deserialize("DatabasePrincipalListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - remove_principals.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/removePrincipals'} # type: ignore - + remove_principals.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/removePrincipals"} # type: ignore diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_managed_private_endpoints_operations.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_managed_private_endpoints_operations.py index f561fc0f1bd7..92674c8fc24c 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_managed_private_endpoints_operations.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_managed_private_endpoints_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,155 +6,255 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse 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 from ..._vendor import _convert_request -from ...operations._managed_private_endpoints_operations import build_check_name_availability_request, build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._managed_private_endpoints_operations import ( + build_check_name_availability_request, + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ManagedPrivateEndpointsOperations: - """ManagedPrivateEndpointsOperations 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 ManagedPrivateEndpointsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~kusto_management_client.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.kusto.aio.KustoManagementClient`'s + :attr:`managed_private_endpoints` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + async def check_name_availability( + self, + resource_group_name: str, + cluster_name: str, + resource_name: _models.ManagedPrivateEndpointsCheckNameRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the managed private endpoints resource name is valid and is not already in use. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: ~azure.mgmt.kusto.models.ManagedPrivateEndpointsCheckNameRequest + :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: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, + resource_group_name: str, + cluster_name: str, + resource_name: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the managed private endpoints resource name is valid and is not already in use. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: 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: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def check_name_availability( self, resource_group_name: str, cluster_name: str, - resource_name: "_models.ManagedPrivateEndpointsCheckNameRequest", + resource_name: Union[_models.ManagedPrivateEndpointsCheckNameRequest, IO], **kwargs: Any - ) -> "_models.CheckNameResult": + ) -> _models.CheckNameResult: """Checks that the managed private endpoints resource name is valid and is not already in use. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param resource_name: The name of the resource. - :type resource_name: ~kusto_management_client.models.ManagedPrivateEndpointsCheckNameRequest + :param resource_name: The name of the resource. Is either a model type or a IO type. Required. + :type resource_name: ~azure.mgmt.kusto.models.ManagedPrivateEndpointsCheckNameRequest 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: CheckNameResult, or the result of cls(response) - :rtype: ~kusto_management_client.models.CheckNameResult - :raises: ~azure.core.exceptions.HttpResponseError + :return: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(resource_name, 'ManagedPrivateEndpointsCheckNameRequest') + 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.CheckNameResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource_name, (IO, bytes)): + _content = resource_name + else: + _json = self._serialize.body(resource_name, "ManagedPrivateEndpointsCheckNameRequest") request = build_check_name_availability_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, - template_url=self.check_name_availability.metadata['url'], + 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) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameResult', pipeline_response) + deserialized = self._deserialize("CheckNameResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpointsCheckNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpointsCheckNameAvailability"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ManagedPrivateEndpointListResult"]: + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ManagedPrivateEndpoint"]: """Returns the list of managed private endpoints. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto 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 ManagedPrivateEndpointListResult or the result of + :return: An iterator like instance of either ManagedPrivateEndpoint or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~kusto_management_client.models.ManagedPrivateEndpointListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kusto.models.ManagedPrivateEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedPrivateEndpointListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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.ManagedPrivateEndpointListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_name=cluster_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -167,7 +268,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -176,98 +279,125 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - cluster_name: str, - managed_private_endpoint_name: str, - **kwargs: Any - ) -> "_models.ManagedPrivateEndpoint": + self, resource_group_name: str, cluster_name: str, managed_private_endpoint_name: str, **kwargs: Any + ) -> _models.ManagedPrivateEndpoint: """Gets a managed private endpoint. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param managed_private_endpoint_name: The name of the managed private endpoint. + :param managed_private_endpoint_name: The name of the managed private endpoint. Required. :type managed_private_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagedPrivateEndpoint, or the result of cls(response) - :rtype: ~kusto_management_client.models.ManagedPrivateEndpoint - :raises: ~azure.core.exceptions.HttpResponseError + :return: ManagedPrivateEndpoint or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.ManagedPrivateEndpoint + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedPrivateEndpoint"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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.ManagedPrivateEndpoint] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, managed_private_endpoint_name=managed_private_endpoint_name, - template_url=self.get.metadata['url'], + 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) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagedPrivateEndpoint', pipeline_response) + deserialized = self._deserialize("ManagedPrivateEndpoint", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, cluster_name: str, managed_private_endpoint_name: str, - parameters: "_models.ManagedPrivateEndpoint", + parameters: Union[_models.ManagedPrivateEndpoint, IO], **kwargs: Any - ) -> "_models.ManagedPrivateEndpoint": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedPrivateEndpoint"] + ) -> _models.ManagedPrivateEndpoint: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ManagedPrivateEndpoint') + 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.ManagedPrivateEndpoint] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ManagedPrivateEndpoint") + + request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, managed_private_endpoint_name=managed_private_endpoint_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + 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) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -275,21 +405,98 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ManagedPrivateEndpoint', pipeline_response) + deserialized = self._deserialize("ManagedPrivateEndpoint", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ManagedPrivateEndpoint', pipeline_response) + deserialized = self._deserialize("ManagedPrivateEndpoint", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ManagedPrivateEndpoint', pipeline_response) + deserialized = self._deserialize("ManagedPrivateEndpoint", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + managed_private_endpoint_name: str, + parameters: _models.ManagedPrivateEndpoint, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedPrivateEndpoint]: + """Creates a managed private endpoint. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param managed_private_endpoint_name: The name of the managed private endpoint. Required. + :type managed_private_endpoint_name: str + :param parameters: The managed private endpoint parameters. Required. + :type parameters: ~azure.mgmt.kusto.models.ManagedPrivateEndpoint + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ManagedPrivateEndpoint or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.ManagedPrivateEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + managed_private_endpoint_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedPrivateEndpoint]: + """Creates a managed private endpoint. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param managed_private_endpoint_name: The name of the managed private endpoint. Required. + :type managed_private_endpoint_name: str + :param parameters: The managed private endpoint 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 ManagedPrivateEndpoint or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.ManagedPrivateEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -297,19 +504,24 @@ async def begin_create_or_update( resource_group_name: str, cluster_name: str, managed_private_endpoint_name: str, - parameters: "_models.ManagedPrivateEndpoint", + parameters: Union[_models.ManagedPrivateEndpoint, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ManagedPrivateEndpoint"]: + ) -> AsyncLROPoller[_models.ManagedPrivateEndpoint]: """Creates a managed private endpoint. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param managed_private_endpoint_name: The name of the managed private endpoint. + :param managed_private_endpoint_name: The name of the managed private endpoint. Required. :type managed_private_endpoint_name: str - :param parameters: The managed private endpoint parameters. - :type parameters: ~kusto_management_client.models.ManagedPrivateEndpoint + :param parameters: The managed private endpoint parameters. Is either a model type or a IO + type. Required. + :type parameters: ~azure.mgmt.kusto.models.ManagedPrivateEndpoint 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 @@ -320,84 +532,107 @@ async def begin_create_or_update( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either ManagedPrivateEndpoint or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~kusto_management_client.models.ManagedPrivateEndpoint] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.ManagedPrivateEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedPrivateEndpoint"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagedPrivateEndpoint] + 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, managed_private_endpoint_name=managed_private_endpoint_name, parameters=parameters, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ManagedPrivateEndpoint', pipeline_response) + deserialized = self._deserialize("ManagedPrivateEndpoint", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}"} # type: ignore async def _update_initial( self, resource_group_name: str, cluster_name: str, managed_private_endpoint_name: str, - parameters: "_models.ManagedPrivateEndpoint", + parameters: Union[_models.ManagedPrivateEndpoint, IO], **kwargs: Any - ) -> "_models.ManagedPrivateEndpoint": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedPrivateEndpoint"] + ) -> _models.ManagedPrivateEndpoint: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ManagedPrivateEndpoint') + 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.ManagedPrivateEndpoint] - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ManagedPrivateEndpoint") + + request = build_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, managed_private_endpoint_name=managed_private_endpoint_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + 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) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -406,20 +641,99 @@ async def _update_initial( response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('ManagedPrivateEndpoint', pipeline_response) + deserialized = self._deserialize("ManagedPrivateEndpoint", pipeline_response) if response.status_code == 202: - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - - deserialized = self._deserialize('ManagedPrivateEndpoint', pipeline_response) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("ManagedPrivateEndpoint", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_name: str, + managed_private_endpoint_name: str, + parameters: _models.ManagedPrivateEndpoint, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedPrivateEndpoint]: + """Updates a managed private endpoint. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param managed_private_endpoint_name: The name of the managed private endpoint. Required. + :type managed_private_endpoint_name: str + :param parameters: The managed private endpoint parameters. Required. + :type parameters: ~azure.mgmt.kusto.models.ManagedPrivateEndpoint + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ManagedPrivateEndpoint or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.ManagedPrivateEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_name: str, + managed_private_endpoint_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedPrivateEndpoint]: + """Updates a managed private endpoint. + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param managed_private_endpoint_name: The name of the managed private endpoint. Required. + :type managed_private_endpoint_name: str + :param parameters: The managed private endpoint 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 ManagedPrivateEndpoint or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.ManagedPrivateEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -427,19 +741,24 @@ async def begin_update( resource_group_name: str, cluster_name: str, managed_private_endpoint_name: str, - parameters: "_models.ManagedPrivateEndpoint", + parameters: Union[_models.ManagedPrivateEndpoint, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ManagedPrivateEndpoint"]: + ) -> AsyncLROPoller[_models.ManagedPrivateEndpoint]: """Updates a managed private endpoint. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param managed_private_endpoint_name: The name of the managed private endpoint. + :param managed_private_endpoint_name: The name of the managed private endpoint. Required. :type managed_private_endpoint_name: str - :param parameters: The managed private endpoint parameters. - :type parameters: ~kusto_management_client.models.ManagedPrivateEndpoint + :param parameters: The managed private endpoint parameters. Is either a model type or a IO + type. Required. + :type parameters: ~azure.mgmt.kusto.models.ManagedPrivateEndpoint 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 @@ -450,78 +769,90 @@ async def begin_update( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either ManagedPrivateEndpoint or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~kusto_management_client.models.ManagedPrivateEndpoint] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.ManagedPrivateEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedPrivateEndpoint"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagedPrivateEndpoint] + 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, managed_private_endpoint_name=managed_private_endpoint_name, parameters=parameters, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ManagedPrivateEndpoint', pipeline_response) + deserialized = self._deserialize("ManagedPrivateEndpoint", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}"} # type: ignore - async def _delete_initial( - self, - resource_group_name: str, - cluster_name: str, - managed_private_endpoint_name: str, - **kwargs: Any + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, cluster_name: str, managed_private_endpoint_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', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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, managed_private_endpoint_name=managed_private_endpoint_name, - template_url=self._delete_initial.metadata['url'], + 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) + 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 + ) - 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]: @@ -531,24 +862,20 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}"} # type: ignore @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - cluster_name: str, - managed_private_endpoint_name: str, - **kwargs: Any + self, resource_group_name: str, cluster_name: str, managed_private_endpoint_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a managed private endpoint. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param managed_private_endpoint_name: The name of the managed private endpoint. + :param managed_private_endpoint_name: The name of the managed private endpoint. Required. :type managed_private_endpoint_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. @@ -560,41 +887,46 @@ async def begin_delete( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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, managed_private_endpoint_name=managed_private_endpoint_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) - 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, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}"} # type: ignore diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_operations.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_operations.py index 86419f8297e4..b1c5061bf17d 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_operations.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,81 +6,95 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse 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._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: ~kusto_management_client.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.kusto.aio.KustoManagementClient`'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") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists available operations for the Microsoft.Kusto provider. :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[~kusto_management_client.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.kusto.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', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + 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) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -93,7 +108,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -102,8 +119,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.Kusto/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Kusto/operations"} # type: ignore diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_operations_results_location_operations.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_operations_results_location_operations.py index bff9af7d72b2..9f3d6b617ea9 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_operations_results_location_operations.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_operations_results_location_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,80 +6,95 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar -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 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._operations_results_location_operations import build_get_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class OperationsResultsLocationOperations: - """OperationsResultsLocationOperations 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 OperationsResultsLocationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~kusto_management_client.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.kusto.aio.KustoManagementClient`'s + :attr:`operations_results_location` 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 get( - self, - location: str, - operation_id: str, - **kwargs: Any + async def get( # pylint: disable=inconsistent-return-statements + self, location: str, operation_id: str, **kwargs: Any ) -> None: """Returns operation results. - :param location: Azure location (region) name. + :param location: Azure location (region) name. Required. :type location: str - :param operation_id: The Guid of the operation ID. + :param operation_id: The Guid of the operation ID. Required. :type operation_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', {})) + 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_get_request( - subscription_id=self._config.subscription_id, location=location, operation_id=operation_id, - template_url=self.get.metadata['url'], + 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) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -88,5 +104,4 @@ async def get( if cls: return cls(pipeline_response, None, {}) - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/locations/{location}/operationResults/{operationId}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/locations/{location}/operationResults/{operationId}"} # type: ignore diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_operations_results_operations.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_operations_results_operations.py index e8b54d3fb168..af1d2eda9bd6 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_operations_results_operations.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_operations_results_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,92 +6,104 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, 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 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._operations_results_operations import build_get_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class OperationsResultsOperations: - """OperationsResultsOperations 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 OperationsResultsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~kusto_management_client.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.kusto.aio.KustoManagementClient`'s + :attr:`operations_results` 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 get( - self, - location: str, - operation_id: str, - **kwargs: Any - ) -> "_models.OperationResult": + async def get(self, location: str, operation_id: str, **kwargs: Any) -> _models.OperationResult: """Returns operation results. - :param location: Azure location (region) name. + :param location: Azure location (region) name. Required. :type location: str - :param operation_id: The Guid of the operation ID. + :param operation_id: The Guid of the operation ID. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationResult, or the result of cls(response) - :rtype: ~kusto_management_client.models.OperationResult - :raises: ~azure.core.exceptions.HttpResponseError + :return: OperationResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.OperationResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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.OperationResult] - request = build_get_request( - subscription_id=self._config.subscription_id, location=location, operation_id=operation_id, - template_url=self.get.metadata['url'], + 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) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('OperationResult', pipeline_response) + deserialized = self._deserialize("OperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/locations/{location}/operationResults/{operationId}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/locations/{location}/operationResults/{operationId}"} # type: ignore diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_patch.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/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/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_private_endpoint_connections_operations.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_private_endpoint_connections_operations.py index 6ca8901bdc6a..5d266bd05309 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/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,115 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse 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 from ..._vendor import _convert_request -from ...operations._private_endpoint_connections_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._private_endpoint_connections_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class 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: ~kusto_management_client.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.kusto.aio.KustoManagementClient`'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( - 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"]: """Returns the list of private endpoint connections. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto 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) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~kusto_management_client.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kusto.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', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_name=cluster_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -108,7 +128,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -117,98 +139,125 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateEndpointConnections'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateEndpointConnections"} # 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 a private endpoint connection. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto 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) - :rtype: ~kusto_management_client.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_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', {})) + 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( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, private_endpoint_connection_name=private_endpoint_connection_name, - template_url=self.get.metadata['url'], + 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) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('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.Kusto/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}"} # 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', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + 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] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + 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, - template_url=self._create_or_update_initial.metadata['url'], + 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) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -216,18 +265,95 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, 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.Kusto/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection with a given name. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto 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: Required. + :type parameters: ~azure.mgmt.kusto.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. + :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.kusto.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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 with a given name. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto 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: 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.kusto.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -235,19 +361,23 @@ async def begin_create_or_update( resource_group_name: str, cluster_name: str, private_endpoint_connection_name: str, - parameters: "_models.PrivateEndpointConnection", + parameters: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.PrivateEndpointConnection"]: + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Approve or reject a private endpoint connection with a given name. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto 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: - :type parameters: ~kusto_management_client.models.PrivateEndpointConnection + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.kusto.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 @@ -258,78 +388,90 @@ async def begin_create_or_update( 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[~kusto_management_client.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.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, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/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 + 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 + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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, - template_url=self._delete_initial.metadata['url'], + 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) + 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 + ) - 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]: @@ -339,24 +481,20 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/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 a private endpoint connection with a given name. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto 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. @@ -368,41 +506,46 @@ async def begin_delete( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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) - 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, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_private_link_resources_operations.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_private_link_resources_operations.py index 297124acdbde..079ca1b4c655 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_private_link_resources_operations.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/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,94 +6,106 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse 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._private_link_resources_operations import build_get_request, build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class 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: ~kusto_management_client.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.kusto.aio.KustoManagementClient`'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 def list( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.PrivateLinkResourceListResult"]: + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateLinkResource"]: """Returns the list of private link resources. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto 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 PrivateLinkResourceListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~kusto_management_client.models.PrivateLinkResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kusto.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_name=cluster_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -106,7 +119,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,63 +130,70 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateLinkResources'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/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 a private link resource. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto 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) - :rtype: ~kusto_management_client.models.PrivateLinkResource - :raises: ~azure.core.exceptions.HttpResponseError + :return: PrivateLinkResource or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.PrivateLinkResource + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, private_link_resource_name=private_link_resource_name, - template_url=self.get.metadata['url'], + 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) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('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.Kusto/clusters/{clusterName}/privateLinkResources/{privateLinkResourceName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateLinkResources/{privateLinkResourceName}"} # type: ignore diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_scripts_operations.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_scripts_operations.py index 799466e1662a..7e89bbce8ba1 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_scripts_operations.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_scripts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,100 +6,118 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse 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 from ..._vendor import _convert_request -from ...operations._scripts_operations import build_check_name_availability_request, build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_database_request, build_update_request_initial -T = TypeVar('T') +from ...operations._scripts_operations import ( + build_check_name_availability_request, + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_database_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ScriptsOperations: - """ScriptsOperations 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 ScriptsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~kusto_management_client.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.kusto.aio.KustoManagementClient`'s + :attr:`scripts` 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_database( - self, - resource_group_name: str, - cluster_name: str, - database_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ScriptListResult"]: + self, resource_group_name: str, cluster_name: str, database_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Script"]: """Returns the list of database scripts for given database. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScriptListResult or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~kusto_management_client.models.ScriptListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Script or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kusto.models.Script] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScriptListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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.ScriptListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_database_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, - template_url=self.list_by_database.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_database_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_name=cluster_name, - database_name=database_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -112,7 +131,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -121,70 +142,76 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts'} # type: ignore + list_by_database.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - cluster_name: str, - database_name: str, - script_name: str, - **kwargs: Any - ) -> "_models.Script": + self, resource_group_name: str, cluster_name: str, database_name: str, script_name: str, **kwargs: Any + ) -> _models.Script: """Gets a Kusto cluster database script. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str - :param script_name: The name of the Kusto database script. + :param script_name: The name of the Kusto database script. Required. :type script_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Script, or the result of cls(response) - :rtype: ~kusto_management_client.models.Script - :raises: ~azure.core.exceptions.HttpResponseError + :return: Script or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.Script + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Script"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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.Script] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, script_name=script_name, - template_url=self.get.metadata['url'], + 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) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Script', pipeline_response) + deserialized = self._deserialize("Script", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}"} # type: ignore async def _create_or_update_initial( self, @@ -192,33 +219,53 @@ async def _create_or_update_initial( cluster_name: str, database_name: str, script_name: str, - parameters: "_models.Script", + parameters: Union[_models.Script, IO], **kwargs: Any - ) -> "_models.Script": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Script"] + ) -> _models.Script: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Script') + 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.Script] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Script") + + request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, script_name=script_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + 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) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -226,21 +273,104 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Script', pipeline_response) + deserialized = self._deserialize("Script", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Script', pipeline_response) + deserialized = self._deserialize("Script", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('Script', pipeline_response) + deserialized = self._deserialize("Script", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + script_name: str, + parameters: _models.Script, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Script]: + """Creates a Kusto database script. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param script_name: The name of the Kusto database script. Required. + :type script_name: str + :param parameters: The Kusto Script parameters contains the KQL to run. Required. + :type parameters: ~azure.mgmt.kusto.models.Script + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Script or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.Script] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + script_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Script]: + """Creates a Kusto database script. + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param script_name: The name of the Kusto database script. Required. + :type script_name: str + :param parameters: The Kusto Script parameters contains the KQL to run. 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 Script or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.Script] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -249,21 +379,26 @@ async def begin_create_or_update( cluster_name: str, database_name: str, script_name: str, - parameters: "_models.Script", + parameters: Union[_models.Script, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Script"]: + ) -> AsyncLROPoller[_models.Script]: """Creates a Kusto database script. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str - :param script_name: The name of the Kusto database script. + :param script_name: The name of the Kusto database script. Required. :type script_name: str - :param parameters: The Kusto Script parameters contains the KQL to run. - :type parameters: ~kusto_management_client.models.Script + :param parameters: The Kusto Script parameters contains the KQL to run. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.kusto.models.Script 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 @@ -274,52 +409,56 @@ async def begin_create_or_update( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Script or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~kusto_management_client.models.Script] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.Script] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Script"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Script] + 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, database_name=database_name, script_name=script_name, parameters=parameters, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('Script', pipeline_response) + deserialized = self._deserialize("Script", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}"} # type: ignore async def _update_initial( self, @@ -327,33 +466,53 @@ async def _update_initial( cluster_name: str, database_name: str, script_name: str, - parameters: "_models.Script", + parameters: Union[_models.Script, IO], **kwargs: Any - ) -> "_models.Script": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Script"] + ) -> _models.Script: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Script') + 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.Script] - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Script") + + request = build_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, script_name=script_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + 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) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -362,20 +521,105 @@ async def _update_initial( response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('Script', pipeline_response) + deserialized = self._deserialize("Script", pipeline_response) if response.status_code == 202: - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - - deserialized = self._deserialize('Script', pipeline_response) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Script", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + script_name: str, + parameters: _models.Script, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Script]: + """Updates a database script. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param script_name: The name of the Kusto database script. Required. + :type script_name: str + :param parameters: The Kusto Script parameters contains to the KQL to run. Required. + :type parameters: ~azure.mgmt.kusto.models.Script + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Script or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.Script] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + script_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Script]: + """Updates a database script. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param script_name: The name of the Kusto database script. Required. + :type script_name: str + :param parameters: The Kusto Script parameters contains to the KQL to run. 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 Script or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.Script] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -384,21 +628,26 @@ async def begin_update( cluster_name: str, database_name: str, script_name: str, - parameters: "_models.Script", + parameters: Union[_models.Script, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Script"]: + ) -> AsyncLROPoller[_models.Script]: """Updates a database script. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str - :param script_name: The name of the Kusto database script. + :param script_name: The name of the Kusto database script. Required. :type script_name: str - :param parameters: The Kusto Script parameters contains to the KQL to run. - :type parameters: ~kusto_management_client.models.Script + :param parameters: The Kusto Script parameters contains to the KQL to run. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.kusto.models.Script 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 @@ -409,80 +658,92 @@ async def begin_update( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Script or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~kusto_management_client.models.Script] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.Script] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Script"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Script] + 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, database_name=database_name, script_name=script_name, parameters=parameters, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('Script', pipeline_response) + deserialized = self._deserialize("Script", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}"} # type: ignore - async def _delete_initial( - self, - resource_group_name: str, - cluster_name: str, - database_name: str, - script_name: str, - **kwargs: Any + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, cluster_name: str, database_name: str, script_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', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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, database_name=database_name, script_name=script_name, - template_url=self._delete_initial.metadata['url'], + 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) + 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 + ) - 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]: @@ -492,27 +753,22 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}"} # type: ignore @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - cluster_name: str, - database_name: str, - script_name: str, - **kwargs: Any + self, resource_group_name: str, cluster_name: str, database_name: str, script_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a Kusto principalAssignment. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str - :param script_name: The name of the Kusto database script. + :param script_name: The name of the Kusto database script. Required. :type script_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. @@ -524,45 +780,112 @@ async def begin_delete( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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, database_name=database_name, script_name=script_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) - 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, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}"} # type: ignore - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}'} # type: ignore + @overload + async def check_name_availability( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + script_name: _models.ScriptCheckNameRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the script name is valid and is not already in use. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param script_name: The name of the script. Required. + :type script_name: ~azure.mgmt.kusto.models.ScriptCheckNameRequest + :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: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + script_name: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the script name is valid and is not already in use. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param script_name: The name of the script. Required. + :type script_name: 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: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def check_name_availability( @@ -570,59 +893,82 @@ async def check_name_availability( resource_group_name: str, cluster_name: str, database_name: str, - script_name: "_models.ScriptCheckNameRequest", + script_name: Union[_models.ScriptCheckNameRequest, IO], **kwargs: Any - ) -> "_models.CheckNameResult": + ) -> _models.CheckNameResult: """Checks that the script name is valid and is not already in use. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str - :param script_name: The name of the script. - :type script_name: ~kusto_management_client.models.ScriptCheckNameRequest + :param script_name: The name of the script. Is either a model type or a IO type. Required. + :type script_name: ~azure.mgmt.kusto.models.ScriptCheckNameRequest 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: CheckNameResult, or the result of cls(response) - :rtype: ~kusto_management_client.models.CheckNameResult - :raises: ~azure.core.exceptions.HttpResponseError + :return: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameResult] - _json = self._serialize.body(script_name, 'ScriptCheckNameRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(script_name, (IO, bytes)): + _content = script_name + else: + _json = self._serialize.body(script_name, "ScriptCheckNameRequest") request = build_check_name_availability_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + 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) + 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 + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameResult', pipeline_response) + deserialized = self._deserialize("CheckNameResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scriptsCheckNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scriptsCheckNameAvailability"} # type: ignore diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/models/__init__.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/models/__init__.py index acaf3582ef9d..87e56251300e 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/models/__init__.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/models/__init__.py @@ -84,144 +84,150 @@ from ._models_py3 import TrustedExternalTenant from ._models_py3 import VirtualNetworkConfiguration - -from ._kusto_management_client_enums import ( - AzureScaleType, - AzureSkuName, - AzureSkuTier, - BlobStorageEventType, - ClusterNetworkAccessFlag, - ClusterPrincipalRole, - Compression, - CreatedByType, - DataConnectionKind, - DatabasePrincipalRole, - DatabasePrincipalType, - DatabaseRouting, - DefaultPrincipalsModificationKind, - EngineType, - EventGridDataFormat, - EventHubDataFormat, - IdentityType, - IotHubDataFormat, - Kind, - LanguageExtensionName, - PrincipalType, - PrincipalsModificationKind, - ProvisioningState, - PublicIPType, - PublicNetworkAccess, - Reason, - State, - Status, - Type, -) +from ._kusto_management_client_enums import AzureScaleType +from ._kusto_management_client_enums import AzureSkuName +from ._kusto_management_client_enums import AzureSkuTier +from ._kusto_management_client_enums import BlobStorageEventType +from ._kusto_management_client_enums import CallerRole +from ._kusto_management_client_enums import ClusterNetworkAccessFlag +from ._kusto_management_client_enums import ClusterPrincipalRole +from ._kusto_management_client_enums import Compression +from ._kusto_management_client_enums import CreatedByType +from ._kusto_management_client_enums import DataConnectionKind +from ._kusto_management_client_enums import DatabasePrincipalRole +from ._kusto_management_client_enums import DatabasePrincipalType +from ._kusto_management_client_enums import DatabaseRouting +from ._kusto_management_client_enums import DatabaseShareOrigin +from ._kusto_management_client_enums import DefaultPrincipalsModificationKind +from ._kusto_management_client_enums import EngineType +from ._kusto_management_client_enums import EventGridDataFormat +from ._kusto_management_client_enums import EventHubDataFormat +from ._kusto_management_client_enums import IdentityType +from ._kusto_management_client_enums import IotHubDataFormat +from ._kusto_management_client_enums import Kind +from ._kusto_management_client_enums import LanguageExtensionName +from ._kusto_management_client_enums import PrincipalType +from ._kusto_management_client_enums import PrincipalsModificationKind +from ._kusto_management_client_enums import ProvisioningState +from ._kusto_management_client_enums import PublicIPType +from ._kusto_management_client_enums import PublicNetworkAccess +from ._kusto_management_client_enums import Reason +from ._kusto_management_client_enums import State +from ._kusto_management_client_enums import Status +from ._kusto_management_client_enums import Type +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__ = [ - 'AcceptedAudiences', - 'AttachedDatabaseConfiguration', - 'AttachedDatabaseConfigurationListResult', - 'AttachedDatabaseConfigurationsCheckNameRequest', - 'AzureCapacity', - 'AzureResourceSku', - 'AzureSku', - 'CheckNameRequest', - 'CheckNameResult', - 'CloudErrorBody', - 'Cluster', - 'ClusterCheckNameRequest', - 'ClusterListResult', - 'ClusterPrincipalAssignment', - 'ClusterPrincipalAssignmentCheckNameRequest', - 'ClusterPrincipalAssignmentListResult', - 'ClusterUpdate', - 'ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties', - 'DataConnection', - 'DataConnectionCheckNameRequest', - 'DataConnectionListResult', - 'DataConnectionValidation', - 'DataConnectionValidationListResult', - 'DataConnectionValidationResult', - 'Database', - 'DatabaseListResult', - 'DatabasePrincipal', - 'DatabasePrincipalAssignment', - 'DatabasePrincipalAssignmentCheckNameRequest', - 'DatabasePrincipalAssignmentListResult', - 'DatabasePrincipalListRequest', - 'DatabasePrincipalListResult', - 'DatabaseStatistics', - 'DiagnoseVirtualNetworkResult', - 'EndpointDependency', - 'EndpointDetail', - 'EventGridDataConnection', - 'EventHubDataConnection', - 'FollowerDatabaseDefinition', - 'FollowerDatabaseListResult', - 'Identity', - 'IotHubDataConnection', - 'KeyVaultProperties', - 'LanguageExtension', - 'LanguageExtensionsList', - 'ListResourceSkusResult', - 'ManagedPrivateEndpoint', - 'ManagedPrivateEndpointListResult', - 'ManagedPrivateEndpointsCheckNameRequest', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'OperationResult', - 'OptimizedAutoscale', - 'OutboundNetworkDependenciesEndpoint', - 'OutboundNetworkDependenciesEndpointListResult', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionListResult', - 'PrivateEndpointProperty', - 'PrivateLinkResource', - 'PrivateLinkResourceListResult', - 'PrivateLinkServiceConnectionStateProperty', - 'ProxyResource', - 'ReadOnlyFollowingDatabase', - 'ReadWriteDatabase', - 'Resource', - 'Script', - 'ScriptCheckNameRequest', - 'ScriptListResult', - 'SkuDescription', - 'SkuDescriptionList', - 'SkuLocationInfoItem', - 'SystemData', - 'TableLevelSharingProperties', - 'TrackedResource', - 'TrustedExternalTenant', - 'VirtualNetworkConfiguration', - 'AzureScaleType', - 'AzureSkuName', - 'AzureSkuTier', - 'BlobStorageEventType', - 'ClusterNetworkAccessFlag', - 'ClusterPrincipalRole', - 'Compression', - 'CreatedByType', - 'DataConnectionKind', - 'DatabasePrincipalRole', - 'DatabasePrincipalType', - 'DatabaseRouting', - 'DefaultPrincipalsModificationKind', - 'EngineType', - 'EventGridDataFormat', - 'EventHubDataFormat', - 'IdentityType', - 'IotHubDataFormat', - 'Kind', - 'LanguageExtensionName', - 'PrincipalType', - 'PrincipalsModificationKind', - 'ProvisioningState', - 'PublicIPType', - 'PublicNetworkAccess', - 'Reason', - 'State', - 'Status', - 'Type', + "AcceptedAudiences", + "AttachedDatabaseConfiguration", + "AttachedDatabaseConfigurationListResult", + "AttachedDatabaseConfigurationsCheckNameRequest", + "AzureCapacity", + "AzureResourceSku", + "AzureSku", + "CheckNameRequest", + "CheckNameResult", + "CloudErrorBody", + "Cluster", + "ClusterCheckNameRequest", + "ClusterListResult", + "ClusterPrincipalAssignment", + "ClusterPrincipalAssignmentCheckNameRequest", + "ClusterPrincipalAssignmentListResult", + "ClusterUpdate", + "ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties", + "DataConnection", + "DataConnectionCheckNameRequest", + "DataConnectionListResult", + "DataConnectionValidation", + "DataConnectionValidationListResult", + "DataConnectionValidationResult", + "Database", + "DatabaseListResult", + "DatabasePrincipal", + "DatabasePrincipalAssignment", + "DatabasePrincipalAssignmentCheckNameRequest", + "DatabasePrincipalAssignmentListResult", + "DatabasePrincipalListRequest", + "DatabasePrincipalListResult", + "DatabaseStatistics", + "DiagnoseVirtualNetworkResult", + "EndpointDependency", + "EndpointDetail", + "EventGridDataConnection", + "EventHubDataConnection", + "FollowerDatabaseDefinition", + "FollowerDatabaseListResult", + "Identity", + "IotHubDataConnection", + "KeyVaultProperties", + "LanguageExtension", + "LanguageExtensionsList", + "ListResourceSkusResult", + "ManagedPrivateEndpoint", + "ManagedPrivateEndpointListResult", + "ManagedPrivateEndpointsCheckNameRequest", + "Operation", + "OperationDisplay", + "OperationListResult", + "OperationResult", + "OptimizedAutoscale", + "OutboundNetworkDependenciesEndpoint", + "OutboundNetworkDependenciesEndpointListResult", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateEndpointProperty", + "PrivateLinkResource", + "PrivateLinkResourceListResult", + "PrivateLinkServiceConnectionStateProperty", + "ProxyResource", + "ReadOnlyFollowingDatabase", + "ReadWriteDatabase", + "Resource", + "Script", + "ScriptCheckNameRequest", + "ScriptListResult", + "SkuDescription", + "SkuDescriptionList", + "SkuLocationInfoItem", + "SystemData", + "TableLevelSharingProperties", + "TrackedResource", + "TrustedExternalTenant", + "VirtualNetworkConfiguration", + "AzureScaleType", + "AzureSkuName", + "AzureSkuTier", + "BlobStorageEventType", + "CallerRole", + "ClusterNetworkAccessFlag", + "ClusterPrincipalRole", + "Compression", + "CreatedByType", + "DataConnectionKind", + "DatabasePrincipalRole", + "DatabasePrincipalType", + "DatabaseRouting", + "DatabaseShareOrigin", + "DefaultPrincipalsModificationKind", + "EngineType", + "EventGridDataFormat", + "EventHubDataFormat", + "IdentityType", + "IotHubDataFormat", + "Kind", + "LanguageExtensionName", + "PrincipalType", + "PrincipalsModificationKind", + "ProvisioningState", + "PublicIPType", + "PublicNetworkAccess", + "Reason", + "State", + "Status", + "Type", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/models/_kusto_management_client_enums.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/models/_kusto_management_client_enums.py index 6877c68df9e8..666eda928560 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/models/_kusto_management_client_enums.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/models/_kusto_management_client_enums.py @@ -7,21 +7,19 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AzureScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Scale type. - """ +class AzureScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Scale type.""" AUTOMATIC = "automatic" MANUAL = "manual" NONE = "none" -class AzureSkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """SKU name. - """ + +class AzureSkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """SKU name.""" DEV_NO_SLA_STANDARD_D11_V2 = "Dev(No SLA)_Standard_D11_v2" DEV_NO_SLA_STANDARD_E2_A_V4 = "Dev(No SLA)_Standard_E2a_v4" @@ -41,6 +39,10 @@ class AzureSkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STANDARD_L16_S = "Standard_L16s" STANDARD_L8_S_V2 = "Standard_L8s_v2" STANDARD_L16_S_V2 = "Standard_L16s_v2" + STANDARD_L8_S_V3 = "Standard_L8s_v3" + STANDARD_L16_S_V3 = "Standard_L16s_v3" + STANDARD_L8_AS_V3 = "Standard_L8as_v3" + STANDARD_L16_AS_V3 = "Standard_L16as_v3" STANDARD_E64_I_V3 = "Standard_E64i_v3" STANDARD_E80_IDS_V4 = "Standard_E80ids_v4" STANDARD_E2_A_V4 = "Standard_E2a_v4" @@ -59,6 +61,12 @@ class AzureSkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STANDARD_E4_ADS_V5 = "Standard_E4ads_v5" STANDARD_E8_ADS_V5 = "Standard_E8ads_v5" STANDARD_E16_ADS_V5 = "Standard_E16ads_v5" + STANDARD_EC8_AS_V5_1_TB_PS = "Standard_EC8as_v5+1TB_PS" + STANDARD_EC8_AS_V5_2_TB_PS = "Standard_EC8as_v5+2TB_PS" + STANDARD_EC16_AS_V5_3_TB_PS = "Standard_EC16as_v5+3TB_PS" + STANDARD_EC16_AS_V5_4_TB_PS = "Standard_EC16as_v5+4TB_PS" + STANDARD_EC8_ADS_V5 = "Standard_EC8ads_v5" + STANDARD_EC16_ADS_V5 = "Standard_EC16ads_v5" STANDARD_E8_S_V4_1_TB_PS = "Standard_E8s_v4+1TB_PS" STANDARD_E8_S_V4_2_TB_PS = "Standard_E8s_v4+2TB_PS" STANDARD_E16_S_V4_3_TB_PS = "Standard_E16s_v4+3TB_PS" @@ -67,55 +75,71 @@ class AzureSkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STANDARD_E8_S_V5_2_TB_PS = "Standard_E8s_v5+2TB_PS" STANDARD_E16_S_V5_3_TB_PS = "Standard_E16s_v5+3TB_PS" STANDARD_E16_S_V5_4_TB_PS = "Standard_E16s_v5+4TB_PS" + STANDARD_E2_D_V4 = "Standard_E2d_v4" + STANDARD_E4_D_V4 = "Standard_E4d_v4" + STANDARD_E8_D_V4 = "Standard_E8d_v4" + STANDARD_E16_D_V4 = "Standard_E16d_v4" + STANDARD_E2_D_V5 = "Standard_E2d_v5" + STANDARD_E4_D_V5 = "Standard_E4d_v5" + STANDARD_E8_D_V5 = "Standard_E8d_v5" + STANDARD_E16_D_V5 = "Standard_E16d_v5" -class AzureSkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """SKU tier. - """ + +class AzureSkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """SKU tier.""" BASIC = "Basic" STANDARD = "Standard" -class BlobStorageEventType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The name of blob storage event type to process. - """ + +class BlobStorageEventType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The name of blob storage event type to process.""" MICROSOFT_STORAGE_BLOB_CREATED = "Microsoft.Storage.BlobCreated" MICROSOFT_STORAGE_BLOB_RENAMED = "Microsoft.Storage.BlobRenamed" -class ClusterNetworkAccessFlag(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class CallerRole(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """CallerRole.""" + + ADMIN = "Admin" + NONE = "None" + + +class ClusterNetworkAccessFlag(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Whether or not to restrict outbound network access. Value is optional but if passed in, must - be 'Enabled' or 'Disabled' + be 'Enabled' or 'Disabled'. """ ENABLED = "Enabled" DISABLED = "Disabled" -class ClusterPrincipalRole(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Cluster principal role. - """ + +class ClusterPrincipalRole(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Cluster principal role.""" ALL_DATABASES_ADMIN = "AllDatabasesAdmin" ALL_DATABASES_VIEWER = "AllDatabasesViewer" -class Compression(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The compression type - """ + +class Compression(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The compression type.""" NONE = "None" G_ZIP = "GZip" -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 DatabasePrincipalRole(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Database principal role. - """ + +class DatabasePrincipalRole(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Database principal role.""" ADMIN = "Admin" INGESTOR = "Ingestor" @@ -124,48 +148,57 @@ class DatabasePrincipalRole(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): UNRESTRICTED_VIEWER = "UnrestrictedViewer" VIEWER = "Viewer" -class DatabasePrincipalType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Database principal type. - """ + +class DatabasePrincipalType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Database principal type.""" APP = "App" GROUP = "Group" USER = "User" -class DatabaseRouting(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class DatabaseRouting(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indication for database routing information from the data connection, by default only database - routing information is allowed + routing information is allowed. """ SINGLE = "Single" MULTI = "Multi" -class DataConnectionKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Kind of the endpoint for the data connection - """ + +class DatabaseShareOrigin(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The origin of the following setup.""" + + DIRECT = "Direct" + DATA_SHARE = "DataShare" + OTHER = "Other" + + +class DataConnectionKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Kind of the endpoint for the data connection.""" EVENT_HUB = "EventHub" EVENT_GRID = "EventGrid" IOT_HUB = "IotHub" -class DefaultPrincipalsModificationKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The default principals modification kind - """ + +class DefaultPrincipalsModificationKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The default principals modification kind.""" UNION = "Union" REPLACE = "Replace" NONE = "None" -class EngineType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The engine type - """ + +class EngineType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The engine type.""" V2 = "V2" V3 = "V3" -class EventGridDataFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The data format of the message. Optionally the data format can be added to each message. - """ + +class EventGridDataFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The data format of the message. Optionally the data format can be added to each message.""" MULTIJSON = "MULTIJSON" JSON = "JSON" @@ -184,9 +217,9 @@ class EventGridDataFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): APACHEAVRO = "APACHEAVRO" W3_CLOGFILE = "W3CLOGFILE" -class EventHubDataFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The data format of the message. Optionally the data format can be added to each message. - """ + +class EventHubDataFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The data format of the message. Optionally the data format can be added to each message.""" MULTIJSON = "MULTIJSON" JSON = "JSON" @@ -205,7 +238,8 @@ class EventHubDataFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): APACHEAVRO = "APACHEAVRO" W3_CLOGFILE = "W3CLOGFILE" -class IdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class IdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of managed identity used. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user-assigned identities. The type 'None' will remove all identities. @@ -216,9 +250,9 @@ class IdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" -class IotHubDataFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The data format of the message. Optionally the data format can be added to each message. - """ + +class IotHubDataFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The data format of the message. Optionally the data format can be added to each message.""" MULTIJSON = "MULTIJSON" JSON = "JSON" @@ -237,39 +271,39 @@ class IotHubDataFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): APACHEAVRO = "APACHEAVRO" W3_CLOGFILE = "W3CLOGFILE" -class Kind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Kind of the database - """ + +class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Kind of the database.""" READ_WRITE = "ReadWrite" READ_ONLY_FOLLOWING = "ReadOnlyFollowing" -class LanguageExtensionName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Language extension that can run within KQL query. - """ + +class LanguageExtensionName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Language extension that can run within KQL query.""" PYTHON = "PYTHON" R = "R" -class PrincipalsModificationKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The principals modification kind of the database - """ + +class PrincipalsModificationKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The principals modification kind of the database.""" UNION = "Union" REPLACE = "Replace" NONE = "None" -class PrincipalType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Principal type. - """ + +class PrincipalType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Principal type.""" APP = "App" GROUP = "Group" USER = "User" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The provisioned state of the resource. - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioned state of the resource.""" RUNNING = "Running" CREATING = "Creating" @@ -278,31 +312,32 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" MOVING = "Moving" -class PublicIPType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Indicates what public IP type to create - IPv4 (default), or DualStack (both IPv4 and IPv6) - """ + +class PublicIPType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates what public IP type to create - IPv4 (default), or DualStack (both IPv4 and IPv6).""" I_PV4 = "IPv4" DUAL_STACK = "DualStack" -class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Public network access to the cluster is enabled by default. When disabled, only private - endpoint connection to the cluster is allowed + endpoint connection to the cluster is allowed. """ ENABLED = "Enabled" DISABLED = "Disabled" -class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Message providing the reason why the given name is invalid. - """ + +class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Message providing the reason why the given name is invalid.""" INVALID = "Invalid" ALREADY_EXISTS = "AlreadyExists" -class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The state of the resource. - """ + +class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The state of the resource.""" CREATING = "Creating" UNAVAILABLE = "Unavailable" @@ -314,18 +349,20 @@ class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STARTING = "Starting" UPDATING = "Updating" -class Status(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The status of operation. - """ + +class Status(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of operation.""" SUCCEEDED = "Succeeded" CANCELED = "Canceled" FAILED = "Failed" RUNNING = "Running" -class Type(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of resource, for instance Microsoft.Kusto/clusters/databases. - """ + +class Type(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of resource, for instance Microsoft.Kusto/clusters/databases.""" MICROSOFT_KUSTO_CLUSTERS_DATABASES = "Microsoft.Kusto/clusters/databases" - MICROSOFT_KUSTO_CLUSTERS_ATTACHED_DATABASE_CONFIGURATIONS = "Microsoft.Kusto/clusters/attachedDatabaseConfigurations" + MICROSOFT_KUSTO_CLUSTERS_ATTACHED_DATABASE_CONFIGURATIONS = ( + "Microsoft.Kusto/clusters/attachedDatabaseConfigurations" + ) diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/models/_models_py3.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/models/_models_py3.py index fdaf0a6510db..5ed49d699dc0 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/models/_models_py3.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/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,14 +8,22 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from .. import _serialization -from ._kusto_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 AcceptedAudiences(msrest.serialization.Model): +class AcceptedAudiences(_serialization.Model): """Represents an accepted audience trusted by the cluster. :ivar value: GUID or valid URL representing an accepted audience. @@ -22,24 +31,19 @@ class AcceptedAudiences(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - *, - value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[str] = None, **kwargs): """ :keyword value: GUID or valid URL representing an accepted audience. :paramtype value: str """ - super(AcceptedAudiences, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """Common fields that are returned in the response for all Azure Resource Manager resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -55,24 +59,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -94,27 +94,23 @@ class ProxyResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) -class AttachedDatabaseConfiguration(ProxyResource): +class AttachedDatabaseConfiguration(ProxyResource): # pylint: disable=too-many-instance-attributes """Class representing an attached database configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -129,9 +125,9 @@ class AttachedDatabaseConfiguration(ProxyResource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar provisioning_state: The provisioned state of the resource. Possible values include: - "Running", "Creating", "Deleting", "Succeeded", "Failed", "Moving". - :vartype provisioning_state: str or ~kusto_management_client.models.ProvisioningState + :ivar provisioning_state: The provisioned state of the resource. Known values are: "Running", + "Creating", "Deleting", "Succeeded", "Failed", and "Moving". + :vartype provisioning_state: str or ~azure.mgmt.kusto.models.ProvisioningState :ivar database_name: The name of the database which you would like to attach, use * if you want to follow all current and future databases. :vartype database_name: str @@ -141,34 +137,45 @@ class AttachedDatabaseConfiguration(ProxyResource): :ivar attached_database_names: The list of databases from the clusterResourceId which are currently attached to the cluster. :vartype attached_database_names: list[str] - :ivar default_principals_modification_kind: The default principals modification kind. Possible - values include: "Union", "Replace", "None". + :ivar default_principals_modification_kind: The default principals modification kind. Known + values are: "Union", "Replace", and "None". :vartype default_principals_modification_kind: str or - ~kusto_management_client.models.DefaultPrincipalsModificationKind + ~azure.mgmt.kusto.models.DefaultPrincipalsModificationKind :ivar table_level_sharing_properties: Table level sharing specifications. - :vartype table_level_sharing_properties: - ~kusto_management_client.models.TableLevelSharingProperties + :vartype table_level_sharing_properties: ~azure.mgmt.kusto.models.TableLevelSharingProperties + :ivar database_name_override: Overrides the original database name. Relevant only when + attaching to a specific database. + :vartype database_name_override: str + :ivar database_name_prefix: Adds a prefix to the attached databases name. When following an + entire cluster, that prefix would be added to all of the databases original names from leader + cluster. + :vartype database_name_prefix: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'attached_database_names': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "attached_database_names": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'database_name': {'key': 'properties.databaseName', 'type': 'str'}, - 'cluster_resource_id': {'key': 'properties.clusterResourceId', 'type': 'str'}, - 'attached_database_names': {'key': 'properties.attachedDatabaseNames', 'type': '[str]'}, - 'default_principals_modification_kind': {'key': 'properties.defaultPrincipalsModificationKind', 'type': 'str'}, - 'table_level_sharing_properties': {'key': 'properties.tableLevelSharingProperties', 'type': 'TableLevelSharingProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "database_name": {"key": "properties.databaseName", "type": "str"}, + "cluster_resource_id": {"key": "properties.clusterResourceId", "type": "str"}, + "attached_database_names": {"key": "properties.attachedDatabaseNames", "type": "[str]"}, + "default_principals_modification_kind": {"key": "properties.defaultPrincipalsModificationKind", "type": "str"}, + "table_level_sharing_properties": { + "key": "properties.tableLevelSharingProperties", + "type": "TableLevelSharingProperties", + }, + "database_name_override": {"key": "properties.databaseNameOverride", "type": "str"}, + "database_name_prefix": {"key": "properties.databaseNamePrefix", "type": "str"}, } def __init__( @@ -177,8 +184,10 @@ def __init__( location: Optional[str] = None, database_name: Optional[str] = None, cluster_resource_id: Optional[str] = None, - default_principals_modification_kind: Optional[Union[str, "DefaultPrincipalsModificationKind"]] = None, - table_level_sharing_properties: Optional["TableLevelSharingProperties"] = None, + default_principals_modification_kind: Optional[Union[str, "_models.DefaultPrincipalsModificationKind"]] = None, + table_level_sharing_properties: Optional["_models.TableLevelSharingProperties"] = None, + database_name_override: Optional[str] = None, + database_name_prefix: Optional[str] = None, **kwargs ): """ @@ -190,15 +199,21 @@ def __init__( :keyword cluster_resource_id: The resource id of the cluster where the databases you would like to attach reside. :paramtype cluster_resource_id: str - :keyword default_principals_modification_kind: The default principals modification kind. - Possible values include: "Union", "Replace", "None". + :keyword default_principals_modification_kind: The default principals modification kind. Known + values are: "Union", "Replace", and "None". :paramtype default_principals_modification_kind: str or - ~kusto_management_client.models.DefaultPrincipalsModificationKind + ~azure.mgmt.kusto.models.DefaultPrincipalsModificationKind :keyword table_level_sharing_properties: Table level sharing specifications. - :paramtype table_level_sharing_properties: - ~kusto_management_client.models.TableLevelSharingProperties + :paramtype table_level_sharing_properties: ~azure.mgmt.kusto.models.TableLevelSharingProperties + :keyword database_name_override: Overrides the original database name. Relevant only when + attaching to a specific database. + :paramtype database_name_override: str + :keyword database_name_prefix: Adds a prefix to the attached databases name. When following an + entire cluster, that prefix would be added to all of the databases original names from leader + cluster. + :paramtype database_name_prefix: str """ - super(AttachedDatabaseConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.provisioning_state = None self.database_name = database_name @@ -206,283 +221,272 @@ def __init__( self.attached_database_names = None self.default_principals_modification_kind = default_principals_modification_kind self.table_level_sharing_properties = table_level_sharing_properties + self.database_name_override = database_name_override + self.database_name_prefix = database_name_prefix -class AttachedDatabaseConfigurationListResult(msrest.serialization.Model): +class AttachedDatabaseConfigurationListResult(_serialization.Model): """The list attached database configurations operation response. :ivar value: The list of attached database configurations. - :vartype value: list[~kusto_management_client.models.AttachedDatabaseConfiguration] + :vartype value: list[~azure.mgmt.kusto.models.AttachedDatabaseConfiguration] """ _attribute_map = { - 'value': {'key': 'value', 'type': '[AttachedDatabaseConfiguration]'}, + "value": {"key": "value", "type": "[AttachedDatabaseConfiguration]"}, } - def __init__( - self, - *, - value: Optional[List["AttachedDatabaseConfiguration"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.AttachedDatabaseConfiguration"]] = None, **kwargs): """ :keyword value: The list of attached database configurations. - :paramtype value: list[~kusto_management_client.models.AttachedDatabaseConfiguration] + :paramtype value: list[~azure.mgmt.kusto.models.AttachedDatabaseConfiguration] """ - super(AttachedDatabaseConfigurationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class AttachedDatabaseConfigurationsCheckNameRequest(msrest.serialization.Model): +class AttachedDatabaseConfigurationsCheckNameRequest(_serialization.Model): """The result returned from a AttachedDatabaseConfigurations check name availability request. 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 name: Required. Attached database resource name. + :ivar name: Attached database resource name. Required. :vartype name: str :ivar type: The type of resource, for instance - Microsoft.Kusto/clusters/attachedDatabaseConfigurations. Has constant value: + Microsoft.Kusto/clusters/attachedDatabaseConfigurations. Required. Default value is "Microsoft.Kusto/clusters/attachedDatabaseConfigurations". :vartype type: str """ _validation = { - 'name': {'required': True}, - 'type': {'required': True, 'constant': True}, + "name": {"required": True}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "Microsoft.Kusto/clusters/attachedDatabaseConfigurations" - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. Attached database resource name. + :keyword name: Attached database resource name. Required. :paramtype name: str """ - super(AttachedDatabaseConfigurationsCheckNameRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class AzureCapacity(msrest.serialization.Model): +class AzureCapacity(_serialization.Model): """Azure capacity definition. All required parameters must be populated in order to send to Azure. - :ivar scale_type: Required. Scale type. Possible values include: "automatic", "manual", "none". - :vartype scale_type: str or ~kusto_management_client.models.AzureScaleType - :ivar minimum: Required. Minimum allowed capacity. + :ivar scale_type: Scale type. Required. Known values are: "automatic", "manual", and "none". + :vartype scale_type: str or ~azure.mgmt.kusto.models.AzureScaleType + :ivar minimum: Minimum allowed capacity. Required. :vartype minimum: int - :ivar maximum: Required. Maximum allowed capacity. + :ivar maximum: Maximum allowed capacity. Required. :vartype maximum: int - :ivar default: Required. The default capacity that would be used. + :ivar default: The default capacity that would be used. Required. :vartype default: int """ _validation = { - 'scale_type': {'required': True}, - 'minimum': {'required': True}, - 'maximum': {'required': True}, - 'default': {'required': True}, + "scale_type": {"required": True}, + "minimum": {"required": True}, + "maximum": {"required": True}, + "default": {"required": True}, } _attribute_map = { - 'scale_type': {'key': 'scaleType', 'type': 'str'}, - 'minimum': {'key': 'minimum', 'type': 'int'}, - 'maximum': {'key': 'maximum', 'type': 'int'}, - 'default': {'key': 'default', 'type': 'int'}, + "scale_type": {"key": "scaleType", "type": "str"}, + "minimum": {"key": "minimum", "type": "int"}, + "maximum": {"key": "maximum", "type": "int"}, + "default": {"key": "default", "type": "int"}, } def __init__( - self, - *, - scale_type: Union[str, "AzureScaleType"], - minimum: int, - maximum: int, - default: int, - **kwargs + self, *, scale_type: Union[str, "_models.AzureScaleType"], minimum: int, maximum: int, default: int, **kwargs ): """ - :keyword scale_type: Required. Scale type. Possible values include: "automatic", "manual", - "none". - :paramtype scale_type: str or ~kusto_management_client.models.AzureScaleType - :keyword minimum: Required. Minimum allowed capacity. + :keyword scale_type: Scale type. Required. Known values are: "automatic", "manual", and "none". + :paramtype scale_type: str or ~azure.mgmt.kusto.models.AzureScaleType + :keyword minimum: Minimum allowed capacity. Required. :paramtype minimum: int - :keyword maximum: Required. Maximum allowed capacity. + :keyword maximum: Maximum allowed capacity. Required. :paramtype maximum: int - :keyword default: Required. The default capacity that would be used. + :keyword default: The default capacity that would be used. Required. :paramtype default: int """ - super(AzureCapacity, self).__init__(**kwargs) + super().__init__(**kwargs) self.scale_type = scale_type self.minimum = minimum self.maximum = maximum self.default = default -class AzureResourceSku(msrest.serialization.Model): +class AzureResourceSku(_serialization.Model): """Azure resource SKU definition. :ivar resource_type: Resource Namespace and Type. :vartype resource_type: str :ivar sku: The SKU details. - :vartype sku: ~kusto_management_client.models.AzureSku + :vartype sku: ~azure.mgmt.kusto.models.AzureSku :ivar capacity: The number of instances of the cluster. - :vartype capacity: ~kusto_management_client.models.AzureCapacity + :vartype capacity: ~azure.mgmt.kusto.models.AzureCapacity """ _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'AzureSku'}, - 'capacity': {'key': 'capacity', 'type': 'AzureCapacity'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "sku": {"key": "sku", "type": "AzureSku"}, + "capacity": {"key": "capacity", "type": "AzureCapacity"}, } def __init__( self, *, resource_type: Optional[str] = None, - sku: Optional["AzureSku"] = None, - capacity: Optional["AzureCapacity"] = None, + sku: Optional["_models.AzureSku"] = None, + capacity: Optional["_models.AzureCapacity"] = None, **kwargs ): """ :keyword resource_type: Resource Namespace and Type. :paramtype resource_type: str :keyword sku: The SKU details. - :paramtype sku: ~kusto_management_client.models.AzureSku + :paramtype sku: ~azure.mgmt.kusto.models.AzureSku :keyword capacity: The number of instances of the cluster. - :paramtype capacity: ~kusto_management_client.models.AzureCapacity + :paramtype capacity: ~azure.mgmt.kusto.models.AzureCapacity """ - super(AzureResourceSku, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.sku = sku self.capacity = capacity -class AzureSku(msrest.serialization.Model): +class AzureSku(_serialization.Model): """Azure SKU definition. All required parameters must be populated in order to send to Azure. - :ivar name: Required. SKU name. Possible values include: "Dev(No SLA)_Standard_D11_v2", "Dev(No + :ivar name: SKU name. Required. Known values are: "Dev(No SLA)_Standard_D11_v2", "Dev(No SLA)_Standard_E2a_v4", "Standard_D11_v2", "Standard_D12_v2", "Standard_D13_v2", "Standard_D14_v2", "Standard_D32d_v4", "Standard_D16d_v5", "Standard_D32d_v5", "Standard_DS13_v2+1TB_PS", "Standard_DS13_v2+2TB_PS", "Standard_DS14_v2+3TB_PS", "Standard_DS14_v2+4TB_PS", "Standard_L4s", "Standard_L8s", "Standard_L16s", "Standard_L8s_v2", - "Standard_L16s_v2", "Standard_E64i_v3", "Standard_E80ids_v4", "Standard_E2a_v4", + "Standard_L16s_v2", "Standard_L8s_v3", "Standard_L16s_v3", "Standard_L8as_v3", + "Standard_L16as_v3", "Standard_E64i_v3", "Standard_E80ids_v4", "Standard_E2a_v4", "Standard_E4a_v4", "Standard_E8a_v4", "Standard_E16a_v4", "Standard_E8as_v4+1TB_PS", "Standard_E8as_v4+2TB_PS", "Standard_E16as_v4+3TB_PS", "Standard_E16as_v4+4TB_PS", "Standard_E8as_v5+1TB_PS", "Standard_E8as_v5+2TB_PS", "Standard_E16as_v5+3TB_PS", "Standard_E16as_v5+4TB_PS", "Standard_E2ads_v5", "Standard_E4ads_v5", "Standard_E8ads_v5", - "Standard_E16ads_v5", "Standard_E8s_v4+1TB_PS", "Standard_E8s_v4+2TB_PS", + "Standard_E16ads_v5", "Standard_EC8as_v5+1TB_PS", "Standard_EC8as_v5+2TB_PS", + "Standard_EC16as_v5+3TB_PS", "Standard_EC16as_v5+4TB_PS", "Standard_EC8ads_v5", + "Standard_EC16ads_v5", "Standard_E8s_v4+1TB_PS", "Standard_E8s_v4+2TB_PS", "Standard_E16s_v4+3TB_PS", "Standard_E16s_v4+4TB_PS", "Standard_E8s_v5+1TB_PS", - "Standard_E8s_v5+2TB_PS", "Standard_E16s_v5+3TB_PS", "Standard_E16s_v5+4TB_PS". - :vartype name: str or ~kusto_management_client.models.AzureSkuName + "Standard_E8s_v5+2TB_PS", "Standard_E16s_v5+3TB_PS", "Standard_E16s_v5+4TB_PS", + "Standard_E2d_v4", "Standard_E4d_v4", "Standard_E8d_v4", "Standard_E16d_v4", "Standard_E2d_v5", + "Standard_E4d_v5", "Standard_E8d_v5", and "Standard_E16d_v5". + :vartype name: str or ~azure.mgmt.kusto.models.AzureSkuName :ivar capacity: The number of instances of the cluster. :vartype capacity: int - :ivar tier: Required. SKU tier. Possible values include: "Basic", "Standard". - :vartype tier: str or ~kusto_management_client.models.AzureSkuTier + :ivar tier: SKU tier. Required. Known values are: "Basic" and "Standard". + :vartype tier: str or ~azure.mgmt.kusto.models.AzureSkuTier """ _validation = { - 'name': {'required': True}, - 'tier': {'required': True}, + "name": {"required": True}, + "tier": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, - 'tier': {'key': 'tier', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, + "tier": {"key": "tier", "type": "str"}, } def __init__( self, *, - name: Union[str, "AzureSkuName"], - tier: Union[str, "AzureSkuTier"], + name: Union[str, "_models.AzureSkuName"], + tier: Union[str, "_models.AzureSkuTier"], capacity: Optional[int] = None, **kwargs ): """ - :keyword name: Required. SKU name. Possible values include: "Dev(No SLA)_Standard_D11_v2", - "Dev(No SLA)_Standard_E2a_v4", "Standard_D11_v2", "Standard_D12_v2", "Standard_D13_v2", + :keyword name: SKU name. Required. Known values are: "Dev(No SLA)_Standard_D11_v2", "Dev(No + SLA)_Standard_E2a_v4", "Standard_D11_v2", "Standard_D12_v2", "Standard_D13_v2", "Standard_D14_v2", "Standard_D32d_v4", "Standard_D16d_v5", "Standard_D32d_v5", "Standard_DS13_v2+1TB_PS", "Standard_DS13_v2+2TB_PS", "Standard_DS14_v2+3TB_PS", "Standard_DS14_v2+4TB_PS", "Standard_L4s", "Standard_L8s", "Standard_L16s", "Standard_L8s_v2", - "Standard_L16s_v2", "Standard_E64i_v3", "Standard_E80ids_v4", "Standard_E2a_v4", + "Standard_L16s_v2", "Standard_L8s_v3", "Standard_L16s_v3", "Standard_L8as_v3", + "Standard_L16as_v3", "Standard_E64i_v3", "Standard_E80ids_v4", "Standard_E2a_v4", "Standard_E4a_v4", "Standard_E8a_v4", "Standard_E16a_v4", "Standard_E8as_v4+1TB_PS", "Standard_E8as_v4+2TB_PS", "Standard_E16as_v4+3TB_PS", "Standard_E16as_v4+4TB_PS", "Standard_E8as_v5+1TB_PS", "Standard_E8as_v5+2TB_PS", "Standard_E16as_v5+3TB_PS", "Standard_E16as_v5+4TB_PS", "Standard_E2ads_v5", "Standard_E4ads_v5", "Standard_E8ads_v5", - "Standard_E16ads_v5", "Standard_E8s_v4+1TB_PS", "Standard_E8s_v4+2TB_PS", + "Standard_E16ads_v5", "Standard_EC8as_v5+1TB_PS", "Standard_EC8as_v5+2TB_PS", + "Standard_EC16as_v5+3TB_PS", "Standard_EC16as_v5+4TB_PS", "Standard_EC8ads_v5", + "Standard_EC16ads_v5", "Standard_E8s_v4+1TB_PS", "Standard_E8s_v4+2TB_PS", "Standard_E16s_v4+3TB_PS", "Standard_E16s_v4+4TB_PS", "Standard_E8s_v5+1TB_PS", - "Standard_E8s_v5+2TB_PS", "Standard_E16s_v5+3TB_PS", "Standard_E16s_v5+4TB_PS". - :paramtype name: str or ~kusto_management_client.models.AzureSkuName + "Standard_E8s_v5+2TB_PS", "Standard_E16s_v5+3TB_PS", "Standard_E16s_v5+4TB_PS", + "Standard_E2d_v4", "Standard_E4d_v4", "Standard_E8d_v4", "Standard_E16d_v4", "Standard_E2d_v5", + "Standard_E4d_v5", "Standard_E8d_v5", and "Standard_E16d_v5". + :paramtype name: str or ~azure.mgmt.kusto.models.AzureSkuName :keyword capacity: The number of instances of the cluster. :paramtype capacity: int - :keyword tier: Required. SKU tier. Possible values include: "Basic", "Standard". - :paramtype tier: str or ~kusto_management_client.models.AzureSkuTier + :keyword tier: SKU tier. Required. Known values are: "Basic" and "Standard". + :paramtype tier: str or ~azure.mgmt.kusto.models.AzureSkuTier """ - super(AzureSku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.capacity = capacity self.tier = tier -class CheckNameRequest(msrest.serialization.Model): +class CheckNameRequest(_serialization.Model): """The result returned from a database check name availability request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Resource name. + :ivar name: Resource name. Required. :vartype name: str - :ivar type: Required. The type of resource, for instance Microsoft.Kusto/clusters/databases. - Possible values include: "Microsoft.Kusto/clusters/databases", + :ivar type: The type of resource, for instance Microsoft.Kusto/clusters/databases. Required. + Known values are: "Microsoft.Kusto/clusters/databases" and "Microsoft.Kusto/clusters/attachedDatabaseConfigurations". - :vartype type: str or ~kusto_management_client.models.Type + :vartype type: str or ~azure.mgmt.kusto.models.Type """ _validation = { - 'name': {'required': True}, - 'type': {'required': True}, + "name": {"required": True}, + "type": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - name: str, - type: Union[str, "Type"], - **kwargs - ): + def __init__(self, *, name: str, type: Union[str, "_models.Type"], **kwargs): """ - :keyword name: Required. Resource name. + :keyword name: Resource name. Required. :paramtype name: str - :keyword type: Required. The type of resource, for instance Microsoft.Kusto/clusters/databases. - Possible values include: "Microsoft.Kusto/clusters/databases", + :keyword type: The type of resource, for instance Microsoft.Kusto/clusters/databases. Required. + Known values are: "Microsoft.Kusto/clusters/databases" and "Microsoft.Kusto/clusters/attachedDatabaseConfigurations". - :paramtype type: str or ~kusto_management_client.models.Type + :paramtype type: str or ~azure.mgmt.kusto.models.Type """ - super(CheckNameRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.type = type -class CheckNameResult(msrest.serialization.Model): +class CheckNameResult(_serialization.Model): """The result returned from a check name availability request. :ivar name_available: Specifies a Boolean value that indicates if the name is available. @@ -492,16 +496,16 @@ class CheckNameResult(msrest.serialization.Model): :ivar message: Message indicating an unavailable name due to a conflict, or a description of the naming rules that are violated. :vartype message: str - :ivar reason: Message providing the reason why the given name is invalid. Possible values - include: "Invalid", "AlreadyExists". - :vartype reason: str or ~kusto_management_client.models.Reason + :ivar reason: Message providing the reason why the given name is invalid. Known values are: + "Invalid" and "AlreadyExists". + :vartype reason: str or ~azure.mgmt.kusto.models.Reason """ _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "reason": {"key": "reason", "type": "str"}, } def __init__( @@ -510,7 +514,7 @@ def __init__( name_available: Optional[bool] = None, name: Optional[str] = None, message: Optional[str] = None, - reason: Optional[Union[str, "Reason"]] = None, + reason: Optional[Union[str, "_models.Reason"]] = None, **kwargs ): """ @@ -521,18 +525,18 @@ def __init__( :keyword message: Message indicating an unavailable name due to a conflict, or a description of the naming rules that are violated. :paramtype message: str - :keyword reason: Message providing the reason why the given name is invalid. Possible values - include: "Invalid", "AlreadyExists". - :paramtype reason: str or ~kusto_management_client.models.Reason + :keyword reason: Message providing the reason why the given name is invalid. Known values are: + "Invalid" and "AlreadyExists". + :paramtype reason: str or ~azure.mgmt.kusto.models.Reason """ - super(CheckNameResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = name_available self.name = name self.message = message self.reason = reason -class CloudErrorBody(msrest.serialization.Model): +class CloudErrorBody(_serialization.Model): """An error response from Kusto. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed @@ -545,14 +549,14 @@ class CloudErrorBody(msrest.serialization.Model): error. :vartype target: str :ivar details: A list of additional details about the error. - :vartype details: list[~kusto_management_client.models.CloudErrorBody] + :vartype details: list[~azure.mgmt.kusto.models.CloudErrorBody] """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, } def __init__( @@ -561,7 +565,7 @@ def __init__( code: Optional[str] = None, message: Optional[str] = None, target: Optional[str] = None, - details: Optional[List["CloudErrorBody"]] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, **kwargs ): """ @@ -575,9 +579,9 @@ def __init__( error. :paramtype target: str :keyword details: A list of additional details about the error. - :paramtype details: list[~kusto_management_client.models.CloudErrorBody] + :paramtype details: list[~azure.mgmt.kusto.models.CloudErrorBody] """ - super(CloudErrorBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target @@ -599,46 +603,40 @@ class TrackedResource(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :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'}, + "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 - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.location = location -class Cluster(TrackedResource): +class Cluster(TrackedResource): # pylint: disable=too-many-instance-attributes """Class representing a Kusto cluster. Variables are only populated by the server, and will be ignored when sending a request. @@ -653,26 +651,26 @@ class Cluster(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str - :ivar sku: Required. The SKU of the cluster. - :vartype sku: ~kusto_management_client.models.AzureSku + :ivar sku: The SKU of the cluster. Required. + :vartype sku: ~azure.mgmt.kusto.models.AzureSku :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~kusto_management_client.models.SystemData + :vartype system_data: ~azure.mgmt.kusto.models.SystemData :ivar zones: The availability zones of the cluster. :vartype zones: list[str] :ivar identity: The identity of the cluster, if configured. - :vartype identity: ~kusto_management_client.models.Identity + :vartype identity: ~azure.mgmt.kusto.models.Identity :ivar etag: A unique read-only string that changes whenever the resource is updated. :vartype etag: str - :ivar state: The state of the resource. Possible values include: "Creating", "Unavailable", - "Running", "Deleting", "Deleted", "Stopping", "Stopped", "Starting", "Updating". - :vartype state: str or ~kusto_management_client.models.State - :ivar provisioning_state: The provisioned state of the resource. Possible values include: - "Running", "Creating", "Deleting", "Succeeded", "Failed", "Moving". - :vartype provisioning_state: str or ~kusto_management_client.models.ProvisioningState + :ivar state: The state of the resource. Known values are: "Creating", "Unavailable", "Running", + "Deleting", "Deleted", "Stopping", "Stopped", "Starting", and "Updating". + :vartype state: str or ~azure.mgmt.kusto.models.State + :ivar provisioning_state: The provisioned state of the resource. Known values are: "Running", + "Creating", "Deleting", "Succeeded", "Failed", and "Moving". + :vartype provisioning_state: str or ~azure.mgmt.kusto.models.ProvisioningState :ivar uri: The cluster URI. :vartype uri: str :ivar data_ingestion_uri: The cluster data ingestion URI. @@ -680,9 +678,9 @@ class Cluster(TrackedResource): :ivar state_reason: The reason for the cluster's current state. :vartype state_reason: str :ivar trusted_external_tenants: The cluster's external tenants. - :vartype trusted_external_tenants: list[~kusto_management_client.models.TrustedExternalTenant] + :vartype trusted_external_tenants: list[~azure.mgmt.kusto.models.TrustedExternalTenant] :ivar optimized_autoscale: Optimized auto scale definition. - :vartype optimized_autoscale: ~kusto_management_client.models.OptimizedAutoscale + :vartype optimized_autoscale: ~azure.mgmt.kusto.models.OptimizedAutoscale :ivar enable_disk_encryption: A boolean value that indicates if the cluster's disks are encrypted. :vartype enable_disk_encryption: bool @@ -690,145 +688,151 @@ class Cluster(TrackedResource): enabled. :vartype enable_streaming_ingest: bool :ivar virtual_network_configuration: Virtual network definition. - :vartype virtual_network_configuration: - ~kusto_management_client.models.VirtualNetworkConfiguration + :vartype virtual_network_configuration: ~azure.mgmt.kusto.models.VirtualNetworkConfiguration :ivar key_vault_properties: KeyVault properties for the cluster encryption. - :vartype key_vault_properties: ~kusto_management_client.models.KeyVaultProperties + :vartype key_vault_properties: ~azure.mgmt.kusto.models.KeyVaultProperties :ivar enable_purge: A boolean value that indicates if the purge operations are enabled. :vartype enable_purge: bool :ivar language_extensions: List of the cluster's language extensions. - :vartype language_extensions: ~kusto_management_client.models.LanguageExtensionsList + :vartype language_extensions: ~azure.mgmt.kusto.models.LanguageExtensionsList :ivar enable_double_encryption: A boolean value that indicates if double encryption is enabled. :vartype enable_double_encryption: bool :ivar public_network_access: Public network access to the cluster is enabled by default. When - disabled, only private endpoint connection to the cluster is allowed. Possible values include: - "Enabled", "Disabled". Default value: "Enabled". - :vartype public_network_access: str or ~kusto_management_client.models.PublicNetworkAccess + disabled, only private endpoint connection to the cluster is allowed. Known values are: + "Enabled" and "Disabled". + :vartype public_network_access: str or ~azure.mgmt.kusto.models.PublicNetworkAccess :ivar allowed_ip_range_list: The list of ips in the format of CIDR allowed to connect to the cluster. :vartype allowed_ip_range_list: list[str] - :ivar engine_type: The engine type. Possible values include: "V2", "V3". Default value: "V3". - :vartype engine_type: str or ~kusto_management_client.models.EngineType + :ivar engine_type: The engine type. Known values are: "V2" and "V3". + :vartype engine_type: str or ~azure.mgmt.kusto.models.EngineType :ivar accepted_audiences: The cluster's accepted audiences. - :vartype accepted_audiences: list[~kusto_management_client.models.AcceptedAudiences] + :vartype accepted_audiences: list[~azure.mgmt.kusto.models.AcceptedAudiences] :ivar enable_auto_stop: A boolean value that indicates if the cluster could be automatically stopped (due to lack of data or no activity for many days). :vartype enable_auto_stop: bool :ivar restrict_outbound_network_access: Whether or not to restrict outbound network access. - Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Possible values include: - "Enabled", "Disabled". Default value: "Disabled". + Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: + "Enabled" and "Disabled". :vartype restrict_outbound_network_access: str or - ~kusto_management_client.models.ClusterNetworkAccessFlag + ~azure.mgmt.kusto.models.ClusterNetworkAccessFlag :ivar allowed_fqdn_list: List of allowed FQDNs(Fully Qualified Domain Name) for egress from Cluster. :vartype allowed_fqdn_list: list[str] :ivar public_ip_type: Indicates what public IP type to create - IPv4 (default), or DualStack - (both IPv4 and IPv6). Possible values include: "IPv4", "DualStack". Default value: "IPv4". - :vartype public_ip_type: str or ~kusto_management_client.models.PublicIPType + (both IPv4 and IPv6). Known values are: "IPv4" and "DualStack". + :vartype public_ip_type: str or ~azure.mgmt.kusto.models.PublicIPType :ivar virtual_cluster_graduation_properties: Virtual Cluster graduation properties. :vartype virtual_cluster_graduation_properties: str :ivar private_endpoint_connections: A list of private endpoint connections. - :vartype private_endpoint_connections: - list[~kusto_management_client.models.PrivateEndpointConnection] + :vartype private_endpoint_connections: list[~azure.mgmt.kusto.models.PrivateEndpointConnection] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'sku': {'required': True}, - 'system_data': {'readonly': True}, - 'etag': {'readonly': True}, - 'state': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'uri': {'readonly': True}, - 'data_ingestion_uri': {'readonly': True}, - 'state_reason': {'readonly': True}, - 'language_extensions': {'readonly': True}, - 'private_endpoint_connections': {'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'}, - 'sku': {'key': 'sku', 'type': 'AzureSku'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'zones': {'key': 'zones', 'type': '[str]'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'uri': {'key': 'properties.uri', 'type': 'str'}, - 'data_ingestion_uri': {'key': 'properties.dataIngestionUri', 'type': 'str'}, - 'state_reason': {'key': 'properties.stateReason', 'type': 'str'}, - 'trusted_external_tenants': {'key': 'properties.trustedExternalTenants', 'type': '[TrustedExternalTenant]'}, - 'optimized_autoscale': {'key': 'properties.optimizedAutoscale', 'type': 'OptimizedAutoscale'}, - 'enable_disk_encryption': {'key': 'properties.enableDiskEncryption', 'type': 'bool'}, - 'enable_streaming_ingest': {'key': 'properties.enableStreamingIngest', 'type': 'bool'}, - 'virtual_network_configuration': {'key': 'properties.virtualNetworkConfiguration', 'type': 'VirtualNetworkConfiguration'}, - 'key_vault_properties': {'key': 'properties.keyVaultProperties', 'type': 'KeyVaultProperties'}, - 'enable_purge': {'key': 'properties.enablePurge', 'type': 'bool'}, - 'language_extensions': {'key': 'properties.languageExtensions', 'type': 'LanguageExtensionsList'}, - 'enable_double_encryption': {'key': 'properties.enableDoubleEncryption', 'type': 'bool'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'allowed_ip_range_list': {'key': 'properties.allowedIpRangeList', 'type': '[str]'}, - 'engine_type': {'key': 'properties.engineType', 'type': 'str'}, - 'accepted_audiences': {'key': 'properties.acceptedAudiences', 'type': '[AcceptedAudiences]'}, - 'enable_auto_stop': {'key': 'properties.enableAutoStop', 'type': 'bool'}, - 'restrict_outbound_network_access': {'key': 'properties.restrictOutboundNetworkAccess', 'type': 'str'}, - 'allowed_fqdn_list': {'key': 'properties.allowedFqdnList', 'type': '[str]'}, - 'public_ip_type': {'key': 'properties.publicIPType', 'type': 'str'}, - 'virtual_cluster_graduation_properties': {'key': 'properties.virtualClusterGraduationProperties', 'type': 'str'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - } - - def __init__( + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "sku": {"required": True}, + "system_data": {"readonly": True}, + "etag": {"readonly": True}, + "state": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "uri": {"readonly": True}, + "data_ingestion_uri": {"readonly": True}, + "state_reason": {"readonly": True}, + "language_extensions": {"readonly": True}, + "private_endpoint_connections": {"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"}, + "sku": {"key": "sku", "type": "AzureSku"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "zones": {"key": "zones", "type": "[str]"}, + "identity": {"key": "identity", "type": "Identity"}, + "etag": {"key": "etag", "type": "str"}, + "state": {"key": "properties.state", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "uri": {"key": "properties.uri", "type": "str"}, + "data_ingestion_uri": {"key": "properties.dataIngestionUri", "type": "str"}, + "state_reason": {"key": "properties.stateReason", "type": "str"}, + "trusted_external_tenants": {"key": "properties.trustedExternalTenants", "type": "[TrustedExternalTenant]"}, + "optimized_autoscale": {"key": "properties.optimizedAutoscale", "type": "OptimizedAutoscale"}, + "enable_disk_encryption": {"key": "properties.enableDiskEncryption", "type": "bool"}, + "enable_streaming_ingest": {"key": "properties.enableStreamingIngest", "type": "bool"}, + "virtual_network_configuration": { + "key": "properties.virtualNetworkConfiguration", + "type": "VirtualNetworkConfiguration", + }, + "key_vault_properties": {"key": "properties.keyVaultProperties", "type": "KeyVaultProperties"}, + "enable_purge": {"key": "properties.enablePurge", "type": "bool"}, + "language_extensions": {"key": "properties.languageExtensions", "type": "LanguageExtensionsList"}, + "enable_double_encryption": {"key": "properties.enableDoubleEncryption", "type": "bool"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "allowed_ip_range_list": {"key": "properties.allowedIpRangeList", "type": "[str]"}, + "engine_type": {"key": "properties.engineType", "type": "str"}, + "accepted_audiences": {"key": "properties.acceptedAudiences", "type": "[AcceptedAudiences]"}, + "enable_auto_stop": {"key": "properties.enableAutoStop", "type": "bool"}, + "restrict_outbound_network_access": {"key": "properties.restrictOutboundNetworkAccess", "type": "str"}, + "allowed_fqdn_list": {"key": "properties.allowedFqdnList", "type": "[str]"}, + "public_ip_type": {"key": "properties.publicIPType", "type": "str"}, + "virtual_cluster_graduation_properties": { + "key": "properties.virtualClusterGraduationProperties", + "type": "str", + }, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + } + + def __init__( # pylint: disable=too-many-locals self, *, location: str, - sku: "AzureSku", + sku: "_models.AzureSku", tags: Optional[Dict[str, str]] = None, zones: Optional[List[str]] = None, - identity: Optional["Identity"] = None, - trusted_external_tenants: Optional[List["TrustedExternalTenant"]] = None, - optimized_autoscale: Optional["OptimizedAutoscale"] = None, - enable_disk_encryption: Optional[bool] = False, - enable_streaming_ingest: Optional[bool] = False, - virtual_network_configuration: Optional["VirtualNetworkConfiguration"] = None, - key_vault_properties: Optional["KeyVaultProperties"] = None, - enable_purge: Optional[bool] = False, - enable_double_encryption: Optional[bool] = False, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = "Enabled", + identity: Optional["_models.Identity"] = None, + trusted_external_tenants: Optional[List["_models.TrustedExternalTenant"]] = None, + optimized_autoscale: Optional["_models.OptimizedAutoscale"] = None, + enable_disk_encryption: bool = False, + enable_streaming_ingest: bool = False, + virtual_network_configuration: Optional["_models.VirtualNetworkConfiguration"] = None, + key_vault_properties: Optional["_models.KeyVaultProperties"] = None, + enable_purge: bool = False, + enable_double_encryption: bool = False, + public_network_access: Union[str, "_models.PublicNetworkAccess"] = "Enabled", allowed_ip_range_list: Optional[List[str]] = None, - engine_type: Optional[Union[str, "EngineType"]] = "V3", - accepted_audiences: Optional[List["AcceptedAudiences"]] = None, - enable_auto_stop: Optional[bool] = True, - restrict_outbound_network_access: Optional[Union[str, "ClusterNetworkAccessFlag"]] = "Disabled", + engine_type: Union[str, "_models.EngineType"] = "V3", + accepted_audiences: Optional[List["_models.AcceptedAudiences"]] = None, + enable_auto_stop: bool = True, + restrict_outbound_network_access: Union[str, "_models.ClusterNetworkAccessFlag"] = "Disabled", allowed_fqdn_list: Optional[List[str]] = None, - public_ip_type: Optional[Union[str, "PublicIPType"]] = "IPv4", + public_ip_type: Union[str, "_models.PublicIPType"] = "IPv4", virtual_cluster_graduation_properties: Optional[str] = None, **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str - :keyword sku: Required. The SKU of the cluster. - :paramtype sku: ~kusto_management_client.models.AzureSku + :keyword sku: The SKU of the cluster. Required. + :paramtype sku: ~azure.mgmt.kusto.models.AzureSku :keyword zones: The availability zones of the cluster. :paramtype zones: list[str] :keyword identity: The identity of the cluster, if configured. - :paramtype identity: ~kusto_management_client.models.Identity + :paramtype identity: ~azure.mgmt.kusto.models.Identity :keyword trusted_external_tenants: The cluster's external tenants. - :paramtype trusted_external_tenants: - list[~kusto_management_client.models.TrustedExternalTenant] + :paramtype trusted_external_tenants: list[~azure.mgmt.kusto.models.TrustedExternalTenant] :keyword optimized_autoscale: Optimized auto scale definition. - :paramtype optimized_autoscale: ~kusto_management_client.models.OptimizedAutoscale + :paramtype optimized_autoscale: ~azure.mgmt.kusto.models.OptimizedAutoscale :keyword enable_disk_encryption: A boolean value that indicates if the cluster's disks are encrypted. :paramtype enable_disk_encryption: bool @@ -836,45 +840,43 @@ def __init__( enabled. :paramtype enable_streaming_ingest: bool :keyword virtual_network_configuration: Virtual network definition. - :paramtype virtual_network_configuration: - ~kusto_management_client.models.VirtualNetworkConfiguration + :paramtype virtual_network_configuration: ~azure.mgmt.kusto.models.VirtualNetworkConfiguration :keyword key_vault_properties: KeyVault properties for the cluster encryption. - :paramtype key_vault_properties: ~kusto_management_client.models.KeyVaultProperties + :paramtype key_vault_properties: ~azure.mgmt.kusto.models.KeyVaultProperties :keyword enable_purge: A boolean value that indicates if the purge operations are enabled. :paramtype enable_purge: bool :keyword enable_double_encryption: A boolean value that indicates if double encryption is enabled. :paramtype enable_double_encryption: bool :keyword public_network_access: Public network access to the cluster is enabled by default. - When disabled, only private endpoint connection to the cluster is allowed. Possible values - include: "Enabled", "Disabled". Default value: "Enabled". - :paramtype public_network_access: str or ~kusto_management_client.models.PublicNetworkAccess + When disabled, only private endpoint connection to the cluster is allowed. Known values are: + "Enabled" and "Disabled". + :paramtype public_network_access: str or ~azure.mgmt.kusto.models.PublicNetworkAccess :keyword allowed_ip_range_list: The list of ips in the format of CIDR allowed to connect to the cluster. :paramtype allowed_ip_range_list: list[str] - :keyword engine_type: The engine type. Possible values include: "V2", "V3". Default value: - "V3". - :paramtype engine_type: str or ~kusto_management_client.models.EngineType + :keyword engine_type: The engine type. Known values are: "V2" and "V3". + :paramtype engine_type: str or ~azure.mgmt.kusto.models.EngineType :keyword accepted_audiences: The cluster's accepted audiences. - :paramtype accepted_audiences: list[~kusto_management_client.models.AcceptedAudiences] + :paramtype accepted_audiences: list[~azure.mgmt.kusto.models.AcceptedAudiences] :keyword enable_auto_stop: A boolean value that indicates if the cluster could be automatically stopped (due to lack of data or no activity for many days). :paramtype enable_auto_stop: bool :keyword restrict_outbound_network_access: Whether or not to restrict outbound network access. - Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Possible values include: - "Enabled", "Disabled". Default value: "Disabled". + Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: + "Enabled" and "Disabled". :paramtype restrict_outbound_network_access: str or - ~kusto_management_client.models.ClusterNetworkAccessFlag + ~azure.mgmt.kusto.models.ClusterNetworkAccessFlag :keyword allowed_fqdn_list: List of allowed FQDNs(Fully Qualified Domain Name) for egress from Cluster. :paramtype allowed_fqdn_list: list[str] :keyword public_ip_type: Indicates what public IP type to create - IPv4 (default), or DualStack - (both IPv4 and IPv6). Possible values include: "IPv4", "DualStack". Default value: "IPv4". - :paramtype public_ip_type: str or ~kusto_management_client.models.PublicIPType + (both IPv4 and IPv6). Known values are: "IPv4" and "DualStack". + :paramtype public_ip_type: str or ~azure.mgmt.kusto.models.PublicIPType :keyword virtual_cluster_graduation_properties: Virtual Cluster graduation properties. :paramtype virtual_cluster_graduation_properties: str """ - super(Cluster, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.sku = sku self.system_data = None self.zones = zones @@ -906,72 +908,62 @@ def __init__( self.private_endpoint_connections = None -class ClusterCheckNameRequest(msrest.serialization.Model): +class ClusterCheckNameRequest(_serialization.Model): """The result returned from a cluster check name availability request. 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 name: Required. Cluster name. + :ivar name: Cluster name. Required. :vartype name: str - :ivar type: The type of resource, Microsoft.Kusto/clusters. Has constant value: + :ivar type: The type of resource, Microsoft.Kusto/clusters. Required. Default value is "Microsoft.Kusto/clusters". :vartype type: str """ _validation = { - 'name': {'required': True}, - 'type': {'required': True, 'constant': True}, + "name": {"required": True}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "Microsoft.Kusto/clusters" - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. Cluster name. + :keyword name: Cluster name. Required. :paramtype name: str """ - super(ClusterCheckNameRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class ClusterListResult(msrest.serialization.Model): +class ClusterListResult(_serialization.Model): """The list Kusto clusters operation response. :ivar value: The list of Kusto clusters. - :vartype value: list[~kusto_management_client.models.Cluster] + :vartype value: list[~azure.mgmt.kusto.models.Cluster] """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Cluster]'}, + "value": {"key": "value", "type": "[Cluster]"}, } - def __init__( - self, - *, - value: Optional[List["Cluster"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Cluster"]] = None, **kwargs): """ :keyword value: The list of Kusto clusters. - :paramtype value: list[~kusto_management_client.models.Cluster] + :paramtype value: list[~azure.mgmt.kusto.models.Cluster] """ - super(ClusterListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class ClusterPrincipalAssignment(ProxyResource): +class ClusterPrincipalAssignment(ProxyResource): # pylint: disable=too-many-instance-attributes """Class representing a cluster principal assignment. Variables are only populated by the server, and will be ignored when sending a request. @@ -987,70 +979,70 @@ class ClusterPrincipalAssignment(ProxyResource): :ivar principal_id: The principal ID assigned to the cluster principal. It can be a user email, application ID, or security group name. :vartype principal_id: str - :ivar role: Cluster principal role. Possible values include: "AllDatabasesAdmin", + :ivar role: Cluster principal role. Known values are: "AllDatabasesAdmin" and "AllDatabasesViewer". - :vartype role: str or ~kusto_management_client.models.ClusterPrincipalRole + :vartype role: str or ~azure.mgmt.kusto.models.ClusterPrincipalRole :ivar tenant_id: The tenant id of the principal. :vartype tenant_id: str - :ivar principal_type: Principal type. Possible values include: "App", "Group", "User". - :vartype principal_type: str or ~kusto_management_client.models.PrincipalType + :ivar principal_type: Principal type. Known values are: "App", "Group", and "User". + :vartype principal_type: str or ~azure.mgmt.kusto.models.PrincipalType :ivar tenant_name: The tenant name of the principal. :vartype tenant_name: str :ivar principal_name: The principal name. :vartype principal_name: str - :ivar provisioning_state: The provisioned state of the resource. Possible values include: - "Running", "Creating", "Deleting", "Succeeded", "Failed", "Moving". - :vartype provisioning_state: str or ~kusto_management_client.models.ProvisioningState + :ivar provisioning_state: The provisioned state of the resource. Known values are: "Running", + "Creating", "Deleting", "Succeeded", "Failed", and "Moving". + :vartype provisioning_state: str or ~azure.mgmt.kusto.models.ProvisioningState :ivar aad_object_id: The service principal object id in AAD (Azure active directory). :vartype aad_object_id: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'tenant_name': {'readonly': True}, - 'principal_name': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'aad_object_id': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "tenant_name": {"readonly": True}, + "principal_name": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "aad_object_id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'principal_id': {'key': 'properties.principalId', 'type': 'str'}, - 'role': {'key': 'properties.role', 'type': 'str'}, - 'tenant_id': {'key': 'properties.tenantId', 'type': 'str'}, - 'principal_type': {'key': 'properties.principalType', 'type': 'str'}, - 'tenant_name': {'key': 'properties.tenantName', 'type': 'str'}, - 'principal_name': {'key': 'properties.principalName', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'aad_object_id': {'key': 'properties.aadObjectId', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "principal_id": {"key": "properties.principalId", "type": "str"}, + "role": {"key": "properties.role", "type": "str"}, + "tenant_id": {"key": "properties.tenantId", "type": "str"}, + "principal_type": {"key": "properties.principalType", "type": "str"}, + "tenant_name": {"key": "properties.tenantName", "type": "str"}, + "principal_name": {"key": "properties.principalName", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "aad_object_id": {"key": "properties.aadObjectId", "type": "str"}, } def __init__( self, *, principal_id: Optional[str] = None, - role: Optional[Union[str, "ClusterPrincipalRole"]] = None, + role: Optional[Union[str, "_models.ClusterPrincipalRole"]] = None, tenant_id: Optional[str] = None, - principal_type: Optional[Union[str, "PrincipalType"]] = None, + principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, **kwargs ): """ :keyword principal_id: The principal ID assigned to the cluster principal. It can be a user email, application ID, or security group name. :paramtype principal_id: str - :keyword role: Cluster principal role. Possible values include: "AllDatabasesAdmin", + :keyword role: Cluster principal role. Known values are: "AllDatabasesAdmin" and "AllDatabasesViewer". - :paramtype role: str or ~kusto_management_client.models.ClusterPrincipalRole + :paramtype role: str or ~azure.mgmt.kusto.models.ClusterPrincipalRole :keyword tenant_id: The tenant id of the principal. :paramtype tenant_id: str - :keyword principal_type: Principal type. Possible values include: "App", "Group", "User". - :paramtype principal_type: str or ~kusto_management_client.models.PrincipalType + :keyword principal_type: Principal type. Known values are: "App", "Group", and "User". + :paramtype principal_type: str or ~azure.mgmt.kusto.models.PrincipalType """ - super(ClusterPrincipalAssignment, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = principal_id self.role = role self.tenant_id = tenant_id @@ -1061,72 +1053,62 @@ def __init__( self.aad_object_id = None -class ClusterPrincipalAssignmentCheckNameRequest(msrest.serialization.Model): +class ClusterPrincipalAssignmentCheckNameRequest(_serialization.Model): """A principal assignment check name availability request. 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 name: Required. Principal Assignment resource name. + :ivar name: Principal Assignment resource name. Required. :vartype name: str - :ivar type: The type of resource, Microsoft.Kusto/clusters/principalAssignments. Has constant - value: "Microsoft.Kusto/clusters/principalAssignments". + :ivar type: The type of resource, Microsoft.Kusto/clusters/principalAssignments. Required. + Default value is "Microsoft.Kusto/clusters/principalAssignments". :vartype type: str """ _validation = { - 'name': {'required': True}, - 'type': {'required': True, 'constant': True}, + "name": {"required": True}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "Microsoft.Kusto/clusters/principalAssignments" - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. Principal Assignment resource name. + :keyword name: Principal Assignment resource name. Required. :paramtype name: str """ - super(ClusterPrincipalAssignmentCheckNameRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class ClusterPrincipalAssignmentListResult(msrest.serialization.Model): +class ClusterPrincipalAssignmentListResult(_serialization.Model): """The list Kusto cluster principal assignments operation response. :ivar value: The list of Kusto cluster principal assignments. - :vartype value: list[~kusto_management_client.models.ClusterPrincipalAssignment] + :vartype value: list[~azure.mgmt.kusto.models.ClusterPrincipalAssignment] """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ClusterPrincipalAssignment]'}, + "value": {"key": "value", "type": "[ClusterPrincipalAssignment]"}, } - def __init__( - self, - *, - value: Optional[List["ClusterPrincipalAssignment"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ClusterPrincipalAssignment"]] = None, **kwargs): """ :keyword value: The list of Kusto cluster principal assignments. - :paramtype value: list[~kusto_management_client.models.ClusterPrincipalAssignment] + :paramtype value: list[~azure.mgmt.kusto.models.ClusterPrincipalAssignment] """ - super(ClusterPrincipalAssignmentListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class ClusterUpdate(Resource): +class ClusterUpdate(Resource): # pylint: disable=too-many-instance-attributes """Class representing an update to a Kusto cluster. Variables are only populated by the server, and will be ignored when sending a request. @@ -1139,20 +1121,20 @@ class ClusterUpdate(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar location: Resource location. :vartype location: str :ivar sku: The SKU of the cluster. - :vartype sku: ~kusto_management_client.models.AzureSku + :vartype sku: ~azure.mgmt.kusto.models.AzureSku :ivar identity: The identity of the cluster, if configured. - :vartype identity: ~kusto_management_client.models.Identity - :ivar state: The state of the resource. Possible values include: "Creating", "Unavailable", - "Running", "Deleting", "Deleted", "Stopping", "Stopped", "Starting", "Updating". - :vartype state: str or ~kusto_management_client.models.State - :ivar provisioning_state: The provisioned state of the resource. Possible values include: - "Running", "Creating", "Deleting", "Succeeded", "Failed", "Moving". - :vartype provisioning_state: str or ~kusto_management_client.models.ProvisioningState + :vartype identity: ~azure.mgmt.kusto.models.Identity + :ivar state: The state of the resource. Known values are: "Creating", "Unavailable", "Running", + "Deleting", "Deleted", "Stopping", "Stopped", "Starting", and "Updating". + :vartype state: str or ~azure.mgmt.kusto.models.State + :ivar provisioning_state: The provisioned state of the resource. Known values are: "Running", + "Creating", "Deleting", "Succeeded", "Failed", and "Moving". + :vartype provisioning_state: str or ~azure.mgmt.kusto.models.ProvisioningState :ivar uri: The cluster URI. :vartype uri: str :ivar data_ingestion_uri: The cluster data ingestion URI. @@ -1160,9 +1142,9 @@ class ClusterUpdate(Resource): :ivar state_reason: The reason for the cluster's current state. :vartype state_reason: str :ivar trusted_external_tenants: The cluster's external tenants. - :vartype trusted_external_tenants: list[~kusto_management_client.models.TrustedExternalTenant] + :vartype trusted_external_tenants: list[~azure.mgmt.kusto.models.TrustedExternalTenant] :ivar optimized_autoscale: Optimized auto scale definition. - :vartype optimized_autoscale: ~kusto_management_client.models.OptimizedAutoscale + :vartype optimized_autoscale: ~azure.mgmt.kusto.models.OptimizedAutoscale :ivar enable_disk_encryption: A boolean value that indicates if the cluster's disks are encrypted. :vartype enable_disk_encryption: bool @@ -1170,135 +1152,141 @@ class ClusterUpdate(Resource): enabled. :vartype enable_streaming_ingest: bool :ivar virtual_network_configuration: Virtual network definition. - :vartype virtual_network_configuration: - ~kusto_management_client.models.VirtualNetworkConfiguration + :vartype virtual_network_configuration: ~azure.mgmt.kusto.models.VirtualNetworkConfiguration :ivar key_vault_properties: KeyVault properties for the cluster encryption. - :vartype key_vault_properties: ~kusto_management_client.models.KeyVaultProperties + :vartype key_vault_properties: ~azure.mgmt.kusto.models.KeyVaultProperties :ivar enable_purge: A boolean value that indicates if the purge operations are enabled. :vartype enable_purge: bool :ivar language_extensions: List of the cluster's language extensions. - :vartype language_extensions: ~kusto_management_client.models.LanguageExtensionsList + :vartype language_extensions: ~azure.mgmt.kusto.models.LanguageExtensionsList :ivar enable_double_encryption: A boolean value that indicates if double encryption is enabled. :vartype enable_double_encryption: bool :ivar public_network_access: Public network access to the cluster is enabled by default. When - disabled, only private endpoint connection to the cluster is allowed. Possible values include: - "Enabled", "Disabled". Default value: "Enabled". - :vartype public_network_access: str or ~kusto_management_client.models.PublicNetworkAccess + disabled, only private endpoint connection to the cluster is allowed. Known values are: + "Enabled" and "Disabled". + :vartype public_network_access: str or ~azure.mgmt.kusto.models.PublicNetworkAccess :ivar allowed_ip_range_list: The list of ips in the format of CIDR allowed to connect to the cluster. :vartype allowed_ip_range_list: list[str] - :ivar engine_type: The engine type. Possible values include: "V2", "V3". Default value: "V3". - :vartype engine_type: str or ~kusto_management_client.models.EngineType + :ivar engine_type: The engine type. Known values are: "V2" and "V3". + :vartype engine_type: str or ~azure.mgmt.kusto.models.EngineType :ivar accepted_audiences: The cluster's accepted audiences. - :vartype accepted_audiences: list[~kusto_management_client.models.AcceptedAudiences] + :vartype accepted_audiences: list[~azure.mgmt.kusto.models.AcceptedAudiences] :ivar enable_auto_stop: A boolean value that indicates if the cluster could be automatically stopped (due to lack of data or no activity for many days). :vartype enable_auto_stop: bool :ivar restrict_outbound_network_access: Whether or not to restrict outbound network access. - Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Possible values include: - "Enabled", "Disabled". Default value: "Disabled". + Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: + "Enabled" and "Disabled". :vartype restrict_outbound_network_access: str or - ~kusto_management_client.models.ClusterNetworkAccessFlag + ~azure.mgmt.kusto.models.ClusterNetworkAccessFlag :ivar allowed_fqdn_list: List of allowed FQDNs(Fully Qualified Domain Name) for egress from Cluster. :vartype allowed_fqdn_list: list[str] :ivar public_ip_type: Indicates what public IP type to create - IPv4 (default), or DualStack - (both IPv4 and IPv6). Possible values include: "IPv4", "DualStack". Default value: "IPv4". - :vartype public_ip_type: str or ~kusto_management_client.models.PublicIPType + (both IPv4 and IPv6). Known values are: "IPv4" and "DualStack". + :vartype public_ip_type: str or ~azure.mgmt.kusto.models.PublicIPType :ivar virtual_cluster_graduation_properties: Virtual Cluster graduation properties. :vartype virtual_cluster_graduation_properties: str :ivar private_endpoint_connections: A list of private endpoint connections. - :vartype private_endpoint_connections: - list[~kusto_management_client.models.PrivateEndpointConnection] + :vartype private_endpoint_connections: list[~azure.mgmt.kusto.models.PrivateEndpointConnection] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'state': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'uri': {'readonly': True}, - 'data_ingestion_uri': {'readonly': True}, - 'state_reason': {'readonly': True}, - 'language_extensions': {'readonly': True}, - 'private_endpoint_connections': {'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'}, - 'sku': {'key': 'sku', 'type': 'AzureSku'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'uri': {'key': 'properties.uri', 'type': 'str'}, - 'data_ingestion_uri': {'key': 'properties.dataIngestionUri', 'type': 'str'}, - 'state_reason': {'key': 'properties.stateReason', 'type': 'str'}, - 'trusted_external_tenants': {'key': 'properties.trustedExternalTenants', 'type': '[TrustedExternalTenant]'}, - 'optimized_autoscale': {'key': 'properties.optimizedAutoscale', 'type': 'OptimizedAutoscale'}, - 'enable_disk_encryption': {'key': 'properties.enableDiskEncryption', 'type': 'bool'}, - 'enable_streaming_ingest': {'key': 'properties.enableStreamingIngest', 'type': 'bool'}, - 'virtual_network_configuration': {'key': 'properties.virtualNetworkConfiguration', 'type': 'VirtualNetworkConfiguration'}, - 'key_vault_properties': {'key': 'properties.keyVaultProperties', 'type': 'KeyVaultProperties'}, - 'enable_purge': {'key': 'properties.enablePurge', 'type': 'bool'}, - 'language_extensions': {'key': 'properties.languageExtensions', 'type': 'LanguageExtensionsList'}, - 'enable_double_encryption': {'key': 'properties.enableDoubleEncryption', 'type': 'bool'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'allowed_ip_range_list': {'key': 'properties.allowedIpRangeList', 'type': '[str]'}, - 'engine_type': {'key': 'properties.engineType', 'type': 'str'}, - 'accepted_audiences': {'key': 'properties.acceptedAudiences', 'type': '[AcceptedAudiences]'}, - 'enable_auto_stop': {'key': 'properties.enableAutoStop', 'type': 'bool'}, - 'restrict_outbound_network_access': {'key': 'properties.restrictOutboundNetworkAccess', 'type': 'str'}, - 'allowed_fqdn_list': {'key': 'properties.allowedFqdnList', 'type': '[str]'}, - 'public_ip_type': {'key': 'properties.publicIPType', 'type': 'str'}, - 'virtual_cluster_graduation_properties': {'key': 'properties.virtualClusterGraduationProperties', 'type': 'str'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - } - - def __init__( + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "state": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "uri": {"readonly": True}, + "data_ingestion_uri": {"readonly": True}, + "state_reason": {"readonly": True}, + "language_extensions": {"readonly": True}, + "private_endpoint_connections": {"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"}, + "sku": {"key": "sku", "type": "AzureSku"}, + "identity": {"key": "identity", "type": "Identity"}, + "state": {"key": "properties.state", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "uri": {"key": "properties.uri", "type": "str"}, + "data_ingestion_uri": {"key": "properties.dataIngestionUri", "type": "str"}, + "state_reason": {"key": "properties.stateReason", "type": "str"}, + "trusted_external_tenants": {"key": "properties.trustedExternalTenants", "type": "[TrustedExternalTenant]"}, + "optimized_autoscale": {"key": "properties.optimizedAutoscale", "type": "OptimizedAutoscale"}, + "enable_disk_encryption": {"key": "properties.enableDiskEncryption", "type": "bool"}, + "enable_streaming_ingest": {"key": "properties.enableStreamingIngest", "type": "bool"}, + "virtual_network_configuration": { + "key": "properties.virtualNetworkConfiguration", + "type": "VirtualNetworkConfiguration", + }, + "key_vault_properties": {"key": "properties.keyVaultProperties", "type": "KeyVaultProperties"}, + "enable_purge": {"key": "properties.enablePurge", "type": "bool"}, + "language_extensions": {"key": "properties.languageExtensions", "type": "LanguageExtensionsList"}, + "enable_double_encryption": {"key": "properties.enableDoubleEncryption", "type": "bool"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "allowed_ip_range_list": {"key": "properties.allowedIpRangeList", "type": "[str]"}, + "engine_type": {"key": "properties.engineType", "type": "str"}, + "accepted_audiences": {"key": "properties.acceptedAudiences", "type": "[AcceptedAudiences]"}, + "enable_auto_stop": {"key": "properties.enableAutoStop", "type": "bool"}, + "restrict_outbound_network_access": {"key": "properties.restrictOutboundNetworkAccess", "type": "str"}, + "allowed_fqdn_list": {"key": "properties.allowedFqdnList", "type": "[str]"}, + "public_ip_type": {"key": "properties.publicIPType", "type": "str"}, + "virtual_cluster_graduation_properties": { + "key": "properties.virtualClusterGraduationProperties", + "type": "str", + }, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + } + + def __init__( # pylint: disable=too-many-locals self, *, tags: Optional[Dict[str, str]] = None, location: Optional[str] = None, - sku: Optional["AzureSku"] = None, - identity: Optional["Identity"] = None, - trusted_external_tenants: Optional[List["TrustedExternalTenant"]] = None, - optimized_autoscale: Optional["OptimizedAutoscale"] = None, - enable_disk_encryption: Optional[bool] = False, - enable_streaming_ingest: Optional[bool] = False, - virtual_network_configuration: Optional["VirtualNetworkConfiguration"] = None, - key_vault_properties: Optional["KeyVaultProperties"] = None, - enable_purge: Optional[bool] = False, - enable_double_encryption: Optional[bool] = False, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = "Enabled", + sku: Optional["_models.AzureSku"] = None, + identity: Optional["_models.Identity"] = None, + trusted_external_tenants: Optional[List["_models.TrustedExternalTenant"]] = None, + optimized_autoscale: Optional["_models.OptimizedAutoscale"] = None, + enable_disk_encryption: bool = False, + enable_streaming_ingest: bool = False, + virtual_network_configuration: Optional["_models.VirtualNetworkConfiguration"] = None, + key_vault_properties: Optional["_models.KeyVaultProperties"] = None, + enable_purge: bool = False, + enable_double_encryption: bool = False, + public_network_access: Union[str, "_models.PublicNetworkAccess"] = "Enabled", allowed_ip_range_list: Optional[List[str]] = None, - engine_type: Optional[Union[str, "EngineType"]] = "V3", - accepted_audiences: Optional[List["AcceptedAudiences"]] = None, - enable_auto_stop: Optional[bool] = True, - restrict_outbound_network_access: Optional[Union[str, "ClusterNetworkAccessFlag"]] = "Disabled", + engine_type: Union[str, "_models.EngineType"] = "V3", + accepted_audiences: Optional[List["_models.AcceptedAudiences"]] = None, + enable_auto_stop: bool = True, + restrict_outbound_network_access: Union[str, "_models.ClusterNetworkAccessFlag"] = "Disabled", allowed_fqdn_list: Optional[List[str]] = None, - public_ip_type: Optional[Union[str, "PublicIPType"]] = "IPv4", + public_ip_type: Union[str, "_models.PublicIPType"] = "IPv4", virtual_cluster_graduation_properties: Optional[str] = None, **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword location: Resource location. :paramtype location: str :keyword sku: The SKU of the cluster. - :paramtype sku: ~kusto_management_client.models.AzureSku + :paramtype sku: ~azure.mgmt.kusto.models.AzureSku :keyword identity: The identity of the cluster, if configured. - :paramtype identity: ~kusto_management_client.models.Identity + :paramtype identity: ~azure.mgmt.kusto.models.Identity :keyword trusted_external_tenants: The cluster's external tenants. - :paramtype trusted_external_tenants: - list[~kusto_management_client.models.TrustedExternalTenant] + :paramtype trusted_external_tenants: list[~azure.mgmt.kusto.models.TrustedExternalTenant] :keyword optimized_autoscale: Optimized auto scale definition. - :paramtype optimized_autoscale: ~kusto_management_client.models.OptimizedAutoscale + :paramtype optimized_autoscale: ~azure.mgmt.kusto.models.OptimizedAutoscale :keyword enable_disk_encryption: A boolean value that indicates if the cluster's disks are encrypted. :paramtype enable_disk_encryption: bool @@ -1306,45 +1294,43 @@ def __init__( enabled. :paramtype enable_streaming_ingest: bool :keyword virtual_network_configuration: Virtual network definition. - :paramtype virtual_network_configuration: - ~kusto_management_client.models.VirtualNetworkConfiguration + :paramtype virtual_network_configuration: ~azure.mgmt.kusto.models.VirtualNetworkConfiguration :keyword key_vault_properties: KeyVault properties for the cluster encryption. - :paramtype key_vault_properties: ~kusto_management_client.models.KeyVaultProperties + :paramtype key_vault_properties: ~azure.mgmt.kusto.models.KeyVaultProperties :keyword enable_purge: A boolean value that indicates if the purge operations are enabled. :paramtype enable_purge: bool :keyword enable_double_encryption: A boolean value that indicates if double encryption is enabled. :paramtype enable_double_encryption: bool :keyword public_network_access: Public network access to the cluster is enabled by default. - When disabled, only private endpoint connection to the cluster is allowed. Possible values - include: "Enabled", "Disabled". Default value: "Enabled". - :paramtype public_network_access: str or ~kusto_management_client.models.PublicNetworkAccess + When disabled, only private endpoint connection to the cluster is allowed. Known values are: + "Enabled" and "Disabled". + :paramtype public_network_access: str or ~azure.mgmt.kusto.models.PublicNetworkAccess :keyword allowed_ip_range_list: The list of ips in the format of CIDR allowed to connect to the cluster. :paramtype allowed_ip_range_list: list[str] - :keyword engine_type: The engine type. Possible values include: "V2", "V3". Default value: - "V3". - :paramtype engine_type: str or ~kusto_management_client.models.EngineType + :keyword engine_type: The engine type. Known values are: "V2" and "V3". + :paramtype engine_type: str or ~azure.mgmt.kusto.models.EngineType :keyword accepted_audiences: The cluster's accepted audiences. - :paramtype accepted_audiences: list[~kusto_management_client.models.AcceptedAudiences] + :paramtype accepted_audiences: list[~azure.mgmt.kusto.models.AcceptedAudiences] :keyword enable_auto_stop: A boolean value that indicates if the cluster could be automatically stopped (due to lack of data or no activity for many days). :paramtype enable_auto_stop: bool :keyword restrict_outbound_network_access: Whether or not to restrict outbound network access. - Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Possible values include: - "Enabled", "Disabled". Default value: "Disabled". + Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: + "Enabled" and "Disabled". :paramtype restrict_outbound_network_access: str or - ~kusto_management_client.models.ClusterNetworkAccessFlag + ~azure.mgmt.kusto.models.ClusterNetworkAccessFlag :keyword allowed_fqdn_list: List of allowed FQDNs(Fully Qualified Domain Name) for egress from Cluster. :paramtype allowed_fqdn_list: list[str] :keyword public_ip_type: Indicates what public IP type to create - IPv4 (default), or DualStack - (both IPv4 and IPv6). Possible values include: "IPv4", "DualStack". Default value: "IPv4". - :paramtype public_ip_type: str or ~kusto_management_client.models.PublicIPType + (both IPv4 and IPv6). Known values are: "IPv4" and "DualStack". + :paramtype public_ip_type: str or ~azure.mgmt.kusto.models.PublicIPType :keyword virtual_cluster_graduation_properties: Virtual Cluster graduation properties. :paramtype virtual_cluster_graduation_properties: str """ - super(ClusterUpdate, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.location = location self.sku = sku @@ -1375,7 +1361,7 @@ def __init__( self.private_endpoint_connections = None -class ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties(msrest.serialization.Model): +class ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties(_serialization.Model): """ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1387,22 +1373,18 @@ class ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalp """ _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'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None @@ -1410,8 +1392,8 @@ def __init__( class Database(ProxyResource): """Class representing a Kusto database. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: ReadOnlyFollowingDatabase, ReadWriteDatabase. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ReadOnlyFollowingDatabase, ReadWriteDatabase Variables are only populated by the server, and will be ignored when sending a request. @@ -1427,84 +1409,72 @@ class Database(ProxyResource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar kind: Required. Kind of the database.Constant filled by server. Possible values include: - "ReadWrite", "ReadOnlyFollowing". - :vartype kind: str or ~kusto_management_client.models.Kind + :ivar kind: Kind of the database. Required. Known values are: "ReadWrite" and + "ReadOnlyFollowing". + :vartype kind: str or ~azure.mgmt.kusto.models.Kind """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, } - _subtype_map = { - 'kind': {'ReadOnlyFollowing': 'ReadOnlyFollowingDatabase', 'ReadWrite': 'ReadWriteDatabase'} - } + _subtype_map = {"kind": {"ReadOnlyFollowing": "ReadOnlyFollowingDatabase", "ReadWrite": "ReadWriteDatabase"}} - def __init__( - self, - *, - location: Optional[str] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, **kwargs): """ :keyword location: Resource location. :paramtype location: str """ - super(Database, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location - self.kind = 'Database' # type: str + self.kind = None # type: Optional[str] -class DatabaseListResult(msrest.serialization.Model): +class DatabaseListResult(_serialization.Model): """The list Kusto databases operation response. :ivar value: The list of Kusto databases. - :vartype value: list[~kusto_management_client.models.Database] + :vartype value: list[~azure.mgmt.kusto.models.Database] """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Database]'}, + "value": {"key": "value", "type": "[Database]"}, } - def __init__( - self, - *, - value: Optional[List["Database"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Database"]] = None, **kwargs): """ :keyword value: The list of Kusto databases. - :paramtype value: list[~kusto_management_client.models.Database] + :paramtype value: list[~azure.mgmt.kusto.models.Database] """ - super(DatabaseListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class DatabasePrincipal(msrest.serialization.Model): +class DatabasePrincipal(_serialization.Model): """A class representing database principal entity. 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 role: Required. Database principal role. Possible values include: "Admin", "Ingestor", - "Monitor", "User", "UnrestrictedViewer", "Viewer". - :vartype role: str or ~kusto_management_client.models.DatabasePrincipalRole - :ivar name: Required. Database principal name. + :ivar role: Database principal role. Required. Known values are: "Admin", "Ingestor", + "Monitor", "User", "UnrestrictedViewer", and "Viewer". + :vartype role: str or ~azure.mgmt.kusto.models.DatabasePrincipalRole + :ivar name: Database principal name. Required. :vartype name: str - :ivar type: Required. Database principal type. Possible values include: "App", "Group", "User". - :vartype type: str or ~kusto_management_client.models.DatabasePrincipalType + :ivar type: Database principal type. Required. Known values are: "App", "Group", and "User". + :vartype type: str or ~azure.mgmt.kusto.models.DatabasePrincipalType :ivar fqn: Database principal fully qualified name. :vartype fqn: str :ivar email: Database principal email if exists. @@ -1516,42 +1486,41 @@ class DatabasePrincipal(msrest.serialization.Model): """ _validation = { - 'role': {'required': True}, - 'name': {'required': True}, - 'type': {'required': True}, - 'tenant_name': {'readonly': True}, + "role": {"required": True}, + "name": {"required": True}, + "type": {"required": True}, + "tenant_name": {"readonly": True}, } _attribute_map = { - 'role': {'key': 'role', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'fqn': {'key': 'fqn', 'type': 'str'}, - 'email': {'key': 'email', 'type': 'str'}, - 'app_id': {'key': 'appId', 'type': 'str'}, - 'tenant_name': {'key': 'tenantName', 'type': 'str'}, + "role": {"key": "role", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "fqn": {"key": "fqn", "type": "str"}, + "email": {"key": "email", "type": "str"}, + "app_id": {"key": "appId", "type": "str"}, + "tenant_name": {"key": "tenantName", "type": "str"}, } def __init__( self, *, - role: Union[str, "DatabasePrincipalRole"], + role: Union[str, "_models.DatabasePrincipalRole"], name: str, - type: Union[str, "DatabasePrincipalType"], + type: Union[str, "_models.DatabasePrincipalType"], fqn: Optional[str] = None, email: Optional[str] = None, app_id: Optional[str] = None, **kwargs ): """ - :keyword role: Required. Database principal role. Possible values include: "Admin", "Ingestor", - "Monitor", "User", "UnrestrictedViewer", "Viewer". - :paramtype role: str or ~kusto_management_client.models.DatabasePrincipalRole - :keyword name: Required. Database principal name. + :keyword role: Database principal role. Required. Known values are: "Admin", "Ingestor", + "Monitor", "User", "UnrestrictedViewer", and "Viewer". + :paramtype role: str or ~azure.mgmt.kusto.models.DatabasePrincipalRole + :keyword name: Database principal name. Required. :paramtype name: str - :keyword type: Required. Database principal type. Possible values include: "App", "Group", - "User". - :paramtype type: str or ~kusto_management_client.models.DatabasePrincipalType + :keyword type: Database principal type. Required. Known values are: "App", "Group", and "User". + :paramtype type: str or ~azure.mgmt.kusto.models.DatabasePrincipalType :keyword fqn: Database principal fully qualified name. :paramtype fqn: str :keyword email: Database principal email if exists. @@ -1559,7 +1528,7 @@ def __init__( :keyword app_id: Application id - relevant only for application principal type. :paramtype app_id: str """ - super(DatabasePrincipal, self).__init__(**kwargs) + super().__init__(**kwargs) self.role = role self.name = name self.type = type @@ -1569,7 +1538,7 @@ def __init__( self.tenant_name = None -class DatabasePrincipalAssignment(ProxyResource): +class DatabasePrincipalAssignment(ProxyResource): # pylint: disable=too-many-instance-attributes """Class representing a database principal assignment. Variables are only populated by the server, and will be ignored when sending a request. @@ -1585,70 +1554,70 @@ class DatabasePrincipalAssignment(ProxyResource): :ivar principal_id: The principal ID assigned to the database principal. It can be a user email, application ID, or security group name. :vartype principal_id: str - :ivar role: Database principal role. Possible values include: "Admin", "Ingestor", "Monitor", - "User", "UnrestrictedViewer", "Viewer". - :vartype role: str or ~kusto_management_client.models.DatabasePrincipalRole + :ivar role: Database principal role. Known values are: "Admin", "Ingestor", "Monitor", "User", + "UnrestrictedViewer", and "Viewer". + :vartype role: str or ~azure.mgmt.kusto.models.DatabasePrincipalRole :ivar tenant_id: The tenant id of the principal. :vartype tenant_id: str - :ivar principal_type: Principal type. Possible values include: "App", "Group", "User". - :vartype principal_type: str or ~kusto_management_client.models.PrincipalType + :ivar principal_type: Principal type. Known values are: "App", "Group", and "User". + :vartype principal_type: str or ~azure.mgmt.kusto.models.PrincipalType :ivar tenant_name: The tenant name of the principal. :vartype tenant_name: str :ivar principal_name: The principal name. :vartype principal_name: str - :ivar provisioning_state: The provisioned state of the resource. Possible values include: - "Running", "Creating", "Deleting", "Succeeded", "Failed", "Moving". - :vartype provisioning_state: str or ~kusto_management_client.models.ProvisioningState + :ivar provisioning_state: The provisioned state of the resource. Known values are: "Running", + "Creating", "Deleting", "Succeeded", "Failed", and "Moving". + :vartype provisioning_state: str or ~azure.mgmt.kusto.models.ProvisioningState :ivar aad_object_id: The service principal object id in AAD (Azure active directory). :vartype aad_object_id: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'tenant_name': {'readonly': True}, - 'principal_name': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'aad_object_id': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "tenant_name": {"readonly": True}, + "principal_name": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "aad_object_id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'principal_id': {'key': 'properties.principalId', 'type': 'str'}, - 'role': {'key': 'properties.role', 'type': 'str'}, - 'tenant_id': {'key': 'properties.tenantId', 'type': 'str'}, - 'principal_type': {'key': 'properties.principalType', 'type': 'str'}, - 'tenant_name': {'key': 'properties.tenantName', 'type': 'str'}, - 'principal_name': {'key': 'properties.principalName', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'aad_object_id': {'key': 'properties.aadObjectId', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "principal_id": {"key": "properties.principalId", "type": "str"}, + "role": {"key": "properties.role", "type": "str"}, + "tenant_id": {"key": "properties.tenantId", "type": "str"}, + "principal_type": {"key": "properties.principalType", "type": "str"}, + "tenant_name": {"key": "properties.tenantName", "type": "str"}, + "principal_name": {"key": "properties.principalName", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "aad_object_id": {"key": "properties.aadObjectId", "type": "str"}, } def __init__( self, *, principal_id: Optional[str] = None, - role: Optional[Union[str, "DatabasePrincipalRole"]] = None, + role: Optional[Union[str, "_models.DatabasePrincipalRole"]] = None, tenant_id: Optional[str] = None, - principal_type: Optional[Union[str, "PrincipalType"]] = None, + principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, **kwargs ): """ :keyword principal_id: The principal ID assigned to the database principal. It can be a user email, application ID, or security group name. :paramtype principal_id: str - :keyword role: Database principal role. Possible values include: "Admin", "Ingestor", - "Monitor", "User", "UnrestrictedViewer", "Viewer". - :paramtype role: str or ~kusto_management_client.models.DatabasePrincipalRole + :keyword role: Database principal role. Known values are: "Admin", "Ingestor", "Monitor", + "User", "UnrestrictedViewer", and "Viewer". + :paramtype role: str or ~azure.mgmt.kusto.models.DatabasePrincipalRole :keyword tenant_id: The tenant id of the principal. :paramtype tenant_id: str - :keyword principal_type: Principal type. Possible values include: "App", "Group", "User". - :paramtype principal_type: str or ~kusto_management_client.models.PrincipalType + :keyword principal_type: Principal type. Known values are: "App", "Group", and "User". + :paramtype principal_type: str or ~azure.mgmt.kusto.models.PrincipalType """ - super(DatabasePrincipalAssignment, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = principal_id self.role = role self.tenant_id = tenant_id @@ -1659,122 +1628,102 @@ def __init__( self.aad_object_id = None -class DatabasePrincipalAssignmentCheckNameRequest(msrest.serialization.Model): +class DatabasePrincipalAssignmentCheckNameRequest(_serialization.Model): """A principal assignment check name availability request. 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 name: Required. Principal Assignment resource name. + :ivar name: Principal Assignment resource name. Required. :vartype name: str - :ivar type: The type of resource, Microsoft.Kusto/clusters/databases/principalAssignments. Has - constant value: "Microsoft.Kusto/clusters/databases/principalAssignments". + :ivar type: The type of resource, Microsoft.Kusto/clusters/databases/principalAssignments. + Required. Default value is "Microsoft.Kusto/clusters/databases/principalAssignments". :vartype type: str """ _validation = { - 'name': {'required': True}, - 'type': {'required': True, 'constant': True}, + "name": {"required": True}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "Microsoft.Kusto/clusters/databases/principalAssignments" - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. Principal Assignment resource name. + :keyword name: Principal Assignment resource name. Required. :paramtype name: str """ - super(DatabasePrincipalAssignmentCheckNameRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class DatabasePrincipalAssignmentListResult(msrest.serialization.Model): +class DatabasePrincipalAssignmentListResult(_serialization.Model): """The list Kusto database principal assignments operation response. :ivar value: The list of Kusto database principal assignments. - :vartype value: list[~kusto_management_client.models.DatabasePrincipalAssignment] + :vartype value: list[~azure.mgmt.kusto.models.DatabasePrincipalAssignment] """ _attribute_map = { - 'value': {'key': 'value', 'type': '[DatabasePrincipalAssignment]'}, + "value": {"key": "value", "type": "[DatabasePrincipalAssignment]"}, } - def __init__( - self, - *, - value: Optional[List["DatabasePrincipalAssignment"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DatabasePrincipalAssignment"]] = None, **kwargs): """ :keyword value: The list of Kusto database principal assignments. - :paramtype value: list[~kusto_management_client.models.DatabasePrincipalAssignment] + :paramtype value: list[~azure.mgmt.kusto.models.DatabasePrincipalAssignment] """ - super(DatabasePrincipalAssignmentListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class DatabasePrincipalListRequest(msrest.serialization.Model): +class DatabasePrincipalListRequest(_serialization.Model): """The list Kusto database principals operation request. :ivar value: The list of Kusto database principals. - :vartype value: list[~kusto_management_client.models.DatabasePrincipal] + :vartype value: list[~azure.mgmt.kusto.models.DatabasePrincipal] """ _attribute_map = { - 'value': {'key': 'value', 'type': '[DatabasePrincipal]'}, + "value": {"key": "value", "type": "[DatabasePrincipal]"}, } - def __init__( - self, - *, - value: Optional[List["DatabasePrincipal"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DatabasePrincipal"]] = None, **kwargs): """ :keyword value: The list of Kusto database principals. - :paramtype value: list[~kusto_management_client.models.DatabasePrincipal] + :paramtype value: list[~azure.mgmt.kusto.models.DatabasePrincipal] """ - super(DatabasePrincipalListRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class DatabasePrincipalListResult(msrest.serialization.Model): +class DatabasePrincipalListResult(_serialization.Model): """The list Kusto database principals operation response. :ivar value: The list of Kusto database principals. - :vartype value: list[~kusto_management_client.models.DatabasePrincipal] + :vartype value: list[~azure.mgmt.kusto.models.DatabasePrincipal] """ _attribute_map = { - 'value': {'key': 'value', 'type': '[DatabasePrincipal]'}, + "value": {"key": "value", "type": "[DatabasePrincipal]"}, } - def __init__( - self, - *, - value: Optional[List["DatabasePrincipal"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DatabasePrincipal"]] = None, **kwargs): """ :keyword value: The list of Kusto database principals. - :paramtype value: list[~kusto_management_client.models.DatabasePrincipal] + :paramtype value: list[~azure.mgmt.kusto.models.DatabasePrincipal] """ - super(DatabasePrincipalListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class DatabaseStatistics(msrest.serialization.Model): +class DatabaseStatistics(_serialization.Model): """A class that contains database statistics information. :ivar size: The database size - the total size of compressed data and index in bytes. @@ -1782,28 +1731,23 @@ class DatabaseStatistics(msrest.serialization.Model): """ _attribute_map = { - 'size': {'key': 'size', 'type': 'float'}, + "size": {"key": "size", "type": "float"}, } - def __init__( - self, - *, - size: Optional[float] = None, - **kwargs - ): + def __init__(self, *, size: Optional[float] = None, **kwargs): """ :keyword size: The database size - the total size of compressed data and index in bytes. :paramtype size: float """ - super(DatabaseStatistics, self).__init__(**kwargs) + super().__init__(**kwargs) self.size = size class DataConnection(ProxyResource): """Class representing an data connection. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: EventGridDataConnection, EventHubDataConnection, IotHubDataConnection. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + EventGridDataConnection, EventHubDataConnection, IotHubDataConnection Variables are only populated by the server, and will be ignored when sending a request. @@ -1819,168 +1763,152 @@ class DataConnection(ProxyResource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar kind: Required. Kind of the endpoint for the data connection.Constant filled by server. - Possible values include: "EventHub", "EventGrid", "IotHub". - :vartype kind: str or ~kusto_management_client.models.DataConnectionKind + :ivar kind: Kind of the endpoint for the data connection. Required. Known values are: + "EventHub", "EventGrid", and "IotHub". + :vartype kind: str or ~azure.mgmt.kusto.models.DataConnectionKind """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, } _subtype_map = { - 'kind': {'EventGrid': 'EventGridDataConnection', 'EventHub': 'EventHubDataConnection', 'IotHub': 'IotHubDataConnection'} + "kind": { + "EventGrid": "EventGridDataConnection", + "EventHub": "EventHubDataConnection", + "IotHub": "IotHubDataConnection", + } } - def __init__( - self, - *, - location: Optional[str] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, **kwargs): """ :keyword location: Resource location. :paramtype location: str """ - super(DataConnection, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location - self.kind = 'DataConnection' # type: str + self.kind = None # type: Optional[str] -class DataConnectionCheckNameRequest(msrest.serialization.Model): +class DataConnectionCheckNameRequest(_serialization.Model): """A data connection check name availability request. 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 name: Required. Data Connection name. + :ivar name: Data Connection name. Required. :vartype name: str - :ivar type: The type of resource, Microsoft.Kusto/clusters/databases/dataConnections. Has - constant value: "Microsoft.Kusto/clusters/databases/dataConnections". + :ivar type: The type of resource, Microsoft.Kusto/clusters/databases/dataConnections. Required. + Default value is "Microsoft.Kusto/clusters/databases/dataConnections". :vartype type: str """ _validation = { - 'name': {'required': True}, - 'type': {'required': True, 'constant': True}, + "name": {"required": True}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "Microsoft.Kusto/clusters/databases/dataConnections" - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. Data Connection name. + :keyword name: Data Connection name. Required. :paramtype name: str """ - super(DataConnectionCheckNameRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class DataConnectionListResult(msrest.serialization.Model): +class DataConnectionListResult(_serialization.Model): """The list Kusto data connections operation response. :ivar value: The list of Kusto data connections. - :vartype value: list[~kusto_management_client.models.DataConnection] + :vartype value: list[~azure.mgmt.kusto.models.DataConnection] """ _attribute_map = { - 'value': {'key': 'value', 'type': '[DataConnection]'}, + "value": {"key": "value", "type": "[DataConnection]"}, } - def __init__( - self, - *, - value: Optional[List["DataConnection"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DataConnection"]] = None, **kwargs): """ :keyword value: The list of Kusto data connections. - :paramtype value: list[~kusto_management_client.models.DataConnection] + :paramtype value: list[~azure.mgmt.kusto.models.DataConnection] """ - super(DataConnectionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class DataConnectionValidation(msrest.serialization.Model): +class DataConnectionValidation(_serialization.Model): """Class representing an data connection validation. :ivar data_connection_name: The name of the data connection. :vartype data_connection_name: str :ivar properties: The data connection properties to validate. - :vartype properties: ~kusto_management_client.models.DataConnection + :vartype properties: ~azure.mgmt.kusto.models.DataConnection """ _attribute_map = { - 'data_connection_name': {'key': 'dataConnectionName', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DataConnection'}, + "data_connection_name": {"key": "dataConnectionName", "type": "str"}, + "properties": {"key": "properties", "type": "DataConnection"}, } def __init__( self, *, data_connection_name: Optional[str] = None, - properties: Optional["DataConnection"] = None, + properties: Optional["_models.DataConnection"] = None, **kwargs ): """ :keyword data_connection_name: The name of the data connection. :paramtype data_connection_name: str :keyword properties: The data connection properties to validate. - :paramtype properties: ~kusto_management_client.models.DataConnection + :paramtype properties: ~azure.mgmt.kusto.models.DataConnection """ - super(DataConnectionValidation, self).__init__(**kwargs) + super().__init__(**kwargs) self.data_connection_name = data_connection_name self.properties = properties -class DataConnectionValidationListResult(msrest.serialization.Model): +class DataConnectionValidationListResult(_serialization.Model): """The list Kusto data connection validation result. :ivar value: The list of Kusto data connection validation errors. - :vartype value: list[~kusto_management_client.models.DataConnectionValidationResult] + :vartype value: list[~azure.mgmt.kusto.models.DataConnectionValidationResult] """ _attribute_map = { - 'value': {'key': 'value', 'type': '[DataConnectionValidationResult]'}, + "value": {"key": "value", "type": "[DataConnectionValidationResult]"}, } - def __init__( - self, - *, - value: Optional[List["DataConnectionValidationResult"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DataConnectionValidationResult"]] = None, **kwargs): """ :keyword value: The list of Kusto data connection validation errors. - :paramtype value: list[~kusto_management_client.models.DataConnectionValidationResult] + :paramtype value: list[~azure.mgmt.kusto.models.DataConnectionValidationResult] """ - super(DataConnectionValidationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class DataConnectionValidationResult(msrest.serialization.Model): +class DataConnectionValidationResult(_serialization.Model): """The result returned from a data connection validation request. :ivar error_message: A message which indicates a problem in data connection validation. @@ -1988,24 +1916,19 @@ class DataConnectionValidationResult(msrest.serialization.Model): """ _attribute_map = { - 'error_message': {'key': 'errorMessage', 'type': 'str'}, + "error_message": {"key": "errorMessage", "type": "str"}, } - def __init__( - self, - *, - error_message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, error_message: Optional[str] = None, **kwargs): """ :keyword error_message: A message which indicates a problem in data connection validation. :paramtype error_message: str """ - super(DataConnectionValidationResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.error_message = error_message -class DiagnoseVirtualNetworkResult(msrest.serialization.Model): +class DiagnoseVirtualNetworkResult(_serialization.Model): """DiagnoseVirtualNetworkResult. :ivar findings: The list of network connectivity diagnostic finding. @@ -2013,56 +1936,51 @@ class DiagnoseVirtualNetworkResult(msrest.serialization.Model): """ _attribute_map = { - 'findings': {'key': 'findings', 'type': '[str]'}, + "findings": {"key": "findings", "type": "[str]"}, } - def __init__( - self, - *, - findings: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, findings: Optional[List[str]] = None, **kwargs): """ :keyword findings: The list of network connectivity diagnostic finding. :paramtype findings: list[str] """ - super(DiagnoseVirtualNetworkResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.findings = findings -class EndpointDependency(msrest.serialization.Model): +class EndpointDependency(_serialization.Model): """A domain name that a service is reached at, including details of the current connection status. :ivar domain_name: The domain name of the dependency. :vartype domain_name: str :ivar endpoint_details: The ports used when connecting to DomainName. - :vartype endpoint_details: list[~kusto_management_client.models.EndpointDetail] + :vartype endpoint_details: list[~azure.mgmt.kusto.models.EndpointDetail] """ _attribute_map = { - 'domain_name': {'key': 'domainName', 'type': 'str'}, - 'endpoint_details': {'key': 'endpointDetails', 'type': '[EndpointDetail]'}, + "domain_name": {"key": "domainName", "type": "str"}, + "endpoint_details": {"key": "endpointDetails", "type": "[EndpointDetail]"}, } def __init__( self, *, domain_name: Optional[str] = None, - endpoint_details: Optional[List["EndpointDetail"]] = None, + endpoint_details: Optional[List["_models.EndpointDetail"]] = None, **kwargs ): """ :keyword domain_name: The domain name of the dependency. :paramtype domain_name: str :keyword endpoint_details: The ports used when connecting to DomainName. - :paramtype endpoint_details: list[~kusto_management_client.models.EndpointDetail] + :paramtype endpoint_details: list[~azure.mgmt.kusto.models.EndpointDetail] """ - super(EndpointDependency, self).__init__(**kwargs) + super().__init__(**kwargs) self.domain_name = domain_name self.endpoint_details = endpoint_details -class EndpointDetail(msrest.serialization.Model): +class EndpointDetail(_serialization.Model): """Current TCP connectivity information from the Kusto cluster to a single endpoint. :ivar port: The port an endpoint is connected to. @@ -2070,24 +1988,19 @@ class EndpointDetail(msrest.serialization.Model): """ _attribute_map = { - 'port': {'key': 'port', 'type': 'int'}, + "port": {"key": "port", "type": "int"}, } - def __init__( - self, - *, - port: Optional[int] = None, - **kwargs - ): + def __init__(self, *, port: Optional[int] = None, **kwargs): """ :keyword port: The port an endpoint is connected to. :paramtype port: int """ - super(EndpointDetail, self).__init__(**kwargs) + super().__init__(**kwargs) self.port = port -class EventGridDataConnection(DataConnection): +class EventGridDataConnection(DataConnection): # pylint: disable=too-many-instance-attributes """Class representing an Event Grid data connection. Variables are only populated by the server, and will be ignored when sending a request. @@ -2104,9 +2017,9 @@ class EventGridDataConnection(DataConnection): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar kind: Required. Kind of the endpoint for the data connection.Constant filled by server. - Possible values include: "EventHub", "EventGrid", "IotHub". - :vartype kind: str or ~kusto_management_client.models.DataConnectionKind + :ivar kind: Kind of the endpoint for the data connection. Required. Known values are: + "EventHub", "EventGrid", and "IotHub". + :vartype kind: str or ~azure.mgmt.kusto.models.DataConnectionKind :ivar storage_account_resource_id: The resource ID of the storage account where the data resides. :vartype storage_account_resource_id: str @@ -2124,58 +2037,57 @@ class EventGridDataConnection(DataConnection): information can be added to each message. :vartype mapping_rule_name: str :ivar data_format: The data format of the message. Optionally the data format can be added to - each message. Possible values include: "MULTIJSON", "JSON", "CSV", "TSV", "SCSV", "SOHSV", - "PSV", "TXT", "RAW", "SINGLEJSON", "AVRO", "TSVE", "PARQUET", "ORC", "APACHEAVRO", - "W3CLOGFILE". - :vartype data_format: str or ~kusto_management_client.models.EventGridDataFormat + each message. Known values are: "MULTIJSON", "JSON", "CSV", "TSV", "SCSV", "SOHSV", "PSV", + "TXT", "RAW", "SINGLEJSON", "AVRO", "TSVE", "PARQUET", "ORC", "APACHEAVRO", and "W3CLOGFILE". + :vartype data_format: str or ~azure.mgmt.kusto.models.EventGridDataFormat :ivar ignore_first_record: A Boolean value that, if set to true, indicates that ingestion should ignore the first record of every file. :vartype ignore_first_record: bool - :ivar blob_storage_event_type: The name of blob storage event type to process. Possible values - include: "Microsoft.Storage.BlobCreated", "Microsoft.Storage.BlobRenamed". - :vartype blob_storage_event_type: str or ~kusto_management_client.models.BlobStorageEventType + :ivar blob_storage_event_type: The name of blob storage event type to process. Known values + are: "Microsoft.Storage.BlobCreated" and "Microsoft.Storage.BlobRenamed". + :vartype blob_storage_event_type: str or ~azure.mgmt.kusto.models.BlobStorageEventType :ivar managed_identity_resource_id: The resource ID of a managed identity (system or user assigned) to be used to authenticate with event hub and storage account. :vartype managed_identity_resource_id: str :ivar managed_identity_object_id: The object ID of managedIdentityResourceId. :vartype managed_identity_object_id: str :ivar database_routing: Indication for database routing information from the data connection, - by default only database routing information is allowed. Possible values include: "Single", + by default only database routing information is allowed. Known values are: "Single" and "Multi". - :vartype database_routing: str or ~kusto_management_client.models.DatabaseRouting - :ivar provisioning_state: The provisioned state of the resource. Possible values include: - "Running", "Creating", "Deleting", "Succeeded", "Failed", "Moving". - :vartype provisioning_state: str or ~kusto_management_client.models.ProvisioningState + :vartype database_routing: str or ~azure.mgmt.kusto.models.DatabaseRouting + :ivar provisioning_state: The provisioned state of the resource. Known values are: "Running", + "Creating", "Deleting", "Succeeded", "Failed", and "Moving". + :vartype provisioning_state: str or ~azure.mgmt.kusto.models.ProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'managed_identity_object_id': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "managed_identity_object_id": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'storage_account_resource_id': {'key': 'properties.storageAccountResourceId', 'type': 'str'}, - 'event_grid_resource_id': {'key': 'properties.eventGridResourceId', 'type': 'str'}, - 'event_hub_resource_id': {'key': 'properties.eventHubResourceId', 'type': 'str'}, - 'consumer_group': {'key': 'properties.consumerGroup', 'type': 'str'}, - 'table_name': {'key': 'properties.tableName', 'type': 'str'}, - 'mapping_rule_name': {'key': 'properties.mappingRuleName', 'type': 'str'}, - 'data_format': {'key': 'properties.dataFormat', 'type': 'str'}, - 'ignore_first_record': {'key': 'properties.ignoreFirstRecord', 'type': 'bool'}, - 'blob_storage_event_type': {'key': 'properties.blobStorageEventType', 'type': 'str'}, - 'managed_identity_resource_id': {'key': 'properties.managedIdentityResourceId', 'type': 'str'}, - 'managed_identity_object_id': {'key': 'properties.managedIdentityObjectId', 'type': 'str'}, - 'database_routing': {'key': 'properties.databaseRouting', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "storage_account_resource_id": {"key": "properties.storageAccountResourceId", "type": "str"}, + "event_grid_resource_id": {"key": "properties.eventGridResourceId", "type": "str"}, + "event_hub_resource_id": {"key": "properties.eventHubResourceId", "type": "str"}, + "consumer_group": {"key": "properties.consumerGroup", "type": "str"}, + "table_name": {"key": "properties.tableName", "type": "str"}, + "mapping_rule_name": {"key": "properties.mappingRuleName", "type": "str"}, + "data_format": {"key": "properties.dataFormat", "type": "str"}, + "ignore_first_record": {"key": "properties.ignoreFirstRecord", "type": "bool"}, + "blob_storage_event_type": {"key": "properties.blobStorageEventType", "type": "str"}, + "managed_identity_resource_id": {"key": "properties.managedIdentityResourceId", "type": "str"}, + "managed_identity_object_id": {"key": "properties.managedIdentityObjectId", "type": "str"}, + "database_routing": {"key": "properties.databaseRouting", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -2188,11 +2100,11 @@ def __init__( consumer_group: Optional[str] = None, table_name: Optional[str] = None, mapping_rule_name: Optional[str] = None, - data_format: Optional[Union[str, "EventGridDataFormat"]] = None, + data_format: Optional[Union[str, "_models.EventGridDataFormat"]] = None, ignore_first_record: Optional[bool] = None, - blob_storage_event_type: Optional[Union[str, "BlobStorageEventType"]] = None, + blob_storage_event_type: Optional[Union[str, "_models.BlobStorageEventType"]] = None, managed_identity_resource_id: Optional[str] = None, - database_routing: Optional[Union[str, "DatabaseRouting"]] = None, + database_routing: Optional[Union[str, "_models.DatabaseRouting"]] = None, **kwargs ): """ @@ -2216,26 +2128,25 @@ def __init__( mapping information can be added to each message. :paramtype mapping_rule_name: str :keyword data_format: The data format of the message. Optionally the data format can be added - to each message. Possible values include: "MULTIJSON", "JSON", "CSV", "TSV", "SCSV", "SOHSV", - "PSV", "TXT", "RAW", "SINGLEJSON", "AVRO", "TSVE", "PARQUET", "ORC", "APACHEAVRO", - "W3CLOGFILE". - :paramtype data_format: str or ~kusto_management_client.models.EventGridDataFormat + to each message. Known values are: "MULTIJSON", "JSON", "CSV", "TSV", "SCSV", "SOHSV", "PSV", + "TXT", "RAW", "SINGLEJSON", "AVRO", "TSVE", "PARQUET", "ORC", "APACHEAVRO", and "W3CLOGFILE". + :paramtype data_format: str or ~azure.mgmt.kusto.models.EventGridDataFormat :keyword ignore_first_record: A Boolean value that, if set to true, indicates that ingestion should ignore the first record of every file. :paramtype ignore_first_record: bool - :keyword blob_storage_event_type: The name of blob storage event type to process. Possible - values include: "Microsoft.Storage.BlobCreated", "Microsoft.Storage.BlobRenamed". - :paramtype blob_storage_event_type: str or ~kusto_management_client.models.BlobStorageEventType + :keyword blob_storage_event_type: The name of blob storage event type to process. Known values + are: "Microsoft.Storage.BlobCreated" and "Microsoft.Storage.BlobRenamed". + :paramtype blob_storage_event_type: str or ~azure.mgmt.kusto.models.BlobStorageEventType :keyword managed_identity_resource_id: The resource ID of a managed identity (system or user assigned) to be used to authenticate with event hub and storage account. :paramtype managed_identity_resource_id: str :keyword database_routing: Indication for database routing information from the data - connection, by default only database routing information is allowed. Possible values include: - "Single", "Multi". - :paramtype database_routing: str or ~kusto_management_client.models.DatabaseRouting + connection, by default only database routing information is allowed. Known values are: "Single" + and "Multi". + :paramtype database_routing: str or ~azure.mgmt.kusto.models.DatabaseRouting """ - super(EventGridDataConnection, self).__init__(location=location, **kwargs) - self.kind = 'EventGrid' # type: str + super().__init__(location=location, **kwargs) + self.kind = "EventGrid" # type: str self.storage_account_resource_id = storage_account_resource_id self.event_grid_resource_id = event_grid_resource_id self.event_hub_resource_id = event_hub_resource_id @@ -2251,7 +2162,7 @@ def __init__( self.provisioning_state = None -class EventHubDataConnection(DataConnection): +class EventHubDataConnection(DataConnection): # pylint: disable=too-many-instance-attributes """Class representing an event hub data connection. Variables are only populated by the server, and will be ignored when sending a request. @@ -2268,9 +2179,9 @@ class EventHubDataConnection(DataConnection): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar kind: Required. Kind of the endpoint for the data connection.Constant filled by server. - Possible values include: "EventHub", "EventGrid", "IotHub". - :vartype kind: str or ~kusto_management_client.models.DataConnectionKind + :ivar kind: Kind of the endpoint for the data connection. Required. Known values are: + "EventHub", "EventGrid", and "IotHub". + :vartype kind: str or ~azure.mgmt.kusto.models.DataConnectionKind :ivar event_hub_resource_id: The resource ID of the event hub to be used to create a data connection. :vartype event_hub_resource_id: str @@ -2283,55 +2194,59 @@ class EventHubDataConnection(DataConnection): information can be added to each message. :vartype mapping_rule_name: str :ivar data_format: The data format of the message. Optionally the data format can be added to - each message. Possible values include: "MULTIJSON", "JSON", "CSV", "TSV", "SCSV", "SOHSV", - "PSV", "TXT", "RAW", "SINGLEJSON", "AVRO", "TSVE", "PARQUET", "ORC", "APACHEAVRO", - "W3CLOGFILE". - :vartype data_format: str or ~kusto_management_client.models.EventHubDataFormat + each message. Known values are: "MULTIJSON", "JSON", "CSV", "TSV", "SCSV", "SOHSV", "PSV", + "TXT", "RAW", "SINGLEJSON", "AVRO", "TSVE", "PARQUET", "ORC", "APACHEAVRO", and "W3CLOGFILE". + :vartype data_format: str or ~azure.mgmt.kusto.models.EventHubDataFormat :ivar event_system_properties: System properties of the event hub. :vartype event_system_properties: list[str] - :ivar compression: The event hub messages compression type. Possible values include: "None", - "GZip". Default value: "None". - :vartype compression: str or ~kusto_management_client.models.Compression - :ivar provisioning_state: The provisioned state of the resource. Possible values include: - "Running", "Creating", "Deleting", "Succeeded", "Failed", "Moving". - :vartype provisioning_state: str or ~kusto_management_client.models.ProvisioningState + :ivar compression: The event hub messages compression type. Known values are: "None" and + "GZip". + :vartype compression: str or ~azure.mgmt.kusto.models.Compression + :ivar provisioning_state: The provisioned state of the resource. Known values are: "Running", + "Creating", "Deleting", "Succeeded", "Failed", and "Moving". + :vartype provisioning_state: str or ~azure.mgmt.kusto.models.ProvisioningState :ivar managed_identity_resource_id: The resource ID of a managed identity (system or user assigned) to be used to authenticate with event hub. :vartype managed_identity_resource_id: str :ivar managed_identity_object_id: The object ID of the managedIdentityResourceId. :vartype managed_identity_object_id: str :ivar database_routing: Indication for database routing information from the data connection, - by default only database routing information is allowed. Possible values include: "Single", + by default only database routing information is allowed. Known values are: "Single" and "Multi". - :vartype database_routing: str or ~kusto_management_client.models.DatabaseRouting + :vartype database_routing: str or ~azure.mgmt.kusto.models.DatabaseRouting + :ivar retrieval_start_date: When defined, the data connection retrieves existing Event hub + events created since the Retrieval start date. It can only retrieve events retained by the + Event hub, based on its retention period. + :vartype retrieval_start_date: ~datetime.datetime """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'managed_identity_object_id': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "provisioning_state": {"readonly": True}, + "managed_identity_object_id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'event_hub_resource_id': {'key': 'properties.eventHubResourceId', 'type': 'str'}, - 'consumer_group': {'key': 'properties.consumerGroup', 'type': 'str'}, - 'table_name': {'key': 'properties.tableName', 'type': 'str'}, - 'mapping_rule_name': {'key': 'properties.mappingRuleName', 'type': 'str'}, - 'data_format': {'key': 'properties.dataFormat', 'type': 'str'}, - 'event_system_properties': {'key': 'properties.eventSystemProperties', 'type': '[str]'}, - 'compression': {'key': 'properties.compression', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'managed_identity_resource_id': {'key': 'properties.managedIdentityResourceId', 'type': 'str'}, - 'managed_identity_object_id': {'key': 'properties.managedIdentityObjectId', 'type': 'str'}, - 'database_routing': {'key': 'properties.databaseRouting', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "event_hub_resource_id": {"key": "properties.eventHubResourceId", "type": "str"}, + "consumer_group": {"key": "properties.consumerGroup", "type": "str"}, + "table_name": {"key": "properties.tableName", "type": "str"}, + "mapping_rule_name": {"key": "properties.mappingRuleName", "type": "str"}, + "data_format": {"key": "properties.dataFormat", "type": "str"}, + "event_system_properties": {"key": "properties.eventSystemProperties", "type": "[str]"}, + "compression": {"key": "properties.compression", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "managed_identity_resource_id": {"key": "properties.managedIdentityResourceId", "type": "str"}, + "managed_identity_object_id": {"key": "properties.managedIdentityObjectId", "type": "str"}, + "database_routing": {"key": "properties.databaseRouting", "type": "str"}, + "retrieval_start_date": {"key": "properties.retrievalStartDate", "type": "iso-8601"}, } def __init__( @@ -2342,11 +2257,12 @@ def __init__( consumer_group: Optional[str] = None, table_name: Optional[str] = None, mapping_rule_name: Optional[str] = None, - data_format: Optional[Union[str, "EventHubDataFormat"]] = None, + data_format: Optional[Union[str, "_models.EventHubDataFormat"]] = None, event_system_properties: Optional[List[str]] = None, - compression: Optional[Union[str, "Compression"]] = "None", + compression: Union[str, "_models.Compression"] = "None", managed_identity_resource_id: Optional[str] = None, - database_routing: Optional[Union[str, "DatabaseRouting"]] = None, + database_routing: Optional[Union[str, "_models.DatabaseRouting"]] = None, + retrieval_start_date: Optional[datetime.datetime] = None, **kwargs ): """ @@ -2364,25 +2280,28 @@ def __init__( mapping information can be added to each message. :paramtype mapping_rule_name: str :keyword data_format: The data format of the message. Optionally the data format can be added - to each message. Possible values include: "MULTIJSON", "JSON", "CSV", "TSV", "SCSV", "SOHSV", - "PSV", "TXT", "RAW", "SINGLEJSON", "AVRO", "TSVE", "PARQUET", "ORC", "APACHEAVRO", - "W3CLOGFILE". - :paramtype data_format: str or ~kusto_management_client.models.EventHubDataFormat + to each message. Known values are: "MULTIJSON", "JSON", "CSV", "TSV", "SCSV", "SOHSV", "PSV", + "TXT", "RAW", "SINGLEJSON", "AVRO", "TSVE", "PARQUET", "ORC", "APACHEAVRO", and "W3CLOGFILE". + :paramtype data_format: str or ~azure.mgmt.kusto.models.EventHubDataFormat :keyword event_system_properties: System properties of the event hub. :paramtype event_system_properties: list[str] - :keyword compression: The event hub messages compression type. Possible values include: "None", - "GZip". Default value: "None". - :paramtype compression: str or ~kusto_management_client.models.Compression + :keyword compression: The event hub messages compression type. Known values are: "None" and + "GZip". + :paramtype compression: str or ~azure.mgmt.kusto.models.Compression :keyword managed_identity_resource_id: The resource ID of a managed identity (system or user assigned) to be used to authenticate with event hub. :paramtype managed_identity_resource_id: str :keyword database_routing: Indication for database routing information from the data - connection, by default only database routing information is allowed. Possible values include: - "Single", "Multi". - :paramtype database_routing: str or ~kusto_management_client.models.DatabaseRouting - """ - super(EventHubDataConnection, self).__init__(location=location, **kwargs) - self.kind = 'EventHub' # type: str + connection, by default only database routing information is allowed. Known values are: "Single" + and "Multi". + :paramtype database_routing: str or ~azure.mgmt.kusto.models.DatabaseRouting + :keyword retrieval_start_date: When defined, the data connection retrieves existing Event hub + events created since the Retrieval start date. It can only retrieve events retained by the + Event hub, based on its retention period. + :paramtype retrieval_start_date: ~datetime.datetime + """ + super().__init__(location=location, **kwargs) + self.kind = "EventHub" # type: str self.event_hub_resource_id = event_hub_resource_id self.consumer_group = consumer_group self.table_name = table_name @@ -2394,85 +2313,86 @@ def __init__( self.managed_identity_resource_id = managed_identity_resource_id self.managed_identity_object_id = None self.database_routing = database_routing + self.retrieval_start_date = retrieval_start_date -class FollowerDatabaseDefinition(msrest.serialization.Model): +class FollowerDatabaseDefinition(_serialization.Model): """A class representing follower database request. 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 cluster_resource_id: Required. Resource id of the cluster that follows a database owned - by this cluster. + :ivar cluster_resource_id: Resource id of the cluster that follows a database owned by this + cluster. Required. :vartype cluster_resource_id: str - :ivar attached_database_configuration_name: Required. Resource name of the attached database - configuration in the follower cluster. + :ivar attached_database_configuration_name: Resource name of the attached database + configuration in the follower cluster. Required. :vartype attached_database_configuration_name: str :ivar database_name: The database name owned by this cluster that was followed. * in case following all databases. :vartype database_name: str + :ivar table_level_sharing_properties: Table level sharing specifications. + :vartype table_level_sharing_properties: ~azure.mgmt.kusto.models.TableLevelSharingProperties + :ivar database_share_origin: The origin of the following setup. Known values are: "Direct", + "DataShare", and "Other". + :vartype database_share_origin: str or ~azure.mgmt.kusto.models.DatabaseShareOrigin """ _validation = { - 'cluster_resource_id': {'required': True}, - 'attached_database_configuration_name': {'required': True}, - 'database_name': {'readonly': True}, + "cluster_resource_id": {"required": True}, + "attached_database_configuration_name": {"required": True}, + "database_name": {"readonly": True}, + "table_level_sharing_properties": {"readonly": True}, + "database_share_origin": {"readonly": True}, } _attribute_map = { - 'cluster_resource_id': {'key': 'clusterResourceId', 'type': 'str'}, - 'attached_database_configuration_name': {'key': 'attachedDatabaseConfigurationName', 'type': 'str'}, - 'database_name': {'key': 'databaseName', 'type': 'str'}, + "cluster_resource_id": {"key": "clusterResourceId", "type": "str"}, + "attached_database_configuration_name": {"key": "attachedDatabaseConfigurationName", "type": "str"}, + "database_name": {"key": "databaseName", "type": "str"}, + "table_level_sharing_properties": {"key": "tableLevelSharingProperties", "type": "TableLevelSharingProperties"}, + "database_share_origin": {"key": "databaseShareOrigin", "type": "str"}, } - def __init__( - self, - *, - cluster_resource_id: str, - attached_database_configuration_name: str, - **kwargs - ): + def __init__(self, *, cluster_resource_id: str, attached_database_configuration_name: str, **kwargs): """ - :keyword cluster_resource_id: Required. Resource id of the cluster that follows a database - owned by this cluster. + :keyword cluster_resource_id: Resource id of the cluster that follows a database owned by this + cluster. Required. :paramtype cluster_resource_id: str - :keyword attached_database_configuration_name: Required. Resource name of the attached database - configuration in the follower cluster. + :keyword attached_database_configuration_name: Resource name of the attached database + configuration in the follower cluster. Required. :paramtype attached_database_configuration_name: str """ - super(FollowerDatabaseDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.cluster_resource_id = cluster_resource_id self.attached_database_configuration_name = attached_database_configuration_name self.database_name = None + self.table_level_sharing_properties = None + self.database_share_origin = None -class FollowerDatabaseListResult(msrest.serialization.Model): +class FollowerDatabaseListResult(_serialization.Model): """The list Kusto database principals operation response. :ivar value: The list of follower database result. - :vartype value: list[~kusto_management_client.models.FollowerDatabaseDefinition] + :vartype value: list[~azure.mgmt.kusto.models.FollowerDatabaseDefinition] """ _attribute_map = { - 'value': {'key': 'value', 'type': '[FollowerDatabaseDefinition]'}, + "value": {"key": "value", "type": "[FollowerDatabaseDefinition]"}, } - def __init__( - self, - *, - value: Optional[List["FollowerDatabaseDefinition"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.FollowerDatabaseDefinition"]] = None, **kwargs): """ :keyword value: The list of follower database result. - :paramtype value: list[~kusto_management_client.models.FollowerDatabaseDefinition] + :paramtype value: list[~azure.mgmt.kusto.models.FollowerDatabaseDefinition] """ - super(FollowerDatabaseListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2483,58 +2403,63 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: Required. The type of managed identity used. The type 'SystemAssigned, - UserAssigned' includes both an implicitly created identity and a set of user-assigned - identities. The type 'None' will remove all identities. Possible values include: "None", - "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned". - :vartype type: str or ~kusto_management_client.models.IdentityType + :ivar type: The type of managed identity used. The type 'SystemAssigned, UserAssigned' includes + both an implicitly created identity and a set of user-assigned identities. The type 'None' will + remove all identities. Required. Known values are: "None", "SystemAssigned", "UserAssigned", + and "SystemAssigned, UserAssigned". + :vartype type: str or ~azure.mgmt.kusto.models.IdentityType :ivar user_assigned_identities: The list of user identities associated with the Kusto cluster. The user identity dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. :vartype user_assigned_identities: dict[str, - ~kusto_management_client.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] + ~azure.mgmt.kusto.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'type': {'required': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + "type": {"required": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": { + "key": "userAssignedIdentities", + "type": "{ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties}", + }, } def __init__( self, *, - type: Union[str, "IdentityType"], - user_assigned_identities: Optional[Dict[str, "ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties"]] = None, + type: Union[str, "_models.IdentityType"], + user_assigned_identities: Optional[ + Dict[str, "_models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties"] + ] = None, **kwargs ): """ - :keyword type: Required. The type of managed identity used. The type 'SystemAssigned, - UserAssigned' includes both an implicitly created identity and a set of user-assigned - identities. The type 'None' will remove all identities. Possible values include: "None", - "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned". - :paramtype type: str or ~kusto_management_client.models.IdentityType + :keyword type: The type of managed identity used. The type 'SystemAssigned, UserAssigned' + includes both an implicitly created identity and a set of user-assigned identities. The type + 'None' will remove all identities. Required. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssigned, UserAssigned". + :paramtype type: str or ~azure.mgmt.kusto.models.IdentityType :keyword user_assigned_identities: The list of user identities associated with the Kusto 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, - ~kusto_management_client.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] + ~azure.mgmt.kusto.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] """ - super(Identity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type self.user_assigned_identities = user_assigned_identities -class IotHubDataConnection(DataConnection): +class IotHubDataConnection(DataConnection): # pylint: disable=too-many-instance-attributes """Class representing an iot hub data connection. Variables are only populated by the server, and will be ignored when sending a request. @@ -2551,9 +2476,9 @@ class IotHubDataConnection(DataConnection): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar kind: Required. Kind of the endpoint for the data connection.Constant filled by server. - Possible values include: "EventHub", "EventGrid", "IotHub". - :vartype kind: str or ~kusto_management_client.models.DataConnectionKind + :ivar kind: Kind of the endpoint for the data connection. Required. Known values are: + "EventHub", "EventGrid", and "IotHub". + :vartype kind: str or ~azure.mgmt.kusto.models.DataConnectionKind :ivar iot_hub_resource_id: The resource ID of the Iot hub to be used to create a data connection. :vartype iot_hub_resource_id: str @@ -2566,46 +2491,50 @@ class IotHubDataConnection(DataConnection): information can be added to each message. :vartype mapping_rule_name: str :ivar data_format: The data format of the message. Optionally the data format can be added to - each message. Possible values include: "MULTIJSON", "JSON", "CSV", "TSV", "SCSV", "SOHSV", - "PSV", "TXT", "RAW", "SINGLEJSON", "AVRO", "TSVE", "PARQUET", "ORC", "APACHEAVRO", - "W3CLOGFILE". - :vartype data_format: str or ~kusto_management_client.models.IotHubDataFormat + each message. Known values are: "MULTIJSON", "JSON", "CSV", "TSV", "SCSV", "SOHSV", "PSV", + "TXT", "RAW", "SINGLEJSON", "AVRO", "TSVE", "PARQUET", "ORC", "APACHEAVRO", and "W3CLOGFILE". + :vartype data_format: str or ~azure.mgmt.kusto.models.IotHubDataFormat :ivar event_system_properties: System properties of the iot hub. :vartype event_system_properties: list[str] :ivar shared_access_policy_name: The name of the share access policy. :vartype shared_access_policy_name: str :ivar database_routing: Indication for database routing information from the data connection, - by default only database routing information is allowed. Possible values include: "Single", + by default only database routing information is allowed. Known values are: "Single" and "Multi". - :vartype database_routing: str or ~kusto_management_client.models.DatabaseRouting - :ivar provisioning_state: The provisioned state of the resource. Possible values include: - "Running", "Creating", "Deleting", "Succeeded", "Failed", "Moving". - :vartype provisioning_state: str or ~kusto_management_client.models.ProvisioningState + :vartype database_routing: str or ~azure.mgmt.kusto.models.DatabaseRouting + :ivar retrieval_start_date: When defined, the data connection retrieves existing Event hub + events created since the Retrieval start date. It can only retrieve events retained by the + Event hub, based on its retention period. + :vartype retrieval_start_date: ~datetime.datetime + :ivar provisioning_state: The provisioned state of the resource. Known values are: "Running", + "Creating", "Deleting", "Succeeded", "Failed", and "Moving". + :vartype provisioning_state: str or ~azure.mgmt.kusto.models.ProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'iot_hub_resource_id': {'key': 'properties.iotHubResourceId', 'type': 'str'}, - 'consumer_group': {'key': 'properties.consumerGroup', 'type': 'str'}, - 'table_name': {'key': 'properties.tableName', 'type': 'str'}, - 'mapping_rule_name': {'key': 'properties.mappingRuleName', 'type': 'str'}, - 'data_format': {'key': 'properties.dataFormat', 'type': 'str'}, - 'event_system_properties': {'key': 'properties.eventSystemProperties', 'type': '[str]'}, - 'shared_access_policy_name': {'key': 'properties.sharedAccessPolicyName', 'type': 'str'}, - 'database_routing': {'key': 'properties.databaseRouting', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "iot_hub_resource_id": {"key": "properties.iotHubResourceId", "type": "str"}, + "consumer_group": {"key": "properties.consumerGroup", "type": "str"}, + "table_name": {"key": "properties.tableName", "type": "str"}, + "mapping_rule_name": {"key": "properties.mappingRuleName", "type": "str"}, + "data_format": {"key": "properties.dataFormat", "type": "str"}, + "event_system_properties": {"key": "properties.eventSystemProperties", "type": "[str]"}, + "shared_access_policy_name": {"key": "properties.sharedAccessPolicyName", "type": "str"}, + "database_routing": {"key": "properties.databaseRouting", "type": "str"}, + "retrieval_start_date": {"key": "properties.retrievalStartDate", "type": "iso-8601"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -2616,10 +2545,11 @@ def __init__( consumer_group: Optional[str] = None, table_name: Optional[str] = None, mapping_rule_name: Optional[str] = None, - data_format: Optional[Union[str, "IotHubDataFormat"]] = None, + data_format: Optional[Union[str, "_models.IotHubDataFormat"]] = None, event_system_properties: Optional[List[str]] = None, shared_access_policy_name: Optional[str] = None, - database_routing: Optional[Union[str, "DatabaseRouting"]] = None, + database_routing: Optional[Union[str, "_models.DatabaseRouting"]] = None, + retrieval_start_date: Optional[datetime.datetime] = None, **kwargs ): """ @@ -2637,21 +2567,24 @@ def __init__( mapping information can be added to each message. :paramtype mapping_rule_name: str :keyword data_format: The data format of the message. Optionally the data format can be added - to each message. Possible values include: "MULTIJSON", "JSON", "CSV", "TSV", "SCSV", "SOHSV", - "PSV", "TXT", "RAW", "SINGLEJSON", "AVRO", "TSVE", "PARQUET", "ORC", "APACHEAVRO", - "W3CLOGFILE". - :paramtype data_format: str or ~kusto_management_client.models.IotHubDataFormat + to each message. Known values are: "MULTIJSON", "JSON", "CSV", "TSV", "SCSV", "SOHSV", "PSV", + "TXT", "RAW", "SINGLEJSON", "AVRO", "TSVE", "PARQUET", "ORC", "APACHEAVRO", and "W3CLOGFILE". + :paramtype data_format: str or ~azure.mgmt.kusto.models.IotHubDataFormat :keyword event_system_properties: System properties of the iot hub. :paramtype event_system_properties: list[str] :keyword shared_access_policy_name: The name of the share access policy. :paramtype shared_access_policy_name: str :keyword database_routing: Indication for database routing information from the data - connection, by default only database routing information is allowed. Possible values include: - "Single", "Multi". - :paramtype database_routing: str or ~kusto_management_client.models.DatabaseRouting - """ - super(IotHubDataConnection, self).__init__(location=location, **kwargs) - self.kind = 'IotHub' # type: str + connection, by default only database routing information is allowed. Known values are: "Single" + and "Multi". + :paramtype database_routing: str or ~azure.mgmt.kusto.models.DatabaseRouting + :keyword retrieval_start_date: When defined, the data connection retrieves existing Event hub + events created since the Retrieval start date. It can only retrieve events retained by the + Event hub, based on its retention period. + :paramtype retrieval_start_date: ~datetime.datetime + """ + super().__init__(location=location, **kwargs) + self.kind = "IotHub" # type: str self.iot_hub_resource_id = iot_hub_resource_id self.consumer_group = consumer_group self.table_name = table_name @@ -2660,10 +2593,11 @@ def __init__( self.event_system_properties = event_system_properties self.shared_access_policy_name = shared_access_policy_name self.database_routing = database_routing + self.retrieval_start_date = retrieval_start_date self.provisioning_state = None -class KeyVaultProperties(msrest.serialization.Model): +class KeyVaultProperties(_serialization.Model): """Properties of the key vault. :ivar key_name: The name of the key vault key. @@ -2677,10 +2611,10 @@ class KeyVaultProperties(msrest.serialization.Model): """ _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'key_version': {'key': 'keyVersion', 'type': 'str'}, - 'key_vault_uri': {'key': 'keyVaultUri', 'type': 'str'}, - 'user_identity': {'key': 'userIdentity', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, + "key_version": {"key": "keyVersion", "type": "str"}, + "key_vault_uri": {"key": "keyVaultUri", "type": "str"}, + "user_identity": {"key": "userIdentity", "type": "str"}, } def __init__( @@ -2703,88 +2637,73 @@ def __init__( key. :paramtype user_identity: str """ - super(KeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.key_version = key_version self.key_vault_uri = key_vault_uri self.user_identity = user_identity -class LanguageExtension(msrest.serialization.Model): +class LanguageExtension(_serialization.Model): """The language extension object. - :ivar language_extension_name: The language extension name. Possible values include: "PYTHON", - "R". - :vartype language_extension_name: str or ~kusto_management_client.models.LanguageExtensionName + :ivar language_extension_name: The language extension name. Known values are: "PYTHON" and "R". + :vartype language_extension_name: str or ~azure.mgmt.kusto.models.LanguageExtensionName """ _attribute_map = { - 'language_extension_name': {'key': 'languageExtensionName', 'type': 'str'}, + "language_extension_name": {"key": "languageExtensionName", "type": "str"}, } def __init__( - self, - *, - language_extension_name: Optional[Union[str, "LanguageExtensionName"]] = None, - **kwargs + self, *, language_extension_name: Optional[Union[str, "_models.LanguageExtensionName"]] = None, **kwargs ): """ - :keyword language_extension_name: The language extension name. Possible values include: - "PYTHON", "R". - :paramtype language_extension_name: str or - ~kusto_management_client.models.LanguageExtensionName + :keyword language_extension_name: The language extension name. Known values are: "PYTHON" and + "R". + :paramtype language_extension_name: str or ~azure.mgmt.kusto.models.LanguageExtensionName """ - super(LanguageExtension, self).__init__(**kwargs) + super().__init__(**kwargs) self.language_extension_name = language_extension_name -class LanguageExtensionsList(msrest.serialization.Model): +class LanguageExtensionsList(_serialization.Model): """The list of language extension objects. :ivar value: The list of language extensions. - :vartype value: list[~kusto_management_client.models.LanguageExtension] + :vartype value: list[~azure.mgmt.kusto.models.LanguageExtension] """ _attribute_map = { - 'value': {'key': 'value', 'type': '[LanguageExtension]'}, + "value": {"key": "value", "type": "[LanguageExtension]"}, } - def __init__( - self, - *, - value: Optional[List["LanguageExtension"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.LanguageExtension"]] = None, **kwargs): """ :keyword value: The list of language extensions. - :paramtype value: list[~kusto_management_client.models.LanguageExtension] + :paramtype value: list[~azure.mgmt.kusto.models.LanguageExtension] """ - super(LanguageExtensionsList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class ListResourceSkusResult(msrest.serialization.Model): +class ListResourceSkusResult(_serialization.Model): """List of available SKUs for a Kusto Cluster. :ivar value: The collection of available SKUs for an existing resource. - :vartype value: list[~kusto_management_client.models.AzureResourceSku] + :vartype value: list[~azure.mgmt.kusto.models.AzureResourceSku] """ _attribute_map = { - 'value': {'key': 'value', 'type': '[AzureResourceSku]'}, + "value": {"key": "value", "type": "[AzureResourceSku]"}, } - def __init__( - self, - *, - value: Optional[List["AzureResourceSku"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.AzureResourceSku"]] = None, **kwargs): """ :keyword value: The collection of available SKUs for an existing resource. - :paramtype value: list[~kusto_management_client.models.AzureResourceSku] + :paramtype value: list[~azure.mgmt.kusto.models.AzureResourceSku] """ - super(ListResourceSkusResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value @@ -2802,7 +2721,7 @@ class ManagedPrivateEndpoint(ProxyResource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~kusto_management_client.models.SystemData + :vartype system_data: ~azure.mgmt.kusto.models.SystemData :ivar private_link_resource_id: The ARM resource ID of the resource for which the managed private endpoint is created. :vartype private_link_resource_id: str @@ -2813,29 +2732,29 @@ class ManagedPrivateEndpoint(ProxyResource): :vartype group_id: str :ivar request_message: The user request message. :vartype request_message: str - :ivar provisioning_state: The provisioned state of the resource. Possible values include: - "Running", "Creating", "Deleting", "Succeeded", "Failed", "Moving". - :vartype provisioning_state: str or ~kusto_management_client.models.ProvisioningState + :ivar provisioning_state: The provisioned state of the resource. Known values are: "Running", + "Creating", "Deleting", "Succeeded", "Failed", and "Moving". + :vartype provisioning_state: str or ~azure.mgmt.kusto.models.ProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"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_link_resource_id': {'key': 'properties.privateLinkResourceId', 'type': 'str'}, - 'private_link_resource_region': {'key': 'properties.privateLinkResourceRegion', 'type': 'str'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'request_message': {'key': 'properties.requestMessage', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "private_link_resource_id": {"key": "properties.privateLinkResourceId", "type": "str"}, + "private_link_resource_region": {"key": "properties.privateLinkResourceRegion", "type": "str"}, + "group_id": {"key": "properties.groupId", "type": "str"}, + "request_message": {"key": "properties.requestMessage", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -2859,7 +2778,7 @@ def __init__( :keyword request_message: The user request message. :paramtype request_message: str """ - super(ManagedPrivateEndpoint, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.private_link_resource_id = private_link_resource_id self.private_link_resource_region = private_link_resource_region @@ -2868,119 +2787,109 @@ def __init__( self.provisioning_state = None -class ManagedPrivateEndpointListResult(msrest.serialization.Model): +class ManagedPrivateEndpointListResult(_serialization.Model): """The list managed private endpoints operation response. :ivar value: The list of managed private endpoints. - :vartype value: list[~kusto_management_client.models.ManagedPrivateEndpoint] + :vartype value: list[~azure.mgmt.kusto.models.ManagedPrivateEndpoint] """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ManagedPrivateEndpoint]'}, + "value": {"key": "value", "type": "[ManagedPrivateEndpoint]"}, } - def __init__( - self, - *, - value: Optional[List["ManagedPrivateEndpoint"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ManagedPrivateEndpoint"]] = None, **kwargs): """ :keyword value: The list of managed private endpoints. - :paramtype value: list[~kusto_management_client.models.ManagedPrivateEndpoint] + :paramtype value: list[~azure.mgmt.kusto.models.ManagedPrivateEndpoint] """ - super(ManagedPrivateEndpointListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class ManagedPrivateEndpointsCheckNameRequest(msrest.serialization.Model): +class ManagedPrivateEndpointsCheckNameRequest(_serialization.Model): """The result returned from a managedPrivateEndpoints check name availability request. 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 name: Required. Managed private endpoint resource name. + :ivar name: Managed private endpoint resource name. Required. :vartype name: str :ivar type: The type of resource, for instance - Microsoft.Kusto/clusters/managedPrivateEndpoints. Has constant value: + Microsoft.Kusto/clusters/managedPrivateEndpoints. Required. Default value is "Microsoft.Kusto/clusters/managedPrivateEndpoints". :vartype type: str """ _validation = { - 'name': {'required': True}, - 'type': {'required': True, 'constant': True}, + "name": {"required": True}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "Microsoft.Kusto/clusters/managedPrivateEndpoints" - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. Managed private endpoint resource name. + :keyword name: Managed private endpoint resource name. Required. :paramtype name: str """ - super(ManagedPrivateEndpointsCheckNameRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """A REST API operation. :ivar name: This is of the format {provider}/{resource}/{operation}. :vartype name: str :ivar display: The object that describes the operation. - :vartype display: ~kusto_management_client.models.OperationDisplay + :vartype display: ~azure.mgmt.kusto.models.OperationDisplay :ivar origin: The intended executor of the operation. :vartype origin: str - :ivar properties: Any object. - :vartype properties: any + :ivar properties: Properties of the operation. + :vartype properties: JSON """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'object'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "properties": {"key": "properties", "type": "object"}, } def __init__( self, *, name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, - properties: Optional[Any] = None, + properties: Optional[JSON] = None, **kwargs ): """ :keyword name: This is of the format {provider}/{resource}/{operation}. :paramtype name: str :keyword display: The object that describes the operation. - :paramtype display: ~kusto_management_client.models.OperationDisplay + :paramtype display: ~azure.mgmt.kusto.models.OperationDisplay :keyword origin: The intended executor of the operation. :paramtype origin: str - :keyword properties: Any object. - :paramtype properties: any + :keyword properties: Properties of the operation. + :paramtype properties: JSON """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display self.origin = origin self.properties = properties -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that describes the operation. :ivar provider: Friendly name of the resource provider. @@ -2994,10 +2903,10 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -3019,46 +2928,40 @@ def __init__( :keyword description: The friendly name of the operation. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.operation = operation self.resource = resource self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list REST API operations. It contains a list of operations and a URL nextLink to get the next set of results. :ivar value: The list of operations supported by the resource provider. - :vartype value: list[~kusto_management_client.models.Operation] + :vartype value: list[~azure.mgmt.kusto.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'}, + "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 - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: The list of operations supported by the resource provider. - :paramtype value: list[~kusto_management_client.models.Operation] + :paramtype value: list[~azure.mgmt.kusto.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(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class OperationResult(msrest.serialization.Model): +class OperationResult(_serialization.Model): # pylint: disable=too-many-instance-attributes """Operation Result Entity. Variables are only populated by the server, and will be ignored when sending a request. @@ -3067,9 +2970,9 @@ class OperationResult(msrest.serialization.Model): :vartype id: str :ivar name: Name of the resource. :vartype name: str - :ivar status: status of the Operation result. Possible values include: "Succeeded", "Canceled", - "Failed", "Running". - :vartype status: str or ~kusto_management_client.models.Status + :ivar status: status of the Operation result. Known values are: "Succeeded", "Canceled", + "Failed", and "Running". + :vartype status: str or ~azure.mgmt.kusto.models.Status :ivar start_time: The operation start time. :vartype start_time: ~datetime.datetime :ivar end_time: The operation end time. @@ -3082,33 +2985,33 @@ class OperationResult(msrest.serialization.Model): :vartype message: str :ivar operation_kind: The kind of the operation. :vartype operation_kind: str - :ivar provisioning_state: The provisioned state of the resource. Possible values include: - "Running", "Creating", "Deleting", "Succeeded", "Failed", "Moving". - :vartype provisioning_state: str or ~kusto_management_client.models.ProvisioningState + :ivar provisioning_state: The provisioned state of the resource. Known values are: "Running", + "Creating", "Deleting", "Succeeded", "Failed", and "Moving". + :vartype provisioning_state: str or ~azure.mgmt.kusto.models.ProvisioningState :ivar operation_state: The state of the operation. :vartype operation_state: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'status': {'readonly': True}, - 'percent_complete': {'maximum': 100, 'minimum': 0}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "status": {"readonly": True}, + "percent_complete": {"maximum": 100, "minimum": 0}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'percent_complete': {'key': 'percentComplete', 'type': 'float'}, - 'code': {'key': 'error.code', 'type': 'str'}, - 'message': {'key': 'error.message', 'type': 'str'}, - 'operation_kind': {'key': 'properties.operationKind', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'operation_state': {'key': 'properties.operationState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "percent_complete": {"key": "percentComplete", "type": "float"}, + "code": {"key": "error.code", "type": "str"}, + "message": {"key": "error.message", "type": "str"}, + "operation_kind": {"key": "properties.operationKind", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "operation_state": {"key": "properties.operationState", "type": "str"}, } def __init__( @@ -3139,7 +3042,7 @@ def __init__( :keyword operation_state: The state of the operation. :paramtype operation_state: str """ - super(OperationResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.status = None @@ -3153,57 +3056,49 @@ def __init__( self.operation_state = operation_state -class OptimizedAutoscale(msrest.serialization.Model): +class OptimizedAutoscale(_serialization.Model): """A class that contains the optimized auto scale definition. All required parameters must be populated in order to send to Azure. - :ivar version: Required. The version of the template defined, for instance 1. + :ivar version: The version of the template defined, for instance 1. Required. :vartype version: int - :ivar is_enabled: Required. A boolean value that indicate if the optimized autoscale feature is - enabled or not. + :ivar is_enabled: A boolean value that indicate if the optimized autoscale feature is enabled + or not. Required. :vartype is_enabled: bool - :ivar minimum: Required. Minimum allowed instances count. + :ivar minimum: Minimum allowed instances count. Required. :vartype minimum: int - :ivar maximum: Required. Maximum allowed instances count. + :ivar maximum: Maximum allowed instances count. Required. :vartype maximum: int """ _validation = { - 'version': {'required': True}, - 'is_enabled': {'required': True}, - 'minimum': {'required': True}, - 'maximum': {'required': True}, + "version": {"required": True}, + "is_enabled": {"required": True}, + "minimum": {"required": True}, + "maximum": {"required": True}, } _attribute_map = { - 'version': {'key': 'version', 'type': 'int'}, - 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, - 'minimum': {'key': 'minimum', 'type': 'int'}, - 'maximum': {'key': 'maximum', 'type': 'int'}, + "version": {"key": "version", "type": "int"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + "minimum": {"key": "minimum", "type": "int"}, + "maximum": {"key": "maximum", "type": "int"}, } - def __init__( - self, - *, - version: int, - is_enabled: bool, - minimum: int, - maximum: int, - **kwargs - ): + def __init__(self, *, version: int, is_enabled: bool, minimum: int, maximum: int, **kwargs): """ - :keyword version: Required. The version of the template defined, for instance 1. + :keyword version: The version of the template defined, for instance 1. Required. :paramtype version: int - :keyword is_enabled: Required. A boolean value that indicate if the optimized autoscale feature - is enabled or not. + :keyword is_enabled: A boolean value that indicate if the optimized autoscale feature is + enabled or not. Required. :paramtype is_enabled: bool - :keyword minimum: Required. Minimum allowed instances count. + :keyword minimum: Minimum allowed instances count. Required. :paramtype minimum: int - :keyword maximum: Required. Maximum allowed instances count. + :keyword maximum: Maximum allowed instances count. Required. :paramtype maximum: int """ - super(OptimizedAutoscale, self).__init__(**kwargs) + super().__init__(**kwargs) self.version = version self.is_enabled = is_enabled self.minimum = minimum @@ -3229,35 +3124,35 @@ class OutboundNetworkDependenciesEndpoint(ProxyResource): Storage, Azure SQL Database, and Azure Active Directory. :vartype category: str :ivar endpoints: The endpoints that the Kusto Service Environment reaches the service at. - :vartype endpoints: list[~kusto_management_client.models.EndpointDependency] - :ivar provisioning_state: The provisioned state of the resource. Possible values include: - "Running", "Creating", "Deleting", "Succeeded", "Failed", "Moving". - :vartype provisioning_state: str or ~kusto_management_client.models.ProvisioningState + :vartype endpoints: list[~azure.mgmt.kusto.models.EndpointDependency] + :ivar provisioning_state: The provisioned state of the resource. Known values are: "Running", + "Creating", "Deleting", "Succeeded", "Failed", and "Moving". + :vartype provisioning_state: str or ~azure.mgmt.kusto.models.ProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'category': {'key': 'properties.category', 'type': 'str'}, - 'endpoints': {'key': 'properties.endpoints', 'type': '[EndpointDependency]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "category": {"key": "properties.category", "type": "str"}, + "endpoints": {"key": "properties.endpoints", "type": "[EndpointDependency]"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( self, *, category: Optional[str] = None, - endpoints: Optional[List["EndpointDependency"]] = None, + endpoints: Optional[List["_models.EndpointDependency"]] = None, **kwargs ): """ @@ -3265,49 +3160,44 @@ def __init__( Storage, Azure SQL Database, and Azure Active Directory. :paramtype category: str :keyword endpoints: The endpoints that the Kusto Service Environment reaches the service at. - :paramtype endpoints: list[~kusto_management_client.models.EndpointDependency] + :paramtype endpoints: list[~azure.mgmt.kusto.models.EndpointDependency] """ - super(OutboundNetworkDependenciesEndpoint, self).__init__(**kwargs) + super().__init__(**kwargs) self.etag = None self.category = category self.endpoints = endpoints self.provisioning_state = None -class OutboundNetworkDependenciesEndpointListResult(msrest.serialization.Model): +class OutboundNetworkDependenciesEndpointListResult(_serialization.Model): """Collection of Outbound Environment Endpoints. 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 value: Required. Collection of resources. - :vartype value: list[~kusto_management_client.models.OutboundNetworkDependenciesEndpoint] + :ivar value: Collection of resources. Required. + :vartype value: list[~azure.mgmt.kusto.models.OutboundNetworkDependenciesEndpoint] :ivar next_link: Link to next page of resources. :vartype next_link: str """ _validation = { - 'value': {'required': True}, - 'next_link': {'readonly': True}, + "value": {"required": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[OutboundNetworkDependenciesEndpoint]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[OutboundNetworkDependenciesEndpoint]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: List["OutboundNetworkDependenciesEndpoint"], - **kwargs - ): + def __init__(self, *, value: List["_models.OutboundNetworkDependenciesEndpoint"], **kwargs): """ - :keyword value: Required. Collection of resources. - :paramtype value: list[~kusto_management_client.models.OutboundNetworkDependenciesEndpoint] + :keyword value: Collection of resources. Required. + :paramtype value: list[~azure.mgmt.kusto.models.OutboundNetworkDependenciesEndpoint] """ - super(OutboundNetworkDependenciesEndpointListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None @@ -3326,13 +3216,13 @@ class PrivateEndpointConnection(ProxyResource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~kusto_management_client.models.SystemData + :vartype system_data: ~azure.mgmt.kusto.models.SystemData :ivar private_endpoint: Private endpoint which the connection belongs to. - :vartype private_endpoint: ~kusto_management_client.models.PrivateEndpointProperty + :vartype private_endpoint: ~azure.mgmt.kusto.models.PrivateEndpointProperty :ivar private_link_service_connection_state: Connection State of the Private Endpoint Connection. :vartype private_link_service_connection_state: - ~kusto_management_client.models.PrivateLinkServiceConnectionStateProperty + ~azure.mgmt.kusto.models.PrivateLinkServiceConnectionStateProperty :ivar group_id: Group id of the private endpoint. :vartype group_id: str :ivar provisioning_state: Provisioning state of the private endpoint. @@ -3340,39 +3230,42 @@ class PrivateEndpointConnection(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'private_endpoint': {'readonly': True}, - 'group_id': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "private_endpoint": {"readonly": True}, + "group_id": {"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': 'PrivateEndpointProperty'}, - 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionStateProperty'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpointProperty"}, + "private_link_service_connection_state": { + "key": "properties.privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionStateProperty", + }, + "group_id": {"key": "properties.groupId", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( self, *, - private_link_service_connection_state: Optional["PrivateLinkServiceConnectionStateProperty"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionStateProperty"] = None, **kwargs ): """ :keyword private_link_service_connection_state: Connection State of the Private Endpoint Connection. :paramtype private_link_service_connection_state: - ~kusto_management_client.models.PrivateLinkServiceConnectionStateProperty + ~azure.mgmt.kusto.models.PrivateLinkServiceConnectionStateProperty """ - super(PrivateEndpointConnection, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.private_endpoint = None self.private_link_service_connection_state = private_link_service_connection_state @@ -3380,32 +3273,27 @@ def __init__( self.provisioning_state = None -class PrivateEndpointConnectionListResult(msrest.serialization.Model): +class PrivateEndpointConnectionListResult(_serialization.Model): """A list of private endpoint connections. :ivar value: Array of private endpoint connections. - :vartype value: list[~kusto_management_client.models.PrivateEndpointConnection] + :vartype value: list[~azure.mgmt.kusto.models.PrivateEndpointConnection] """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, } - def __init__( - self, - *, - value: Optional[List["PrivateEndpointConnection"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs): """ :keyword value: Array of private endpoint connections. - :paramtype value: list[~kusto_management_client.models.PrivateEndpointConnection] + :paramtype value: list[~azure.mgmt.kusto.models.PrivateEndpointConnection] """ - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class PrivateEndpointProperty(msrest.serialization.Model): +class PrivateEndpointProperty(_serialization.Model): """Private endpoint which the connection belongs to. Variables are only populated by the server, and will be ignored when sending a request. @@ -3415,20 +3303,16 @@ class PrivateEndpointProperty(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PrivateEndpointProperty, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None @@ -3446,7 +3330,7 @@ class PrivateLinkResource(Resource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~kusto_management_client.models.SystemData + :vartype system_data: ~azure.mgmt.kusto.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. @@ -3456,64 +3340,55 @@ class PrivateLinkResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'group_id': {'readonly': True}, - 'required_members': {'readonly': True}, - 'required_zone_names': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "group_id": {"readonly": True}, + "required_members": {"readonly": True}, + "required_zone_names": {"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]'}, + "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) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.system_data = None self.group_id = None self.required_members = None self.required_zone_names = None -class PrivateLinkResourceListResult(msrest.serialization.Model): +class PrivateLinkResourceListResult(_serialization.Model): """A list of private link resources. :ivar value: Array of private link resources. - :vartype value: list[~kusto_management_client.models.PrivateLinkResource] + :vartype value: list[~azure.mgmt.kusto.models.PrivateLinkResource] """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, + "value": {"key": "value", "type": "[PrivateLinkResource]"}, } - def __init__( - self, - *, - value: Optional[List["PrivateLinkResource"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs): """ :keyword value: Array of private link resources. - :paramtype value: list[~kusto_management_client.models.PrivateLinkResource] + :paramtype value: list[~azure.mgmt.kusto.models.PrivateLinkResource] """ - super(PrivateLinkResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class PrivateLinkServiceConnectionStateProperty(msrest.serialization.Model): +class PrivateLinkServiceConnectionStateProperty(_serialization.Model): """Connection State of the Private Endpoint Connection. Variables are only populated by the server, and will be ignored when sending a request. @@ -3528,35 +3403,29 @@ class PrivateLinkServiceConnectionStateProperty(msrest.serialization.Model): """ _validation = { - 'actions_required': {'readonly': True}, + "actions_required": {"readonly": 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: Optional[str] = None, - description: Optional[str] = None, - **kwargs - ): + def __init__(self, *, status: Optional[str] = None, description: Optional[str] = None, **kwargs): """ :keyword status: The private link service connection status. :paramtype status: str :keyword description: The private link service connection description. :paramtype description: str """ - super(PrivateLinkServiceConnectionStateProperty, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.description = description self.actions_required = None -class ReadOnlyFollowingDatabase(Database): +class ReadOnlyFollowingDatabase(Database): # pylint: disable=too-many-instance-attributes """Class representing a read only following database. Variables are only populated by the server, and will be ignored when sending a request. @@ -3573,64 +3442,77 @@ class ReadOnlyFollowingDatabase(Database): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar kind: Required. Kind of the database.Constant filled by server. Possible values include: - "ReadWrite", "ReadOnlyFollowing". - :vartype kind: str or ~kusto_management_client.models.Kind - :ivar provisioning_state: The provisioned state of the resource. Possible values include: - "Running", "Creating", "Deleting", "Succeeded", "Failed", "Moving". - :vartype provisioning_state: str or ~kusto_management_client.models.ProvisioningState + :ivar kind: Kind of the database. Required. Known values are: "ReadWrite" and + "ReadOnlyFollowing". + :vartype kind: str or ~azure.mgmt.kusto.models.Kind + :ivar provisioning_state: The provisioned state of the resource. Known values are: "Running", + "Creating", "Deleting", "Succeeded", "Failed", and "Moving". + :vartype provisioning_state: str or ~azure.mgmt.kusto.models.ProvisioningState :ivar soft_delete_period: The time the data should be kept before it stops being accessible to queries in TimeSpan. :vartype soft_delete_period: ~datetime.timedelta :ivar hot_cache_period: The time the data should be kept in cache for fast queries in TimeSpan. :vartype hot_cache_period: ~datetime.timedelta :ivar statistics: The statistics of the database. - :vartype statistics: ~kusto_management_client.models.DatabaseStatistics + :vartype statistics: ~azure.mgmt.kusto.models.DatabaseStatistics :ivar leader_cluster_resource_id: The name of the leader cluster. :vartype leader_cluster_resource_id: str :ivar attached_database_configuration_name: The name of the attached database configuration cluster. :vartype attached_database_configuration_name: str - :ivar principals_modification_kind: The principals modification kind of the database. Possible - values include: "Union", "Replace", "None". + :ivar principals_modification_kind: The principals modification kind of the database. Known + values are: "Union", "Replace", and "None". :vartype principals_modification_kind: str or - ~kusto_management_client.models.PrincipalsModificationKind + ~azure.mgmt.kusto.models.PrincipalsModificationKind + :ivar table_level_sharing_properties: Table level sharing specifications. + :vartype table_level_sharing_properties: ~azure.mgmt.kusto.models.TableLevelSharingProperties + :ivar original_database_name: The original database name, before databaseNameOverride or + databaseNamePrefix where applied. + :vartype original_database_name: str + :ivar database_share_origin: The origin of the following setup. Known values are: "Direct", + "DataShare", and "Other". + :vartype database_share_origin: str or ~azure.mgmt.kusto.models.DatabaseShareOrigin """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'soft_delete_period': {'readonly': True}, - 'statistics': {'readonly': True}, - 'leader_cluster_resource_id': {'readonly': True}, - 'attached_database_configuration_name': {'readonly': True}, - 'principals_modification_kind': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'soft_delete_period': {'key': 'properties.softDeletePeriod', 'type': 'duration'}, - 'hot_cache_period': {'key': 'properties.hotCachePeriod', 'type': 'duration'}, - 'statistics': {'key': 'properties.statistics', 'type': 'DatabaseStatistics'}, - 'leader_cluster_resource_id': {'key': 'properties.leaderClusterResourceId', 'type': 'str'}, - 'attached_database_configuration_name': {'key': 'properties.attachedDatabaseConfigurationName', 'type': 'str'}, - 'principals_modification_kind': {'key': 'properties.principalsModificationKind', 'type': 'str'}, - } - - def __init__( - self, - *, - location: Optional[str] = None, - hot_cache_period: Optional[datetime.timedelta] = None, - **kwargs + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "provisioning_state": {"readonly": True}, + "soft_delete_period": {"readonly": True}, + "statistics": {"readonly": True}, + "leader_cluster_resource_id": {"readonly": True}, + "attached_database_configuration_name": {"readonly": True}, + "principals_modification_kind": {"readonly": True}, + "table_level_sharing_properties": {"readonly": True}, + "original_database_name": {"readonly": True}, + "database_share_origin": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "soft_delete_period": {"key": "properties.softDeletePeriod", "type": "duration"}, + "hot_cache_period": {"key": "properties.hotCachePeriod", "type": "duration"}, + "statistics": {"key": "properties.statistics", "type": "DatabaseStatistics"}, + "leader_cluster_resource_id": {"key": "properties.leaderClusterResourceId", "type": "str"}, + "attached_database_configuration_name": {"key": "properties.attachedDatabaseConfigurationName", "type": "str"}, + "principals_modification_kind": {"key": "properties.principalsModificationKind", "type": "str"}, + "table_level_sharing_properties": { + "key": "properties.tableLevelSharingProperties", + "type": "TableLevelSharingProperties", + }, + "original_database_name": {"key": "properties.originalDatabaseName", "type": "str"}, + "database_share_origin": {"key": "properties.databaseShareOrigin", "type": "str"}, + } + + def __init__( + self, *, location: Optional[str] = None, hot_cache_period: Optional[datetime.timedelta] = None, **kwargs ): """ :keyword location: Resource location. @@ -3639,8 +3521,8 @@ def __init__( TimeSpan. :paramtype hot_cache_period: ~datetime.timedelta """ - super(ReadOnlyFollowingDatabase, self).__init__(location=location, **kwargs) - self.kind = 'ReadOnlyFollowing' # type: str + super().__init__(location=location, **kwargs) + self.kind = "ReadOnlyFollowing" # type: str self.provisioning_state = None self.soft_delete_period = None self.hot_cache_period = hot_cache_period @@ -3648,6 +3530,9 @@ def __init__( self.leader_cluster_resource_id = None self.attached_database_configuration_name = None self.principals_modification_kind = None + self.table_level_sharing_properties = None + self.original_database_name = None + self.database_share_origin = None class ReadWriteDatabase(Database): @@ -3667,44 +3552,44 @@ class ReadWriteDatabase(Database): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar kind: Required. Kind of the database.Constant filled by server. Possible values include: - "ReadWrite", "ReadOnlyFollowing". - :vartype kind: str or ~kusto_management_client.models.Kind - :ivar provisioning_state: The provisioned state of the resource. Possible values include: - "Running", "Creating", "Deleting", "Succeeded", "Failed", "Moving". - :vartype provisioning_state: str or ~kusto_management_client.models.ProvisioningState + :ivar kind: Kind of the database. Required. Known values are: "ReadWrite" and + "ReadOnlyFollowing". + :vartype kind: str or ~azure.mgmt.kusto.models.Kind + :ivar provisioning_state: The provisioned state of the resource. Known values are: "Running", + "Creating", "Deleting", "Succeeded", "Failed", and "Moving". + :vartype provisioning_state: str or ~azure.mgmt.kusto.models.ProvisioningState :ivar soft_delete_period: The time the data should be kept before it stops being accessible to queries in TimeSpan. :vartype soft_delete_period: ~datetime.timedelta :ivar hot_cache_period: The time the data should be kept in cache for fast queries in TimeSpan. :vartype hot_cache_period: ~datetime.timedelta :ivar statistics: The statistics of the database. - :vartype statistics: ~kusto_management_client.models.DatabaseStatistics + :vartype statistics: ~azure.mgmt.kusto.models.DatabaseStatistics :ivar is_followed: Indicates whether the database is followed. :vartype is_followed: bool """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'statistics': {'readonly': True}, - 'is_followed': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "provisioning_state": {"readonly": True}, + "statistics": {"readonly": True}, + "is_followed": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'soft_delete_period': {'key': 'properties.softDeletePeriod', 'type': 'duration'}, - 'hot_cache_period': {'key': 'properties.hotCachePeriod', 'type': 'duration'}, - 'statistics': {'key': 'properties.statistics', 'type': 'DatabaseStatistics'}, - 'is_followed': {'key': 'properties.isFollowed', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "soft_delete_period": {"key": "properties.softDeletePeriod", "type": "duration"}, + "hot_cache_period": {"key": "properties.hotCachePeriod", "type": "duration"}, + "statistics": {"key": "properties.statistics", "type": "DatabaseStatistics"}, + "is_followed": {"key": "properties.isFollowed", "type": "bool"}, } def __init__( @@ -3725,8 +3610,8 @@ def __init__( TimeSpan. :paramtype hot_cache_period: ~datetime.timedelta """ - super(ReadWriteDatabase, self).__init__(location=location, **kwargs) - self.kind = 'ReadWrite' # type: str + super().__init__(location=location, **kwargs) + self.kind = "ReadWrite" # type: str self.provisioning_state = None self.soft_delete_period = soft_delete_period self.hot_cache_period = hot_cache_period @@ -3748,7 +3633,7 @@ class Script(ProxyResource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~kusto_management_client.models.SystemData + :vartype system_data: ~azure.mgmt.kusto.models.SystemData :ivar script_url: The url to the KQL script blob file. Must not be used together with scriptContent property. :vartype script_url: str @@ -3763,30 +3648,30 @@ class Script(ProxyResource): :vartype force_update_tag: str :ivar continue_on_errors: Flag that indicates whether to continue if one of the command fails. :vartype continue_on_errors: bool - :ivar provisioning_state: The provisioned state of the resource. Possible values include: - "Running", "Creating", "Deleting", "Succeeded", "Failed", "Moving". - :vartype provisioning_state: str or ~kusto_management_client.models.ProvisioningState + :ivar provisioning_state: The provisioned state of the resource. Known values are: "Running", + "Creating", "Deleting", "Succeeded", "Failed", and "Moving". + :vartype provisioning_state: str or ~azure.mgmt.kusto.models.ProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"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'}, - 'script_url': {'key': 'properties.scriptUrl', 'type': 'str'}, - 'script_url_sas_token': {'key': 'properties.scriptUrlSasToken', 'type': 'str'}, - 'script_content': {'key': 'properties.scriptContent', 'type': 'str'}, - 'force_update_tag': {'key': 'properties.forceUpdateTag', 'type': 'str'}, - 'continue_on_errors': {'key': 'properties.continueOnErrors', 'type': 'bool'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "script_url": {"key": "properties.scriptUrl", "type": "str"}, + "script_url_sas_token": {"key": "properties.scriptUrlSasToken", "type": "str"}, + "script_content": {"key": "properties.scriptContent", "type": "str"}, + "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, + "continue_on_errors": {"key": "properties.continueOnErrors", "type": "bool"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -3796,7 +3681,7 @@ def __init__( script_url_sas_token: Optional[str] = None, script_content: Optional[str] = None, force_update_tag: Optional[str] = None, - continue_on_errors: Optional[bool] = False, + continue_on_errors: bool = False, **kwargs ): """ @@ -3816,7 +3701,7 @@ def __init__( fails. :paramtype continue_on_errors: bool """ - super(Script, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.script_url = script_url self.script_url_sas_token = script_url_sas_token @@ -3826,72 +3711,62 @@ def __init__( self.provisioning_state = None -class ScriptCheckNameRequest(msrest.serialization.Model): +class ScriptCheckNameRequest(_serialization.Model): """A script name availability request. 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 name: Required. Script name. + :ivar name: Script name. Required. :vartype name: str - :ivar type: The type of resource, Microsoft.Kusto/clusters/databases/scripts. Has constant - value: "Microsoft.Kusto/clusters/databases/scripts". + :ivar type: The type of resource, Microsoft.Kusto/clusters/databases/scripts. Required. Default + value is "Microsoft.Kusto/clusters/databases/scripts". :vartype type: str """ _validation = { - 'name': {'required': True}, - 'type': {'required': True, 'constant': True}, + "name": {"required": True}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "Microsoft.Kusto/clusters/databases/scripts" - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. Script name. + :keyword name: Script name. Required. :paramtype name: str """ - super(ScriptCheckNameRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class ScriptListResult(msrest.serialization.Model): +class ScriptListResult(_serialization.Model): """The list Kusto database script operation response. :ivar value: The list of Kusto scripts. - :vartype value: list[~kusto_management_client.models.Script] + :vartype value: list[~azure.mgmt.kusto.models.Script] """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Script]'}, + "value": {"key": "value", "type": "[Script]"}, } - def __init__( - self, - *, - value: Optional[List["Script"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Script"]] = None, **kwargs): """ :keyword value: The list of Kusto scripts. - :paramtype value: list[~kusto_management_client.models.Script] + :paramtype value: list[~azure.mgmt.kusto.models.Script] """ - super(ScriptListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class SkuDescription(msrest.serialization.Model): +class SkuDescription(_serialization.Model): """The Kusto SKU description of given resource type. Variables are only populated by the server, and will be ignored when sending a request. @@ -3905,36 +3780,32 @@ class SkuDescription(msrest.serialization.Model): :ivar locations: The set of locations that the SKU is available. :vartype locations: list[str] :ivar location_info: Locations and zones. - :vartype location_info: list[~kusto_management_client.models.SkuLocationInfoItem] + :vartype location_info: list[~azure.mgmt.kusto.models.SkuLocationInfoItem] :ivar restrictions: The restrictions because of which SKU cannot be used. - :vartype restrictions: list[any] + :vartype restrictions: list[JSON] """ _validation = { - 'resource_type': {'readonly': True}, - 'name': {'readonly': True}, - 'tier': {'readonly': True}, - 'locations': {'readonly': True}, - 'location_info': {'readonly': True}, - 'restrictions': {'readonly': True}, + "resource_type": {"readonly": True}, + "name": {"readonly": True}, + "tier": {"readonly": True}, + "locations": {"readonly": True}, + "location_info": {"readonly": True}, + "restrictions": {"readonly": True}, } _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'location_info': {'key': 'locationInfo', 'type': '[SkuLocationInfoItem]'}, - 'restrictions': {'key': 'restrictions', 'type': '[object]'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "location_info": {"key": "locationInfo", "type": "[SkuLocationInfoItem]"}, + "restrictions": {"key": "restrictions", "type": "[object]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SkuDescription, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.resource_type = None self.name = None self.tier = None @@ -3943,127 +3814,117 @@ def __init__( self.restrictions = None -class SkuDescriptionList(msrest.serialization.Model): +class SkuDescriptionList(_serialization.Model): """The list of the EngagementFabric SKU descriptions. Variables are only populated by the server, and will be ignored when sending a request. :ivar value: SKU descriptions. - :vartype value: list[~kusto_management_client.models.SkuDescription] + :vartype value: list[~azure.mgmt.kusto.models.SkuDescription] """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SkuDescription]'}, + "value": {"key": "value", "type": "[SkuDescription]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SkuDescriptionList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class SkuLocationInfoItem(msrest.serialization.Model): +class SkuLocationInfoItem(_serialization.Model): """The locations and zones info for SKU. All required parameters must be populated in order to send to Azure. - :ivar location: Required. The available location of the SKU. + :ivar location: The available location of the SKU. Required. :vartype location: str :ivar zones: The available zone of the SKU. :vartype zones: list[str] """ _validation = { - 'location': {'required': True}, + "location": {"required": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, + "location": {"key": "location", "type": "str"}, + "zones": {"key": "zones", "type": "[str]"}, } - def __init__( - self, - *, - location: str, - zones: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, location: str, zones: Optional[List[str]] = None, **kwargs): """ - :keyword location: Required. The available location of the SKU. + :keyword location: The available location of the SKU. Required. :paramtype location: str :keyword zones: The available zone of the SKU. :paramtype zones: list[str] """ - super(SkuLocationInfoItem, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.zones = zones -class SystemData(msrest.serialization.Model): +class SystemData(_serialization.Model): """Metadata pertaining to creation and last modification of the resource. :ivar created_by: The identity that created the resource. :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Possible values include: - "User", "Application", "ManagedIdentity", "Key". - :vartype created_by_type: str or ~kusto_management_client.models.CreatedByType + :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.kusto.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :vartype last_modified_by_type: str or ~kusto_management_client.models.CreatedByType + :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.kusto.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 ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :paramtype created_by_type: str or ~kusto_management_client.models.CreatedByType + :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.kusto.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :paramtype last_modified_by_type: str or ~kusto_management_client.models.CreatedByType + :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.kusto.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(SystemData, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -4072,7 +3933,7 @@ def __init__( self.last_modified_at = last_modified_at -class TableLevelSharingProperties(msrest.serialization.Model): +class TableLevelSharingProperties(_serialization.Model): """Tables that will be included and excluded in the follower database. :ivar tables_to_include: List of tables to include in the follower database. @@ -4092,12 +3953,12 @@ class TableLevelSharingProperties(msrest.serialization.Model): """ _attribute_map = { - 'tables_to_include': {'key': 'tablesToInclude', 'type': '[str]'}, - 'tables_to_exclude': {'key': 'tablesToExclude', 'type': '[str]'}, - 'external_tables_to_include': {'key': 'externalTablesToInclude', 'type': '[str]'}, - 'external_tables_to_exclude': {'key': 'externalTablesToExclude', 'type': '[str]'}, - 'materialized_views_to_include': {'key': 'materializedViewsToInclude', 'type': '[str]'}, - 'materialized_views_to_exclude': {'key': 'materializedViewsToExclude', 'type': '[str]'}, + "tables_to_include": {"key": "tablesToInclude", "type": "[str]"}, + "tables_to_exclude": {"key": "tablesToExclude", "type": "[str]"}, + "external_tables_to_include": {"key": "externalTablesToInclude", "type": "[str]"}, + "external_tables_to_exclude": {"key": "externalTablesToExclude", "type": "[str]"}, + "materialized_views_to_include": {"key": "materializedViewsToInclude", "type": "[str]"}, + "materialized_views_to_exclude": {"key": "materializedViewsToExclude", "type": "[str]"}, } def __init__( @@ -4129,7 +3990,7 @@ def __init__( database. :paramtype materialized_views_to_exclude: list[str] """ - super(TableLevelSharingProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.tables_to_include = tables_to_include self.tables_to_exclude = tables_to_exclude self.external_tables_to_include = external_tables_to_include @@ -4138,7 +3999,7 @@ def __init__( self.materialized_views_to_exclude = materialized_views_to_exclude -class TrustedExternalTenant(msrest.serialization.Model): +class TrustedExternalTenant(_serialization.Model): """Represents a tenant ID that is trusted by the cluster. :ivar value: GUID representing an external tenant. @@ -4146,67 +4007,55 @@ class TrustedExternalTenant(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - *, - value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[str] = None, **kwargs): """ :keyword value: GUID representing an external tenant. :paramtype value: str """ - super(TrustedExternalTenant, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class VirtualNetworkConfiguration(msrest.serialization.Model): +class VirtualNetworkConfiguration(_serialization.Model): """A class that contains virtual network definition. All required parameters must be populated in order to send to Azure. - :ivar subnet_id: Required. The subnet resource id. + :ivar subnet_id: The subnet resource id. Required. :vartype subnet_id: str - :ivar engine_public_ip_id: Required. Engine service's public IP address resource id. + :ivar engine_public_ip_id: Engine service's public IP address resource id. Required. :vartype engine_public_ip_id: str - :ivar data_management_public_ip_id: Required. Data management's service public IP address - resource id. + :ivar data_management_public_ip_id: Data management's service public IP address resource id. + Required. :vartype data_management_public_ip_id: str """ _validation = { - 'subnet_id': {'required': True}, - 'engine_public_ip_id': {'required': True}, - 'data_management_public_ip_id': {'required': True}, + "subnet_id": {"required": True}, + "engine_public_ip_id": {"required": True}, + "data_management_public_ip_id": {"required": True}, } _attribute_map = { - 'subnet_id': {'key': 'subnetId', 'type': 'str'}, - 'engine_public_ip_id': {'key': 'enginePublicIpId', 'type': 'str'}, - 'data_management_public_ip_id': {'key': 'dataManagementPublicIpId', 'type': 'str'}, + "subnet_id": {"key": "subnetId", "type": "str"}, + "engine_public_ip_id": {"key": "enginePublicIpId", "type": "str"}, + "data_management_public_ip_id": {"key": "dataManagementPublicIpId", "type": "str"}, } - def __init__( - self, - *, - subnet_id: str, - engine_public_ip_id: str, - data_management_public_ip_id: str, - **kwargs - ): + def __init__(self, *, subnet_id: str, engine_public_ip_id: str, data_management_public_ip_id: str, **kwargs): """ - :keyword subnet_id: Required. The subnet resource id. + :keyword subnet_id: The subnet resource id. Required. :paramtype subnet_id: str - :keyword engine_public_ip_id: Required. Engine service's public IP address resource id. + :keyword engine_public_ip_id: Engine service's public IP address resource id. Required. :paramtype engine_public_ip_id: str - :keyword data_management_public_ip_id: Required. Data management's service public IP address - resource id. + :keyword data_management_public_ip_id: Data management's service public IP address resource id. + Required. :paramtype data_management_public_ip_id: str """ - super(VirtualNetworkConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.subnet_id = subnet_id self.engine_public_ip_id = engine_public_ip_id self.data_management_public_ip_id = data_management_public_ip_id diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/models/_patch.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/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/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/__init__.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/__init__.py index 766e81238756..38f45e09b0cb 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/__init__.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/__init__.py @@ -20,18 +20,24 @@ from ._operations_results_operations import OperationsResultsOperations from ._operations_results_location_operations import OperationsResultsLocationOperations +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', - 'ClusterPrincipalAssignmentsOperations', - 'DatabasesOperations', - 'AttachedDatabaseConfigurationsOperations', - 'ManagedPrivateEndpointsOperations', - 'DatabasePrincipalAssignmentsOperations', - 'ScriptsOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'DataConnectionsOperations', - 'Operations', - 'OperationsResultsOperations', - 'OperationsResultsLocationOperations', + "ClustersOperations", + "ClusterPrincipalAssignmentsOperations", + "DatabasesOperations", + "AttachedDatabaseConfigurationsOperations", + "ManagedPrivateEndpointsOperations", + "DatabasePrincipalAssignmentsOperations", + "ScriptsOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "DataConnectionsOperations", + "Operations", + "OperationsResultsOperations", + "OperationsResultsLocationOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_attached_database_configurations_operations.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_attached_database_configurations_operations.py index cb1da23eb1c1..fdf3388a3ff4 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_attached_database_configurations_operations.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_attached_database_configurations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,101 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse 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 msrest import Serializer from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_check_name_availability_request( - resource_group_name: str, - cluster_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2022-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurationCheckNameAvailability') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurationCheckNameAvailability", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "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"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", 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 + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "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"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -115,248 +110,331 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "attachedDatabaseConfigurationName": _SERIALIZER.url("attached_database_configuration_name", attached_database_configuration_name, 'str'), - "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"), + "attachedDatabaseConfigurationName": _SERIALIZER.url( + "attached_database_configuration_name", attached_database_configuration_name, "str" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( +def build_create_or_update_request( resource_group_name: str, cluster_name: str, attached_database_configuration_name: str, subscription_id: str, - *, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2022-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "attachedDatabaseConfigurationName": _SERIALIZER.url("attached_database_configuration_name", attached_database_configuration_name, 'str'), - "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"), + "attachedDatabaseConfigurationName": _SERIALIZER.url( + "attached_database_configuration_name", attached_database_configuration_name, "str" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( +def build_delete_request( resource_group_name: str, cluster_name: str, attached_database_configuration_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "attachedDatabaseConfigurationName": _SERIALIZER.url("attached_database_configuration_name", attached_database_configuration_name, 'str'), - "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"), + "attachedDatabaseConfigurationName": _SERIALIZER.url( + "attached_database_configuration_name", attached_database_configuration_name, "str" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class AttachedDatabaseConfigurationsOperations(object): - """AttachedDatabaseConfigurationsOperations 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: ~kusto_management_client.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. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class AttachedDatabaseConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kusto.KustoManagementClient`'s + :attr:`attached_database_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") + + @overload + def check_name_availability( + self, + resource_group_name: str, + cluster_name: str, + resource_name: _models.AttachedDatabaseConfigurationsCheckNameRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the attached database configuration resource name is valid and is not already in + use. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: ~azure.mgmt.kusto.models.AttachedDatabaseConfigurationsCheckNameRequest + :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: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, + resource_group_name: str, + cluster_name: str, + resource_name: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the attached database configuration resource name is valid and is not already in + use. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: 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: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def check_name_availability( self, resource_group_name: str, cluster_name: str, - resource_name: "_models.AttachedDatabaseConfigurationsCheckNameRequest", + resource_name: Union[_models.AttachedDatabaseConfigurationsCheckNameRequest, IO], **kwargs: Any - ) -> "_models.CheckNameResult": + ) -> _models.CheckNameResult: """Checks that the attached database configuration resource name is valid and is not already in use. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param resource_name: The name of the resource. - :type resource_name: - ~kusto_management_client.models.AttachedDatabaseConfigurationsCheckNameRequest + :param resource_name: The name of the resource. Is either a model type or a IO type. Required. + :type resource_name: ~azure.mgmt.kusto.models.AttachedDatabaseConfigurationsCheckNameRequest 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: CheckNameResult, or the result of cls(response) - :rtype: ~kusto_management_client.models.CheckNameResult - :raises: ~azure.core.exceptions.HttpResponseError + :return: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameResult] - _json = self._serialize.body(resource_name, 'AttachedDatabaseConfigurationsCheckNameRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource_name, (IO, bytes)): + _content = resource_name + else: + _json = self._serialize.body(resource_name, "AttachedDatabaseConfigurationsCheckNameRequest") request = build_check_name_availability_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, - template_url=self.check_name_availability.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameResult', pipeline_response) + deserialized = self._deserialize("CheckNameResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurationCheckNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurationCheckNameAvailability"} # type: ignore @distributed_trace def list_by_cluster( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> Iterable["_models.AttachedDatabaseConfigurationListResult"]: + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.AttachedDatabaseConfiguration"]: """Returns the list of attached database configurations of the given Kusto cluster. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto 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 AttachedDatabaseConfigurationListResult or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~kusto_management_client.models.AttachedDatabaseConfigurationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either AttachedDatabaseConfiguration or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kusto.models.AttachedDatabaseConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AttachedDatabaseConfigurationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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.AttachedDatabaseConfigurationListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_cluster_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, - template_url=self.list_by_cluster.metadata['url'], + 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) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_cluster_request( - resource_group_name=resource_group_name, - cluster_name=cluster_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -370,7 +448,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -379,98 +459,126 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_cluster.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations'} # type: ignore + list_by_cluster.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - cluster_name: str, - attached_database_configuration_name: str, - **kwargs: Any - ) -> "_models.AttachedDatabaseConfiguration": + self, resource_group_name: str, cluster_name: str, attached_database_configuration_name: str, **kwargs: Any + ) -> _models.AttachedDatabaseConfiguration: """Returns an attached database configuration. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str :param attached_database_configuration_name: The name of the attached database configuration. + Required. :type attached_database_configuration_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AttachedDatabaseConfiguration, or the result of cls(response) - :rtype: ~kusto_management_client.models.AttachedDatabaseConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :return: AttachedDatabaseConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.AttachedDatabaseConfiguration + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AttachedDatabaseConfiguration"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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.AttachedDatabaseConfiguration] - request = build_get_request( resource_group_name=resource_group_name, cluster_name=cluster_name, attached_database_configuration_name=attached_database_configuration_name, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AttachedDatabaseConfiguration', pipeline_response) + deserialized = self._deserialize("AttachedDatabaseConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, cluster_name: str, attached_database_configuration_name: str, - parameters: "_models.AttachedDatabaseConfiguration", + parameters: Union[_models.AttachedDatabaseConfiguration, IO], **kwargs: Any - ) -> "_models.AttachedDatabaseConfiguration": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AttachedDatabaseConfiguration"] + ) -> _models.AttachedDatabaseConfiguration: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'AttachedDatabaseConfiguration') + 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.AttachedDatabaseConfiguration] - request = build_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AttachedDatabaseConfiguration") + + request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, attached_database_configuration_name=attached_database_configuration_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -478,21 +586,100 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('AttachedDatabaseConfiguration', pipeline_response) + deserialized = self._deserialize("AttachedDatabaseConfiguration", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AttachedDatabaseConfiguration', pipeline_response) + deserialized = self._deserialize("AttachedDatabaseConfiguration", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AttachedDatabaseConfiguration', pipeline_response) + deserialized = self._deserialize("AttachedDatabaseConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + attached_database_configuration_name: str, + parameters: _models.AttachedDatabaseConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AttachedDatabaseConfiguration]: + """Creates or updates an attached database configuration. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param attached_database_configuration_name: The name of the attached database configuration. + Required. + :type attached_database_configuration_name: str + :param parameters: The database parameters supplied to the CreateOrUpdate operation. Required. + :type parameters: ~azure.mgmt.kusto.models.AttachedDatabaseConfiguration + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AttachedDatabaseConfiguration or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.AttachedDatabaseConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + attached_database_configuration_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AttachedDatabaseConfiguration]: + """Creates or updates an attached database configuration. + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param attached_database_configuration_name: The name of the attached database configuration. + Required. + :type attached_database_configuration_name: str + :param parameters: The database parameters supplied to the CreateOrUpdate 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 AttachedDatabaseConfiguration or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.AttachedDatabaseConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -500,19 +687,25 @@ def begin_create_or_update( resource_group_name: str, cluster_name: str, attached_database_configuration_name: str, - parameters: "_models.AttachedDatabaseConfiguration", + parameters: Union[_models.AttachedDatabaseConfiguration, IO], **kwargs: Any - ) -> LROPoller["_models.AttachedDatabaseConfiguration"]: + ) -> LROPoller[_models.AttachedDatabaseConfiguration]: """Creates or updates an attached database configuration. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str :param attached_database_configuration_name: The name of the attached database configuration. + Required. :type attached_database_configuration_name: str - :param parameters: The database parameters supplied to the CreateOrUpdate operation. - :type parameters: ~kusto_management_client.models.AttachedDatabaseConfiguration + :param parameters: The database parameters supplied to the CreateOrUpdate operation. Is either + a model type or a IO type. Required. + :type parameters: ~azure.mgmt.kusto.models.AttachedDatabaseConfiguration 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 @@ -523,78 +716,90 @@ def begin_create_or_update( Retry-After header is present. :return: An instance of LROPoller that returns either AttachedDatabaseConfiguration or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~kusto_management_client.models.AttachedDatabaseConfiguration] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.AttachedDatabaseConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AttachedDatabaseConfiguration"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AttachedDatabaseConfiguration] + 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, attached_database_configuration_name=attached_database_configuration_name, parameters=parameters, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AttachedDatabaseConfiguration', pipeline_response) + deserialized = self._deserialize("AttachedDatabaseConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}"} # type: ignore - def _delete_initial( - self, - resource_group_name: str, - cluster_name: str, - attached_database_configuration_name: str, - **kwargs: Any + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, cluster_name: str, attached_database_configuration_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', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_delete_request_initial( + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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, attached_database_configuration_name=attached_database_configuration_name, subscription_id=self._config.subscription_id, - template_url=self._delete_initial.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -604,24 +809,21 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}"} # type: ignore @distributed_trace def begin_delete( - self, - resource_group_name: str, - cluster_name: str, - attached_database_configuration_name: str, - **kwargs: Any + self, resource_group_name: str, cluster_name: str, attached_database_configuration_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes the attached database configuration with the given name. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str :param attached_database_configuration_name: The name of the attached database configuration. + Required. :type attached_database_configuration_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. @@ -633,41 +835,46 @@ def begin_delete( Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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, attached_database_configuration_name=attached_database_configuration_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) - 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, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}"} # type: ignore diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_cluster_principal_assignments_operations.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_cluster_principal_assignments_operations.py index 36a4aaa8ab2e..cbaea8224e98 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_cluster_principal_assignments_operations.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_cluster_principal_assignments_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,396 +6,475 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse 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 msrest import Serializer from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_check_name_availability_request( - resource_group_name: str, - cluster_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2022-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/checkPrincipalAssignmentNameAvailability') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/checkPrincipalAssignmentNameAvailability", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "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"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - cluster_name: str, - principal_assignment_name: str, - **kwargs: Any + resource_group_name: str, cluster_name: str, principal_assignment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments/{principalAssignmentName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments/{principalAssignmentName}", + ) # 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'), - "principalAssignmentName": _SERIALIZER.url("principal_assignment_name", principal_assignment_name, 'str'), + "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"), + "principalAssignmentName": _SERIALIZER.url("principal_assignment_name", principal_assignment_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - cluster_name: str, - principal_assignment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _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, principal_assignment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2022-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments/{principalAssignmentName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments/{principalAssignmentName}", + ) # 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'), - "principalAssignmentName": _SERIALIZER.url("principal_assignment_name", principal_assignment_name, 'str'), + "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"), + "principalAssignmentName": _SERIALIZER.url("principal_assignment_name", principal_assignment_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - cluster_name: str, - principal_assignment_name: str, - **kwargs: Any + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, cluster_name: str, principal_assignment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments/{principalAssignmentName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments/{principalAssignmentName}", + ) # 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'), - "principalAssignmentName": _SERIALIZER.url("principal_assignment_name", principal_assignment_name, 'str'), + "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"), + "principalAssignmentName": _SERIALIZER.url("principal_assignment_name", principal_assignment_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_list_request( - subscription_id: str, - resource_group_name: str, - cluster_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +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", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments", + ) # 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'), + "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) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class ClusterPrincipalAssignmentsOperations(object): - """ClusterPrincipalAssignmentsOperations 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: ~kusto_management_client.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. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ClusterPrincipalAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kusto.KustoManagementClient`'s + :attr:`cluster_principal_assignments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + def check_name_availability( + self, + resource_group_name: str, + cluster_name: str, + principal_assignment_name: _models.ClusterPrincipalAssignmentCheckNameRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the principal assignment name is valid and is not already in use. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param principal_assignment_name: The name of the principal assignment. Required. + :type principal_assignment_name: + ~azure.mgmt.kusto.models.ClusterPrincipalAssignmentCheckNameRequest + :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: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, + resource_group_name: str, + cluster_name: str, + principal_assignment_name: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the principal assignment name is valid and is not already in use. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param principal_assignment_name: The name of the principal assignment. Required. + :type principal_assignment_name: 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: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def check_name_availability( self, resource_group_name: str, cluster_name: str, - principal_assignment_name: "_models.ClusterPrincipalAssignmentCheckNameRequest", + principal_assignment_name: Union[_models.ClusterPrincipalAssignmentCheckNameRequest, IO], **kwargs: Any - ) -> "_models.CheckNameResult": + ) -> _models.CheckNameResult: """Checks that the principal assignment name is valid and is not already in use. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param principal_assignment_name: The name of the principal assignment. + :param principal_assignment_name: The name of the principal assignment. Is either a model type + or a IO type. Required. :type principal_assignment_name: - ~kusto_management_client.models.ClusterPrincipalAssignmentCheckNameRequest + ~azure.mgmt.kusto.models.ClusterPrincipalAssignmentCheckNameRequest 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: CheckNameResult, or the result of cls(response) - :rtype: ~kusto_management_client.models.CheckNameResult - :raises: ~azure.core.exceptions.HttpResponseError + :return: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(principal_assignment_name, 'ClusterPrincipalAssignmentCheckNameRequest') + 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.CheckNameResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(principal_assignment_name, (IO, bytes)): + _content = principal_assignment_name + else: + _json = self._serialize.body(principal_assignment_name, "ClusterPrincipalAssignmentCheckNameRequest") request = build_check_name_availability_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, - template_url=self.check_name_availability.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameResult', pipeline_response) + deserialized = self._deserialize("CheckNameResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/checkPrincipalAssignmentNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/checkPrincipalAssignmentNameAvailability"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - cluster_name: str, - principal_assignment_name: str, - **kwargs: Any - ) -> "_models.ClusterPrincipalAssignment": + self, resource_group_name: str, cluster_name: str, principal_assignment_name: str, **kwargs: Any + ) -> _models.ClusterPrincipalAssignment: """Gets a Kusto cluster principalAssignment. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param principal_assignment_name: The name of the Kusto principalAssignment. + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. :type principal_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ClusterPrincipalAssignment, or the result of cls(response) - :rtype: ~kusto_management_client.models.ClusterPrincipalAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :return: ClusterPrincipalAssignment or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.ClusterPrincipalAssignment + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterPrincipalAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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.ClusterPrincipalAssignment] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, principal_assignment_name=principal_assignment_name, - template_url=self.get.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ClusterPrincipalAssignment', pipeline_response) + deserialized = self._deserialize("ClusterPrincipalAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments/{principalAssignmentName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments/{principalAssignmentName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, cluster_name: str, principal_assignment_name: str, - parameters: "_models.ClusterPrincipalAssignment", + parameters: Union[_models.ClusterPrincipalAssignment, IO], **kwargs: Any - ) -> "_models.ClusterPrincipalAssignment": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterPrincipalAssignment"] + ) -> _models.ClusterPrincipalAssignment: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ClusterPrincipalAssignment') + 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.ClusterPrincipalAssignment] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ClusterPrincipalAssignment") + + request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, principal_assignment_name=principal_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -402,18 +482,97 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ClusterPrincipalAssignment', pipeline_response) + deserialized = self._deserialize("ClusterPrincipalAssignment", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ClusterPrincipalAssignment', pipeline_response) + deserialized = self._deserialize("ClusterPrincipalAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments/{principalAssignmentName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments/{principalAssignmentName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + principal_assignment_name: str, + parameters: _models.ClusterPrincipalAssignment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ClusterPrincipalAssignment]: + """Create a Kusto cluster principalAssignment. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. + :type principal_assignment_name: str + :param parameters: The Kusto cluster principalAssignment's parameters supplied for the + operation. Required. + :type parameters: ~azure.mgmt.kusto.models.ClusterPrincipalAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ClusterPrincipalAssignment or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.ClusterPrincipalAssignment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + principal_assignment_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ClusterPrincipalAssignment]: + """Create a Kusto cluster principalAssignment. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. + :type principal_assignment_name: str + :param parameters: The Kusto cluster principalAssignment's parameters supplied for the + 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 ClusterPrincipalAssignment or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.ClusterPrincipalAssignment] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -421,20 +580,24 @@ def begin_create_or_update( resource_group_name: str, cluster_name: str, principal_assignment_name: str, - parameters: "_models.ClusterPrincipalAssignment", + parameters: Union[_models.ClusterPrincipalAssignment, IO], **kwargs: Any - ) -> LROPoller["_models.ClusterPrincipalAssignment"]: + ) -> LROPoller[_models.ClusterPrincipalAssignment]: """Create a Kusto cluster principalAssignment. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param principal_assignment_name: The name of the Kusto principalAssignment. + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. :type principal_assignment_name: str :param parameters: The Kusto cluster principalAssignment's parameters supplied for the - operation. - :type parameters: ~kusto_management_client.models.ClusterPrincipalAssignment + operation. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.kusto.models.ClusterPrincipalAssignment 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 @@ -445,78 +608,90 @@ def begin_create_or_update( Retry-After header is present. :return: An instance of LROPoller that returns either ClusterPrincipalAssignment or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~kusto_management_client.models.ClusterPrincipalAssignment] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.ClusterPrincipalAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterPrincipalAssignment"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ClusterPrincipalAssignment] + 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, principal_assignment_name=principal_assignment_name, parameters=parameters, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ClusterPrincipalAssignment', pipeline_response) + deserialized = self._deserialize("ClusterPrincipalAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments/{principalAssignmentName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments/{principalAssignmentName}"} # type: ignore - def _delete_initial( - self, - resource_group_name: str, - cluster_name: str, - principal_assignment_name: str, - **kwargs: Any + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, cluster_name: str, principal_assignment_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', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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, principal_assignment_name=principal_assignment_name, - template_url=self._delete_initial.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -526,24 +701,20 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments/{principalAssignmentName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments/{principalAssignmentName}"} # type: ignore @distributed_trace def begin_delete( - self, - resource_group_name: str, - cluster_name: str, - principal_assignment_name: str, - **kwargs: Any + self, resource_group_name: str, cluster_name: str, principal_assignment_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a Kusto cluster principalAssignment. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param principal_assignment_name: The name of the Kusto principalAssignment. + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. :type principal_assignment_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. @@ -555,92 +726,104 @@ def begin_delete( Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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, principal_assignment_name=principal_assignment_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) - 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, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments/{principalAssignmentName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments/{principalAssignmentName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> Iterable["_models.ClusterPrincipalAssignmentListResult"]: + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.ClusterPrincipalAssignment"]: """Lists all Kusto cluster principalAssignments. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto 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 ClusterPrincipalAssignmentListResult or the result - of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~kusto_management_client.models.ClusterPrincipalAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ClusterPrincipalAssignment or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kusto.models.ClusterPrincipalAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterPrincipalAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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.ClusterPrincipalAssignmentListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_name=cluster_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -654,7 +837,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -663,8 +848,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments"} # type: ignore diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_clusters_operations.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_clusters_operations.py index 149036927b99..76976d07f14a 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_clusters_operations.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_clusters_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,816 +6,733 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse 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 msrest import Serializer from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - resource_group_name: str, - cluster_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + +def build_get_request(resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "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"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( +def build_create_or_update_request( resource_group_name: str, cluster_name: str, subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2022-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "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"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if if_none_match is not None: - header_parameters['If-None-Match'] = _SERIALIZER.header("if_none_match", if_none_match, 'str') + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( - resource_group_name: str, - cluster_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - if_match: Optional[str] = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, cluster_name: str, subscription_id: str, *, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2022-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "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"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - resource_group_name: str, - cluster_name: str, - subscription_id: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "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"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_stop_request_initial( - resource_group_name: str, - cluster_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" +def build_stop_request(resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/stop') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/stop", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "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"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_start_request_initial( - resource_group_name: str, - cluster_name: str, - subscription_id: str, - **kwargs: Any +def build_start_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/start') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/start", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "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"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_follower_databases_request( - resource_group_name: str, - cluster_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/listFollowerDatabases') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/listFollowerDatabases", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "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"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_detach_follower_databases_request_initial( - resource_group_name: str, - cluster_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_detach_follower_databases_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2022-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/detachFollowerDatabases') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/detachFollowerDatabases", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "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"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_diagnose_virtual_network_request_initial( - resource_group_name: str, - cluster_name: str, - subscription_id: str, - **kwargs: Any +def build_diagnose_virtual_network_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/diagnoseVirtualNetwork') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/diagnoseVirtualNetwork", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "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"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/clusters') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/clusters") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_skus_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" +def build_list_skus_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/skus') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/skus") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_check_name_availability_request( - subscription_id: str, - location: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] +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", "2022-07-07")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2022-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/locations/{location}/checkNameAvailability') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/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'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_skus_by_resource_request( - resource_group_name: str, - cluster_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/skus') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/skus", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "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"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_outbound_network_dependencies_endpoints_request( - subscription_id: str, - resource_group_name: str, - cluster_name: str, - **kwargs: Any + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/outboundNetworkDependenciesEndpoints') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/outboundNetworkDependenciesEndpoints", + ) # 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'), + "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) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_language_extensions_request( - subscription_id: str, - resource_group_name: str, - cluster_name: str, - **kwargs: Any + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/listLanguageExtensions') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/listLanguageExtensions", + ) # 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'), + "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) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_add_language_extensions_request_initial( - subscription_id: str, - resource_group_name: str, - cluster_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_add_language_extensions_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2022-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/addLanguageExtensions') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/addLanguageExtensions", + ) # 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'), + "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) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_remove_language_extensions_request_initial( - subscription_id: str, - resource_group_name: str, - cluster_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_remove_language_extensions_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2022-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/removeLanguageExtensions') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/removeLanguageExtensions", + ) # 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'), + "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) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - -class ClustersOperations(object): - """ClustersOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~kusto_management_client.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. + _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.kusto.KustoManagementClient`'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") @distributed_trace - def get( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> "_models.Cluster": + def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> _models.Cluster: """Gets a Kusto cluster. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto 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) - :rtype: ~kusto_management_client.models.Cluster - :raises: ~azure.core.exceptions.HttpResponseError + :return: Cluster or the result of cls(response) + :rtype: ~azure.mgmt.kusto.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', {})) + 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, - template_url=self.get.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Cluster', pipeline_response) + deserialized = self._deserialize("Cluster", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, cluster_name: str, - parameters: "_models.Cluster", + parameters: Union[_models.Cluster, IO], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **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', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Cluster] - _json = self._serialize.body(parameters, '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, "Cluster") - request = build_create_or_update_request_initial( + request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, - content_type=content_type, - json=_json, if_match=if_match, if_none_match=if_none_match, - template_url=self._create_or_update_initial.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -822,44 +740,97 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Cluster', pipeline_response) + deserialized = self._deserialize("Cluster", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Cluster', pipeline_response) + deserialized = self._deserialize("Cluster", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + parameters: _models.Cluster, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Cluster]: + """Create or update a Kusto cluster. - @distributed_trace + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param parameters: The Kusto cluster parameters supplied to the CreateOrUpdate operation. + Required. + :type parameters: ~azure.mgmt.kusto.models.Cluster + :param if_match: The ETag of the cluster. Omit this value to always overwrite the current + cluster. Specify the last-seen ETag value to prevent accidentally overwriting concurrent + changes. Default value is None. + :type if_match: str + :param if_none_match: Set to '*' to allow a new cluster to be created, but to prevent updating + an existing cluster. Other values will result in a 412 Pre-condition Failed response. Default + value is None. + :type if_none_match: 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. + :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.kusto.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload def begin_create_or_update( self, resource_group_name: str, cluster_name: str, - parameters: "_models.Cluster", + parameters: IO, if_match: Optional[str] = None, if_none_match: Optional[str] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.Cluster"]: + ) -> LROPoller[_models.Cluster]: """Create or update a Kusto cluster. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str :param parameters: The Kusto cluster parameters supplied to the CreateOrUpdate operation. - :type parameters: ~kusto_management_client.models.Cluster + Required. + :type parameters: IO :param if_match: The ETag of the cluster. Omit this value to always overwrite the current cluster. Specify the last-seen ETag value to prevent accidentally overwriting concurrent - changes. + changes. Default value is None. :type if_match: str :param if_none_match: Set to '*' to allow a new cluster to be created, but to prevent updating - an existing cluster. Other values will result in a 412 Pre-condition Failed response. + an existing cluster. Other values will result in a 412 Pre-condition Failed response. Default + value is None. :type if_none_match: str + :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 @@ -869,84 +840,152 @@ def begin_create_or_update( :keyword int polling_interval: 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[~kusto_management_client.models.Cluster] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Cluster"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + parameters: Union[_models.Cluster, IO], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[_models.Cluster]: + """Create or update a Kusto cluster. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param parameters: The Kusto cluster parameters supplied to the CreateOrUpdate operation. Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.kusto.models.Cluster or IO + :param if_match: The ETag of the cluster. Omit this value to always overwrite the current + cluster. Specify the last-seen ETag value to prevent accidentally overwriting concurrent + changes. Default value is None. + :type if_match: str + :param if_none_match: Set to '*' to allow a new cluster to be created, but to prevent updating + an existing cluster. Other values will result in a 412 Pre-condition Failed response. Default + value is None. + :type if_none_match: str + :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.kusto.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Cluster] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, parameters=parameters, if_match=if_match, if_none_match=if_none_match, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('Cluster', pipeline_response) + deserialized = self._deserialize("Cluster", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}"} # type: ignore def _update_initial( self, resource_group_name: str, cluster_name: str, - parameters: "_models.ClusterUpdate", + parameters: Union[_models.ClusterUpdate, IO], if_match: Optional[str] = None, **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', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Cluster] - _json = self._serialize.body(parameters, 'ClusterUpdate') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ClusterUpdate") - request = build_update_request_initial( + request = build_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self._update_initial.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -955,47 +994,135 @@ def _update_initial( response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('Cluster', pipeline_response) + deserialized = self._deserialize("Cluster", pipeline_response) if response.status_code == 201: - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - - deserialized = self._deserialize('Cluster', pipeline_response) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Cluster", pipeline_response) if response.status_code == 202: - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - - deserialized = self._deserialize('Cluster', pipeline_response) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Cluster", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + cluster_name: str, + parameters: _models.ClusterUpdate, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Cluster]: + """Update a Kusto cluster. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param parameters: The Kusto cluster parameters supplied to the Update operation. Required. + :type parameters: ~azure.mgmt.kusto.models.ClusterUpdate + :param if_match: The ETag of the cluster. Omit this value to always overwrite the current + cluster. Specify the last-seen ETag value to prevent accidentally overwriting concurrent + changes. Default value is None. + :type if_match: 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. + :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.kusto.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + cluster_name: str, + parameters: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Cluster]: + """Update a Kusto cluster. + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param parameters: The Kusto cluster parameters supplied to the Update operation. Required. + :type parameters: IO + :param if_match: The ETag of the cluster. Omit this value to always overwrite the current + cluster. Specify the last-seen ETag value to prevent accidentally overwriting concurrent + changes. Default value is None. + :type if_match: str + :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.kusto.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( self, resource_group_name: str, cluster_name: str, - parameters: "_models.ClusterUpdate", + parameters: Union[_models.ClusterUpdate, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> LROPoller["_models.Cluster"]: + ) -> LROPoller[_models.Cluster]: """Update a Kusto cluster. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param parameters: The Kusto cluster parameters supplied to the Update operation. - :type parameters: ~kusto_management_client.models.ClusterUpdate + :param parameters: The Kusto cluster parameters supplied to the Update operation. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.kusto.models.ClusterUpdate or IO :param if_match: The ETag of the cluster. Omit this value to always overwrite the current cluster. Specify the last-seen ETag value to prevent accidentally overwriting concurrent - changes. + changes. Default value is None. :type if_match: str + :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 @@ -1005,75 +1132,89 @@ def begin_update( :keyword int polling_interval: 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[~kusto_management_client.models.Cluster] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Cluster"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Cluster] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, parameters=parameters, if_match=if_match, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('Cluster', pipeline_response) + deserialized = self._deserialize("Cluster", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}"} # type: ignore - def _delete_initial( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any + 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 + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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_initial( + request = build_delete_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, - template_url=self._delete_initial.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -1083,21 +1224,16 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}"} # type: ignore @distributed_trace - def begin_delete( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a Kusto cluster. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto 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. @@ -1109,67 +1245,82 @@ def begin_delete( Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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) - 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, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}"} # type: ignore - def _stop_initial( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any + def _stop_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 + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_stop_request_initial( + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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_stop_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, - template_url=self._stop_initial.metadata['url'], + api_version=api_version, + template_url=self._stop_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1179,21 +1330,16 @@ def _stop_initial( if cls: return cls(pipeline_response, None, {}) - _stop_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/stop'} # type: ignore - + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/stop"} # type: ignore @distributed_trace - def begin_stop( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_stop(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> LROPoller[None]: """Stops a Kusto cluster. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto 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. @@ -1205,67 +1351,82 @@ def begin_stop( Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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._stop_initial( + raw_result = self._stop_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) - 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, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_stop.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/stop'} # type: ignore + begin_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/stop"} # type: ignore - def _start_initial( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any + def _start_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 + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_start_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_start_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, - template_url=self._start_initial.metadata['url'], + api_version=api_version, + template_url=self._start_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1275,21 +1436,16 @@ def _start_initial( if cls: return cls(pipeline_response, None, {}) - _start_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/start'} # type: ignore - + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/start"} # type: ignore @distributed_trace - def begin_start( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_start(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> LROPoller[None]: """Starts a Kusto cluster. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto 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. @@ -1301,92 +1457,104 @@ def begin_start( Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, 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) - 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, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/start'} # type: ignore + begin_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/start"} # type: ignore @distributed_trace def list_follower_databases( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> Iterable["_models.FollowerDatabaseListResult"]: + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.FollowerDatabaseDefinition"]: """Returns a list of databases that are owned by this cluster and were followed by another cluster. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto 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 FollowerDatabaseListResult or the result of + :return: An iterator like instance of either FollowerDatabaseDefinition or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~kusto_management_client.models.FollowerDatabaseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kusto.models.FollowerDatabaseDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FollowerDatabaseListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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.FollowerDatabaseListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_follower_databases_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, - template_url=self.list_follower_databases.metadata['url'], + api_version=api_version, + template_url=self.list_follower_databases.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_follower_databases_request( - resource_group_name=resource_group_name, - cluster_name=cluster_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1400,7 +1568,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1409,41 +1579,59 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_follower_databases.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/listFollowerDatabases'} # type: ignore + list_follower_databases.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/listFollowerDatabases"} # type: ignore - def _detach_follower_databases_initial( + def _detach_follower_databases_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, - follower_database_to_remove: "_models.FollowerDatabaseDefinition", + follower_database_to_remove: Union[_models.FollowerDatabaseDefinition, 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', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(follower_database_to_remove, 'FollowerDatabaseDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(follower_database_to_remove, (IO, bytes)): + _content = follower_database_to_remove + else: + _json = self._serialize.body(follower_database_to_remove, "FollowerDatabaseDefinition") - request = build_detach_follower_databases_request_initial( + request = build_detach_follower_databases_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, - template_url=self._detach_follower_databases_initial.metadata['url'], + content=_content, + template_url=self._detach_follower_databases_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1453,25 +1641,99 @@ def _detach_follower_databases_initial( if cls: return cls(pipeline_response, None, {}) - _detach_follower_databases_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/detachFollowerDatabases'} # type: ignore + _detach_follower_databases_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/detachFollowerDatabases"} # type: ignore + @overload + def begin_detach_follower_databases( + self, + resource_group_name: str, + cluster_name: str, + follower_database_to_remove: _models.FollowerDatabaseDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Detaches all followers of a database owned by this cluster. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param follower_database_to_remove: The follower databases properties to remove. Required. + :type follower_database_to_remove: ~azure.mgmt.kusto.models.FollowerDatabaseDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_detach_follower_databases( + self, + resource_group_name: str, + cluster_name: str, + follower_database_to_remove: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Detaches all followers of a database owned by this cluster. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param follower_database_to_remove: The follower databases properties to remove. Required. + :type follower_database_to_remove: 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_detach_follower_databases( self, resource_group_name: str, cluster_name: str, - follower_database_to_remove: "_models.FollowerDatabaseDefinition", + follower_database_to_remove: Union[_models.FollowerDatabaseDefinition, IO], **kwargs: Any ) -> LROPoller[None]: """Detaches all followers of a database owned by this cluster. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param follower_database_to_remove: The follower databases properties to remove. - :type follower_database_to_remove: ~kusto_management_client.models.FollowerDatabaseDefinition + :param follower_database_to_remove: The follower databases properties to remove. Is either a + model type or a IO type. Required. + :type follower_database_to_remove: ~azure.mgmt.kusto.models.FollowerDatabaseDefinition 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 @@ -1482,70 +1744,85 @@ def begin_detach_follower_databases( Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[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._detach_follower_databases_initial( + raw_result = self._detach_follower_databases_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, follower_database_to_remove=follower_database_to_remove, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", 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, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_detach_follower_databases.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/detachFollowerDatabases'} # type: ignore + begin_detach_follower_databases.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/detachFollowerDatabases"} # type: ignore def _diagnose_virtual_network_initial( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> Optional["_models.DiagnoseVirtualNetworkResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DiagnoseVirtualNetworkResult"]] + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> Optional[_models.DiagnoseVirtualNetworkResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_diagnose_virtual_network_request_initial( + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DiagnoseVirtualNetworkResult]] + + request = build_diagnose_virtual_network_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, - template_url=self._diagnose_virtual_network_initial.metadata['url'], + api_version=api_version, + template_url=self._diagnose_virtual_network_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1554,29 +1831,26 @@ def _diagnose_virtual_network_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DiagnoseVirtualNetworkResult', pipeline_response) + deserialized = self._deserialize("DiagnoseVirtualNetworkResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _diagnose_virtual_network_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/diagnoseVirtualNetwork'} # type: ignore - + _diagnose_virtual_network_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/diagnoseVirtualNetwork"} # type: ignore @distributed_trace def begin_diagnose_virtual_network( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> LROPoller["_models.DiagnoseVirtualNetworkResult"]: + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> LROPoller[_models.DiagnoseVirtualNetworkResult]: """Diagnoses network connectivity status for external resources on which the service is dependent on. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto 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. @@ -1588,89 +1862,102 @@ def begin_diagnose_virtual_network( Retry-After header is present. :return: An instance of LROPoller that returns either DiagnoseVirtualNetworkResult or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~kusto_management_client.models.DiagnoseVirtualNetworkResult] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.DiagnoseVirtualNetworkResult] + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnoseVirtualNetworkResult"] - 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[_models.DiagnoseVirtualNetworkResult] + 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._diagnose_virtual_network_initial( + raw_result = self._diagnose_virtual_network_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) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DiagnoseVirtualNetworkResult', pipeline_response) + deserialized = self._deserialize("DiagnoseVirtualNetworkResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **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) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_diagnose_virtual_network.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/diagnoseVirtualNetwork'} # type: ignore + begin_diagnose_virtual_network.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/diagnoseVirtualNetwork"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.ClusterListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Cluster"]: """Lists all Kusto clusters within a resource group. :param resource_group_name: The name of the resource group containing the Kusto cluster. + 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[~kusto_management_client.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.kusto.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', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, - template_url=self.list_by_resource_group.metadata['url'], + 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) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1684,7 +1971,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1693,47 +1982,54 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters'} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.ClusterListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Cluster"]: """Lists all Kusto clusters within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ClusterListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~kusto_management_client.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.kusto.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', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, - template_url=self.list.metadata['url'], + 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) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1747,7 +2043,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1756,47 +2054,54 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/clusters'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/clusters"} # type: ignore @distributed_trace - def list_skus( - self, - **kwargs: Any - ) -> Iterable["_models.SkuDescriptionList"]: + def list_skus(self, **kwargs: Any) -> Iterable["_models.SkuDescription"]: """Lists eligible SKUs for Kusto resource provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SkuDescriptionList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~kusto_management_client.models.SkuDescriptionList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SkuDescription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kusto.models.SkuDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SkuDescriptionList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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.SkuDescriptionList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_skus_request( subscription_id=self._config.subscription_id, - template_url=self.list_skus.metadata['url'], + api_version=api_version, + template_url=self.list_skus.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_skus_request( - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1810,7 +2115,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1819,113 +2126,180 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_skus.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/skus'} # type: ignore + list_skus.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/skus"} # type: ignore - @distributed_trace + @overload def check_name_availability( self, location: str, - cluster_name: "_models.ClusterCheckNameRequest", + cluster_name: _models.ClusterCheckNameRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CheckNameResult": + ) -> _models.CheckNameResult: + """Checks that the cluster name is valid and is not already in use. + + :param location: Azure location (region) name. Required. + :type location: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: ~azure.mgmt.kusto.models.ClusterCheckNameRequest + :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: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, location: str, cluster_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the cluster name is valid and is not already in use. + + :param location: Azure location (region) name. Required. + :type location: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: 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: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, location: str, cluster_name: Union[_models.ClusterCheckNameRequest, IO], **kwargs: Any + ) -> _models.CheckNameResult: """Checks that the cluster name is valid and is not already in use. - :param location: Azure location (region) name. + :param location: Azure location (region) name. Required. :type location: str - :param cluster_name: The name of the cluster. - :type cluster_name: ~kusto_management_client.models.ClusterCheckNameRequest + :param cluster_name: The name of the cluster. Is either a model type or a IO type. Required. + :type cluster_name: ~azure.mgmt.kusto.models.ClusterCheckNameRequest 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: CheckNameResult, or the result of cls(response) - :rtype: ~kusto_management_client.models.CheckNameResult - :raises: ~azure.core.exceptions.HttpResponseError + :return: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(cluster_name, 'ClusterCheckNameRequest') + 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.CheckNameResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(cluster_name, (IO, bytes)): + _content = cluster_name + else: + _json = self._serialize.body(cluster_name, "ClusterCheckNameRequest") request = build_check_name_availability_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameResult', pipeline_response) + deserialized = self._deserialize("CheckNameResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/locations/{location}/checkNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/locations/{location}/checkNameAvailability"} # type: ignore @distributed_trace def list_skus_by_resource( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> Iterable["_models.ListResourceSkusResult"]: + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.AzureResourceSku"]: """Returns the SKUs available for the provided resource. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto 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 ListResourceSkusResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~kusto_management_client.models.ListResourceSkusResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either AzureResourceSku or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kusto.models.AzureResourceSku] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListResourceSkusResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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.ListResourceSkusResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_skus_by_resource_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, - template_url=self.list_skus_by_resource.metadata['url'], + api_version=api_version, + template_url=self.list_skus_by_resource.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_skus_by_resource_request( - resource_group_name=resource_group_name, - cluster_name=cluster_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1939,7 +2313,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1948,59 +2324,65 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_skus_by_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/skus'} # type: ignore + list_skus_by_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/skus"} # type: ignore @distributed_trace def list_outbound_network_dependencies_endpoints( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> Iterable["_models.OutboundNetworkDependenciesEndpointListResult"]: + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.OutboundNetworkDependenciesEndpoint"]: """Gets the network endpoints of all outbound dependencies of a Kusto cluster. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto 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 OutboundNetworkDependenciesEndpointListResult or - the result of cls(response) + :return: An iterator like instance of either OutboundNetworkDependenciesEndpoint or the result + of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~kusto_management_client.models.OutboundNetworkDependenciesEndpointListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.kusto.models.OutboundNetworkDependenciesEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OutboundNetworkDependenciesEndpointListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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.OutboundNetworkDependenciesEndpointListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_outbound_network_dependencies_endpoints_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, - template_url=self.list_outbound_network_dependencies_endpoints.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_outbound_network_dependencies_endpoints.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_outbound_network_dependencies_endpoints_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_name=cluster_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2014,7 +2396,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2023,58 +2407,63 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_outbound_network_dependencies_endpoints.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/outboundNetworkDependenciesEndpoints'} # type: ignore + list_outbound_network_dependencies_endpoints.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/outboundNetworkDependenciesEndpoints"} # type: ignore @distributed_trace def list_language_extensions( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> Iterable["_models.LanguageExtensionsList"]: + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.LanguageExtension"]: """Returns a list of language extensions that can run within KQL queries. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto 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 LanguageExtensionsList or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~kusto_management_client.models.LanguageExtensionsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either LanguageExtension or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kusto.models.LanguageExtension] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LanguageExtensionsList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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.LanguageExtensionsList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_language_extensions_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, - template_url=self.list_language_extensions.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_language_extensions.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_language_extensions_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_name=cluster_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2088,7 +2477,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -2097,41 +2488,59 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_language_extensions.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/listLanguageExtensions'} # type: ignore + list_language_extensions.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/listLanguageExtensions"} # type: ignore - def _add_language_extensions_initial( + def _add_language_extensions_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, - language_extensions_to_add: "_models.LanguageExtensionsList", + language_extensions_to_add: Union[_models.LanguageExtensionsList, 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', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(language_extensions_to_add, 'LanguageExtensionsList') + 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] - request = build_add_language_extensions_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(language_extensions_to_add, (IO, bytes)): + _content = language_extensions_to_add + else: + _json = self._serialize.body(language_extensions_to_add, "LanguageExtensionsList") + + request = build_add_language_extensions_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, - template_url=self._add_language_extensions_initial.metadata['url'], + content=_content, + template_url=self._add_language_extensions_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2141,25 +2550,99 @@ def _add_language_extensions_initial( if cls: return cls(pipeline_response, None, {}) - _add_language_extensions_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/addLanguageExtensions'} # type: ignore + _add_language_extensions_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/addLanguageExtensions"} # type: ignore + + @overload + def begin_add_language_extensions( + self, + resource_group_name: str, + cluster_name: str, + language_extensions_to_add: _models.LanguageExtensionsList, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Add a list of language extensions that can run within KQL queries. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param language_extensions_to_add: The language extensions to add. Required. + :type language_extensions_to_add: ~azure.mgmt.kusto.models.LanguageExtensionsList + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_add_language_extensions( + self, + resource_group_name: str, + cluster_name: str, + language_extensions_to_add: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Add a list of language extensions that can run within KQL queries. + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param language_extensions_to_add: The language extensions to add. Required. + :type language_extensions_to_add: 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_add_language_extensions( self, resource_group_name: str, cluster_name: str, - language_extensions_to_add: "_models.LanguageExtensionsList", + language_extensions_to_add: Union[_models.LanguageExtensionsList, IO], **kwargs: Any ) -> LROPoller[None]: """Add a list of language extensions that can run within KQL queries. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param language_extensions_to_add: The language extensions to add. - :type language_extensions_to_add: ~kusto_management_client.models.LanguageExtensionsList + :param language_extensions_to_add: The language extensions to add. Is either a model type or a + IO type. Required. + :type language_extensions_to_add: ~azure.mgmt.kusto.models.LanguageExtensionsList 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 @@ -2170,76 +2653,101 @@ def begin_add_language_extensions( Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[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._add_language_extensions_initial( + raw_result = self._add_language_extensions_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, language_extensions_to_add=language_extensions_to_add, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", 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, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_add_language_extensions.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/addLanguageExtensions'} # type: ignore + begin_add_language_extensions.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/addLanguageExtensions"} # type: ignore - def _remove_language_extensions_initial( + def _remove_language_extensions_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, - language_extensions_to_remove: "_models.LanguageExtensionsList", + language_extensions_to_remove: Union[_models.LanguageExtensionsList, 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', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(language_extensions_to_remove, 'LanguageExtensionsList') + 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] - request = build_remove_language_extensions_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(language_extensions_to_remove, (IO, bytes)): + _content = language_extensions_to_remove + else: + _json = self._serialize.body(language_extensions_to_remove, "LanguageExtensionsList") + + request = build_remove_language_extensions_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, - template_url=self._remove_language_extensions_initial.metadata['url'], + content=_content, + template_url=self._remove_language_extensions_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -2249,25 +2757,99 @@ def _remove_language_extensions_initial( if cls: return cls(pipeline_response, None, {}) - _remove_language_extensions_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/removeLanguageExtensions'} # type: ignore + _remove_language_extensions_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/removeLanguageExtensions"} # type: ignore + + @overload + def begin_remove_language_extensions( + self, + resource_group_name: str, + cluster_name: str, + language_extensions_to_remove: _models.LanguageExtensionsList, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Remove a list of language extensions that can run within KQL queries. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param language_extensions_to_remove: The language extensions to remove. Required. + :type language_extensions_to_remove: ~azure.mgmt.kusto.models.LanguageExtensionsList + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_remove_language_extensions( + self, + resource_group_name: str, + cluster_name: str, + language_extensions_to_remove: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Remove a list of language extensions that can run within KQL queries. + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param language_extensions_to_remove: The language extensions to remove. Required. + :type language_extensions_to_remove: 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_remove_language_extensions( self, resource_group_name: str, cluster_name: str, - language_extensions_to_remove: "_models.LanguageExtensionsList", + language_extensions_to_remove: Union[_models.LanguageExtensionsList, IO], **kwargs: Any ) -> LROPoller[None]: """Remove a list of language extensions that can run within KQL queries. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param language_extensions_to_remove: The language extensions to remove. - :type language_extensions_to_remove: ~kusto_management_client.models.LanguageExtensionsList + :param language_extensions_to_remove: The language extensions to remove. Is either a model type + or a IO type. Required. + :type language_extensions_to_remove: ~azure.mgmt.kusto.models.LanguageExtensionsList 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 @@ -2278,43 +2860,48 @@ def begin_remove_language_extensions( Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[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._remove_language_extensions_initial( + raw_result = self._remove_language_extensions_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, language_extensions_to_remove=language_extensions_to_remove, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", 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, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_remove_language_extensions.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/removeLanguageExtensions'} # type: ignore + begin_remove_language_extensions.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/removeLanguageExtensions"} # type: ignore diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_data_connections_operations.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_data_connections_operations.py index 91cb375b9c78..38325818983d 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_data_connections_operations.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_data_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,157 +6,138 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse 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 msrest import Serializer from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +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_database_request( - resource_group_name: str, - cluster_name: str, - database_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, cluster_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), - "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"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_data_connection_validation_request_initial( - resource_group_name: str, - cluster_name: str, - database_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_data_connection_validation_request( + resource_group_name: str, cluster_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2022-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnectionValidation') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnectionValidation", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), - "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"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_check_name_availability_request( - resource_group_name: str, - cluster_name: str, - database_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, cluster_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2022-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/checkNameAvailability') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/checkNameAvailability", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), - "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"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -166,134 +148,119 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), - "dataConnectionName": _SERIALIZER.url("data_connection_name", data_connection_name, 'str'), - "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"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "dataConnectionName": _SERIALIZER.url("data_connection_name", data_connection_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( +def build_create_or_update_request( resource_group_name: str, cluster_name: str, database_name: str, data_connection_name: str, subscription_id: str, - *, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2022-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), - "dataConnectionName": _SERIALIZER.url("data_connection_name", data_connection_name, 'str'), - "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"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "dataConnectionName": _SERIALIZER.url("data_connection_name", data_connection_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( +def build_update_request( resource_group_name: str, cluster_name: str, database_name: str, data_connection_name: str, subscription_id: str, - *, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2022-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), - "dataConnectionName": _SERIALIZER.url("data_connection_name", data_connection_name, 'str'), - "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"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "dataConnectionName": _SERIALIZER.url("data_connection_name", data_connection_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( +def build_delete_request( resource_group_name: str, cluster_name: str, database_name: str, @@ -301,109 +268,111 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), - "dataConnectionName": _SERIALIZER.url("data_connection_name", data_connection_name, 'str'), - "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"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "dataConnectionName": _SERIALIZER.url("data_connection_name", data_connection_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class DataConnectionsOperations(object): - """DataConnectionsOperations 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: ~kusto_management_client.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. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class DataConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kusto.KustoManagementClient`'s + :attr:`data_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_database( - self, - resource_group_name: str, - cluster_name: str, - database_name: str, - **kwargs: Any - ) -> Iterable["_models.DataConnectionListResult"]: + self, resource_group_name: str, cluster_name: str, database_name: str, **kwargs: Any + ) -> Iterable["_models.DataConnection"]: """Returns the list of data connections of the given Kusto database. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataConnectionListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~kusto_management_client.models.DataConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataConnection or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kusto.models.DataConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataConnectionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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.DataConnectionListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_database_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, - template_url=self.list_by_database.metadata['url'], + api_version=api_version, + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_database_request( - resource_group_name=resource_group_name, - cluster_name=cluster_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -417,7 +386,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -426,43 +397,61 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections'} # type: ignore + list_by_database.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections"} # type: ignore def _data_connection_validation_initial( self, resource_group_name: str, cluster_name: str, database_name: str, - parameters: "_models.DataConnectionValidation", + parameters: Union[_models.DataConnectionValidation, IO], **kwargs: Any - ) -> Optional["_models.DataConnectionValidationListResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DataConnectionValidationListResult"]] + ) -> Optional[_models.DataConnectionValidationListResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'DataConnectionValidation') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DataConnectionValidationListResult]] - request = build_data_connection_validation_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataConnectionValidation") + + request = build_data_connection_validation_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._data_connection_validation_initial.metadata['url'], + content=_content, + template_url=self._data_connection_validation_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -471,35 +460,82 @@ def _data_connection_validation_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('DataConnectionValidationListResult', pipeline_response) + deserialized = self._deserialize("DataConnectionValidationListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _data_connection_validation_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnectionValidation'} # type: ignore + _data_connection_validation_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnectionValidation"} # type: ignore + @overload + def begin_data_connection_validation( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + parameters: _models.DataConnectionValidation, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DataConnectionValidationListResult]: + """Checks that the data connection parameters are valid. - @distributed_trace + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param parameters: The data connection parameters supplied to the CreateOrUpdate operation. + Required. + :type parameters: ~azure.mgmt.kusto.models.DataConnectionValidation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DataConnectionValidationListResult or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.DataConnectionValidationListResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload def begin_data_connection_validation( self, resource_group_name: str, cluster_name: str, database_name: str, - parameters: "_models.DataConnectionValidation", + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DataConnectionValidationListResult"]: + ) -> LROPoller[_models.DataConnectionValidationListResult]: """Checks that the data connection parameters are valid. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str :param parameters: The data connection parameters supplied to the CreateOrUpdate operation. - :type parameters: ~kusto_management_client.models.DataConnectionValidation + 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 @@ -511,51 +547,158 @@ def begin_data_connection_validation( :return: An instance of LROPoller that returns either DataConnectionValidationListResult or the result of cls(response) :rtype: - ~azure.core.polling.LROPoller[~kusto_management_client.models.DataConnectionValidationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.DataConnectionValidationListResult] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataConnectionValidationListResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @distributed_trace + def begin_data_connection_validation( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + parameters: Union[_models.DataConnectionValidation, IO], + **kwargs: Any + ) -> LROPoller[_models.DataConnectionValidationListResult]: + """Checks that the data connection parameters are valid. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param parameters: The data connection parameters supplied to the CreateOrUpdate operation. Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.kusto.models.DataConnectionValidation 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 DataConnectionValidationListResult or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.DataConnectionValidationListResult] + :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.DataConnectionValidationListResult] + 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._data_connection_validation_initial( + raw_result = self._data_connection_validation_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, parameters=parameters, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DataConnectionValidationListResult', pipeline_response) + deserialized = self._deserialize("DataConnectionValidationListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **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) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_data_connection_validation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnectionValidation'} # type: ignore + begin_data_connection_validation.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnectionValidation"} # type: ignore + + @overload + def check_name_availability( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + data_connection_name: _models.DataConnectionCheckNameRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the data connection name is valid and is not already in use. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param data_connection_name: The name of the data connection. Required. + :type data_connection_name: ~azure.mgmt.kusto.models.DataConnectionCheckNameRequest + :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: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + data_connection_name: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the data connection name is valid and is not already in use. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param data_connection_name: The name of the data connection. Required. + :type data_connection_name: 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: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def check_name_availability( @@ -563,121 +706,153 @@ def check_name_availability( resource_group_name: str, cluster_name: str, database_name: str, - data_connection_name: "_models.DataConnectionCheckNameRequest", + data_connection_name: Union[_models.DataConnectionCheckNameRequest, IO], **kwargs: Any - ) -> "_models.CheckNameResult": + ) -> _models.CheckNameResult: """Checks that the data connection name is valid and is not already in use. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str - :param data_connection_name: The name of the data connection. - :type data_connection_name: ~kusto_management_client.models.DataConnectionCheckNameRequest + :param data_connection_name: The name of the data connection. Is either a model type or a IO + type. Required. + :type data_connection_name: ~azure.mgmt.kusto.models.DataConnectionCheckNameRequest 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: CheckNameResult, or the result of cls(response) - :rtype: ~kusto_management_client.models.CheckNameResult - :raises: ~azure.core.exceptions.HttpResponseError + :return: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(data_connection_name, 'DataConnectionCheckNameRequest') + 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.CheckNameResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(data_connection_name, (IO, bytes)): + _content = data_connection_name + else: + _json = self._serialize.body(data_connection_name, "DataConnectionCheckNameRequest") request = build_check_name_availability_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameResult', pipeline_response) + deserialized = self._deserialize("CheckNameResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/checkNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/checkNameAvailability"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - cluster_name: str, - database_name: str, - data_connection_name: str, - **kwargs: Any - ) -> "_models.DataConnection": + self, resource_group_name: str, cluster_name: str, database_name: str, data_connection_name: str, **kwargs: Any + ) -> _models.DataConnection: """Returns a data connection. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str - :param data_connection_name: The name of the data connection. + :param data_connection_name: The name of the data connection. Required. :type data_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataConnection, or the result of cls(response) - :rtype: ~kusto_management_client.models.DataConnection - :raises: ~azure.core.exceptions.HttpResponseError + :return: DataConnection or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.DataConnection + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataConnection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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.DataConnection] - request = build_get_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, data_connection_name=data_connection_name, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DataConnection', pipeline_response) + deserialized = self._deserialize("DataConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore def _create_or_update_initial( self, @@ -685,33 +860,53 @@ def _create_or_update_initial( cluster_name: str, database_name: str, data_connection_name: str, - parameters: "_models.DataConnection", + parameters: Union[_models.DataConnection, IO], **kwargs: Any - ) -> "_models.DataConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataConnection"] + ) -> _models.DataConnection: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataConnection] - _json = self._serialize.body(parameters, 'DataConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataConnection") - request = build_create_or_update_request_initial( + request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, data_connection_name=data_connection_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -719,44 +914,93 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DataConnection', pipeline_response) + deserialized = self._deserialize("DataConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DataConnection', pipeline_response) + deserialized = self._deserialize("DataConnection", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('DataConnection', pipeline_response) + deserialized = self._deserialize("DataConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + data_connection_name: str, + parameters: _models.DataConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DataConnection]: + """Creates or updates a data connection. - @distributed_trace + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param data_connection_name: The name of the data connection. Required. + :type data_connection_name: str + :param parameters: The data connection parameters supplied to the CreateOrUpdate operation. + Required. + :type parameters: ~azure.mgmt.kusto.models.DataConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DataConnection or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.DataConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload def begin_create_or_update( self, resource_group_name: str, cluster_name: str, database_name: str, data_connection_name: str, - parameters: "_models.DataConnection", + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DataConnection"]: + ) -> LROPoller[_models.DataConnection]: """Creates or updates a data connection. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str - :param data_connection_name: The name of the data connection. + :param data_connection_name: The name of the data connection. Required. :type data_connection_name: str :param parameters: The data connection parameters supplied to the CreateOrUpdate operation. - :type parameters: ~kusto_management_client.models.DataConnection + 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 @@ -767,52 +1011,97 @@ def begin_create_or_update( Retry-After header is present. :return: An instance of LROPoller that returns either DataConnection or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~kusto_management_client.models.DataConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.DataConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + data_connection_name: str, + parameters: Union[_models.DataConnection, IO], + **kwargs: Any + ) -> LROPoller[_models.DataConnection]: + """Creates or updates a data connection. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param data_connection_name: The name of the data connection. Required. + :type data_connection_name: str + :param parameters: The data connection parameters supplied to the CreateOrUpdate operation. Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.kusto.models.DataConnection 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 DataConnection or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.DataConnection] + :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.DataConnection] + 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, database_name=database_name, data_connection_name=data_connection_name, parameters=parameters, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DataConnection', pipeline_response) + deserialized = self._deserialize("DataConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore def _update_initial( self, @@ -820,33 +1109,53 @@ def _update_initial( cluster_name: str, database_name: str, data_connection_name: str, - parameters: "_models.DataConnection", + parameters: Union[_models.DataConnection, IO], **kwargs: Any - ) -> "_models.DataConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataConnection"] + ) -> _models.DataConnection: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'DataConnection') + 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.DataConnection] - request = build_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataConnection") + + request = build_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, data_connection_name=data_connection_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -855,25 +1164,112 @@ def _update_initial( response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('DataConnection', pipeline_response) + deserialized = self._deserialize("DataConnection", pipeline_response) if response.status_code == 201: - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - - deserialized = self._deserialize('DataConnection', pipeline_response) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("DataConnection", pipeline_response) if response.status_code == 202: - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - - deserialized = self._deserialize('DataConnection', pipeline_response) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("DataConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + data_connection_name: str, + parameters: _models.DataConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DataConnection]: + """Updates a data connection. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param data_connection_name: The name of the data connection. Required. + :type data_connection_name: str + :param parameters: The data connection parameters supplied to the Update operation. Required. + :type parameters: ~azure.mgmt.kusto.models.DataConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DataConnection or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.DataConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + data_connection_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DataConnection]: + """Updates a data connection. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param data_connection_name: The name of the data connection. Required. + :type data_connection_name: str + :param parameters: The data connection parameters supplied to the Update 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 DataConnection or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.DataConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -882,21 +1278,26 @@ def begin_update( cluster_name: str, database_name: str, data_connection_name: str, - parameters: "_models.DataConnection", + parameters: Union[_models.DataConnection, IO], **kwargs: Any - ) -> LROPoller["_models.DataConnection"]: + ) -> LROPoller[_models.DataConnection]: """Updates a data connection. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str - :param data_connection_name: The name of the data connection. + :param data_connection_name: The name of the data connection. Required. :type data_connection_name: str - :param parameters: The data connection parameters supplied to the Update operation. - :type parameters: ~kusto_management_client.models.DataConnection + :param parameters: The data connection parameters supplied to the Update operation. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.kusto.models.DataConnection 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 @@ -907,80 +1308,92 @@ def begin_update( Retry-After header is present. :return: An instance of LROPoller that returns either DataConnection or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~kusto_management_client.models.DataConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.DataConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataConnection] + 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, database_name=database_name, data_connection_name=data_connection_name, parameters=parameters, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DataConnection', pipeline_response) + deserialized = self._deserialize("DataConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore - def _delete_initial( - self, - resource_group_name: str, - cluster_name: str, - database_name: str, - data_connection_name: str, - **kwargs: Any + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, cluster_name: str, database_name: str, data_connection_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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_initial( + request = build_delete_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, data_connection_name=data_connection_name, subscription_id=self._config.subscription_id, - template_url=self._delete_initial.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -990,27 +1403,22 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore @distributed_trace def begin_delete( - self, - resource_group_name: str, - cluster_name: str, - database_name: str, - data_connection_name: str, - **kwargs: Any + self, resource_group_name: str, cluster_name: str, database_name: str, data_connection_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes the data connection with the given name. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str - :param data_connection_name: The name of the data connection. + :param data_connection_name: The name of the data connection. Required. :type data_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. @@ -1022,42 +1430,47 @@ def begin_delete( Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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, database_name=database_name, data_connection_name=data_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) - 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, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_database_principal_assignments_operations.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_database_principal_assignments_operations.py index 10a428da89bf..5edd9ca2f84e 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_database_principal_assignments_operations.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_database_principal_assignments_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,259 +6,303 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse 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 msrest import Serializer from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_check_name_availability_request( - resource_group_name: str, - cluster_name: str, - database_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, cluster_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2022-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/checkPrincipalAssignmentNameAvailability') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/checkPrincipalAssignmentNameAvailability", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), - "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"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, resource_group_name: str, cluster_name: str, database_name: str, principal_assignment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}", + ) # 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'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), - "principalAssignmentName": _SERIALIZER.url("principal_assignment_name", principal_assignment_name, 'str'), + "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"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "principalAssignmentName": _SERIALIZER.url("principal_assignment_name", principal_assignment_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, +def build_create_or_update_request( resource_group_name: str, cluster_name: str, database_name: str, principal_assignment_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2022-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}", + ) # 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'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), - "principalAssignmentName": _SERIALIZER.url("principal_assignment_name", principal_assignment_name, 'str'), + "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"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "principalAssignmentName": _SERIALIZER.url("principal_assignment_name", principal_assignment_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, +def build_delete_request( resource_group_name: str, cluster_name: str, database_name: str, principal_assignment_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}", + ) # 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'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), - "principalAssignmentName": _SERIALIZER.url("principal_assignment_name", principal_assignment_name, 'str'), + "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"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "principalAssignmentName": _SERIALIZER.url("principal_assignment_name", principal_assignment_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( - subscription_id: str, - resource_group_name: str, - cluster_name: str, - database_name: str, - **kwargs: Any + resource_group_name: str, cluster_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments", + ) # 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'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "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"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class DatabasePrincipalAssignmentsOperations(object): - """DatabasePrincipalAssignmentsOperations 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: ~kusto_management_client.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. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class DatabasePrincipalAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kusto.KustoManagementClient`'s + :attr:`database_principal_assignments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + def check_name_availability( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + principal_assignment_name: _models.DatabasePrincipalAssignmentCheckNameRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the database principal assignment is valid and is not already in use. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param principal_assignment_name: The name of the resource. Required. + :type principal_assignment_name: + ~azure.mgmt.kusto.models.DatabasePrincipalAssignmentCheckNameRequest + :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: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + principal_assignment_name: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the database principal assignment is valid and is not already in use. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param principal_assignment_name: The name of the resource. Required. + :type principal_assignment_name: 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: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def check_name_availability( @@ -265,63 +310,87 @@ def check_name_availability( resource_group_name: str, cluster_name: str, database_name: str, - principal_assignment_name: "_models.DatabasePrincipalAssignmentCheckNameRequest", + principal_assignment_name: Union[_models.DatabasePrincipalAssignmentCheckNameRequest, IO], **kwargs: Any - ) -> "_models.CheckNameResult": + ) -> _models.CheckNameResult: """Checks that the database principal assignment is valid and is not already in use. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str - :param principal_assignment_name: The name of the resource. + :param principal_assignment_name: The name of the resource. Is either a model type or a IO + type. Required. :type principal_assignment_name: - ~kusto_management_client.models.DatabasePrincipalAssignmentCheckNameRequest + ~azure.mgmt.kusto.models.DatabasePrincipalAssignmentCheckNameRequest 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: CheckNameResult, or the result of cls(response) - :rtype: ~kusto_management_client.models.CheckNameResult - :raises: ~azure.core.exceptions.HttpResponseError + :return: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(principal_assignment_name, 'DatabasePrincipalAssignmentCheckNameRequest') + 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.CheckNameResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(principal_assignment_name, (IO, bytes)): + _content = principal_assignment_name + else: + _json = self._serialize.body(principal_assignment_name, "DatabasePrincipalAssignmentCheckNameRequest") request = build_check_name_availability_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameResult', pipeline_response) + deserialized = self._deserialize("CheckNameResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/checkPrincipalAssignmentNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/checkPrincipalAssignmentNameAvailability"} # type: ignore @distributed_trace def get( @@ -331,56 +400,69 @@ def get( database_name: str, principal_assignment_name: str, **kwargs: Any - ) -> "_models.DatabasePrincipalAssignment": + ) -> _models.DatabasePrincipalAssignment: """Gets a Kusto cluster database principalAssignment. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str - :param principal_assignment_name: The name of the Kusto principalAssignment. + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. :type principal_assignment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DatabasePrincipalAssignment, or the result of cls(response) - :rtype: ~kusto_management_client.models.DatabasePrincipalAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :return: DatabasePrincipalAssignment or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.DatabasePrincipalAssignment + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabasePrincipalAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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.DatabasePrincipalAssignment] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, principal_assignment_name=principal_assignment_name, - template_url=self.get.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DatabasePrincipalAssignment', pipeline_response) + deserialized = self._deserialize("DatabasePrincipalAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}"} # type: ignore def _create_or_update_initial( self, @@ -388,33 +470,53 @@ def _create_or_update_initial( cluster_name: str, database_name: str, principal_assignment_name: str, - parameters: "_models.DatabasePrincipalAssignment", + parameters: Union[_models.DatabasePrincipalAssignment, IO], **kwargs: Any - ) -> "_models.DatabasePrincipalAssignment": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabasePrincipalAssignment"] + ) -> _models.DatabasePrincipalAssignment: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'DatabasePrincipalAssignment') + 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.DatabasePrincipalAssignment] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DatabasePrincipalAssignment") + + request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, principal_assignment_name=principal_assignment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -422,41 +524,90 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DatabasePrincipalAssignment', pipeline_response) + deserialized = self._deserialize("DatabasePrincipalAssignment", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DatabasePrincipalAssignment', pipeline_response) + deserialized = self._deserialize("DatabasePrincipalAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + principal_assignment_name: str, + parameters: _models.DatabasePrincipalAssignment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DatabasePrincipalAssignment]: + """Creates a Kusto cluster database principalAssignment. - @distributed_trace + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. + :type principal_assignment_name: str + :param parameters: The Kusto principalAssignments parameters supplied for the operation. + Required. + :type parameters: ~azure.mgmt.kusto.models.DatabasePrincipalAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DatabasePrincipalAssignment or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.DatabasePrincipalAssignment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload def begin_create_or_update( self, resource_group_name: str, cluster_name: str, database_name: str, principal_assignment_name: str, - parameters: "_models.DatabasePrincipalAssignment", + parameters: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DatabasePrincipalAssignment"]: + ) -> LROPoller[_models.DatabasePrincipalAssignment]: """Creates a Kusto cluster database principalAssignment. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str - :param principal_assignment_name: The name of the Kusto principalAssignment. + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. :type principal_assignment_name: str :param parameters: The Kusto principalAssignments parameters supplied for the operation. - :type parameters: ~kusto_management_client.models.DatabasePrincipalAssignment + 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 @@ -467,55 +618,99 @@ def begin_create_or_update( Retry-After header is present. :return: An instance of LROPoller that returns either DatabasePrincipalAssignment or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~kusto_management_client.models.DatabasePrincipalAssignment] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.DatabasePrincipalAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabasePrincipalAssignment"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + principal_assignment_name: str, + parameters: Union[_models.DatabasePrincipalAssignment, IO], + **kwargs: Any + ) -> LROPoller[_models.DatabasePrincipalAssignment]: + """Creates a Kusto cluster database principalAssignment. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. + :type principal_assignment_name: str + :param parameters: The Kusto principalAssignments parameters supplied for the operation. Is + either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.kusto.models.DatabasePrincipalAssignment 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 DatabasePrincipalAssignment or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.DatabasePrincipalAssignment] + :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.DatabasePrincipalAssignment] + 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, database_name=database_name, principal_assignment_name=principal_assignment_name, parameters=parameters, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DatabasePrincipalAssignment', pipeline_response) + deserialized = self._deserialize("DatabasePrincipalAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}"} # type: ignore - def _delete_initial( + def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, @@ -523,25 +718,38 @@ def _delete_initial( principal_assignment_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', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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, database_name=database_name, principal_assignment_name=principal_assignment_name, - template_url=self._delete_initial.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -551,8 +759,7 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}"} # type: ignore @distributed_trace def begin_delete( @@ -566,12 +773,13 @@ def begin_delete( """Deletes a Kusto principalAssignment. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str - :param principal_assignment_name: The name of the Kusto principalAssignment. + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. :type principal_assignment_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. @@ -583,98 +791,108 @@ def begin_delete( Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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, database_name=database_name, principal_assignment_name=principal_assignment_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) - 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, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - cluster_name: str, - database_name: str, - **kwargs: Any - ) -> Iterable["_models.DatabasePrincipalAssignmentListResult"]: + self, resource_group_name: str, cluster_name: str, database_name: str, **kwargs: Any + ) -> Iterable["_models.DatabasePrincipalAssignment"]: """Lists all Kusto cluster database principalAssignments. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabasePrincipalAssignmentListResult or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~kusto_management_client.models.DatabasePrincipalAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DatabasePrincipalAssignment or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kusto.models.DatabasePrincipalAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabasePrincipalAssignmentListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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.DatabasePrincipalAssignmentListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, - template_url=self.list.metadata['url'], + 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) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_name=cluster_name, - database_name=database_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -688,7 +906,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -697,8 +917,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments"} # type: ignore diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_databases_operations.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_databases_operations.py index 0a5df2ad0f32..827495ee5a0f 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_databases_operations.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_databases_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,529 +6,565 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse 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 msrest import Serializer from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_check_name_availability_request( - resource_group_name: str, - cluster_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2022-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/checkNameAvailability') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/checkNameAvailability", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "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"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", 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 + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "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"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - cluster_name: str, - database_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, cluster_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), - "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"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( +def build_create_or_update_request( resource_group_name: str, cluster_name: str, database_name: str, subscription_id: str, *, - json: JSONType = None, - content: Any = None, + caller_role: Union[str, "_models.CallerRole"] = "Admin", **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2022-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), - "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"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if caller_role is not None: + _params["callerRole"] = _SERIALIZER.query("caller_role", caller_role, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( +def build_update_request( resource_group_name: str, cluster_name: str, database_name: str, subscription_id: str, *, - json: JSONType = None, - content: Any = None, + caller_role: Union[str, "_models.CallerRole"] = "Admin", **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2022-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), - "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"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if caller_role is not None: + _params["callerRole"] = _SERIALIZER.query("caller_role", caller_role, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - resource_group_name: str, - cluster_name: str, - database_name: str, - subscription_id: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, cluster_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), - "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"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_principals_request( - resource_group_name: str, - cluster_name: str, - database_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, cluster_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/listPrincipals') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/listPrincipals", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), - "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"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_add_principals_request( - resource_group_name: str, - cluster_name: str, - database_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, cluster_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2022-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/addPrincipals') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/addPrincipals", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), - "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"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_remove_principals_request( - resource_group_name: str, - cluster_name: str, - database_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, cluster_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2022-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/removePrincipals') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/removePrincipals", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), - "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"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - -class DatabasesOperations(object): - """DatabasesOperations 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: ~kusto_management_client.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. + _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 DatabasesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kusto.KustoManagementClient`'s + :attr:`databases` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + def check_name_availability( + self, + resource_group_name: str, + cluster_name: str, + resource_name: _models.CheckNameRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the databases resource name is valid and is not already in use. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: ~azure.mgmt.kusto.models.CheckNameRequest + :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: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, + resource_group_name: str, + cluster_name: str, + resource_name: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the databases resource name is valid and is not already in use. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: 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: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def check_name_availability( self, resource_group_name: str, cluster_name: str, - resource_name: "_models.CheckNameRequest", + resource_name: Union[_models.CheckNameRequest, IO], **kwargs: Any - ) -> "_models.CheckNameResult": + ) -> _models.CheckNameResult: """Checks that the databases resource name is valid and is not already in use. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param resource_name: The name of the resource. - :type resource_name: ~kusto_management_client.models.CheckNameRequest + :param resource_name: The name of the resource. Is either a model type or a IO type. Required. + :type resource_name: ~azure.mgmt.kusto.models.CheckNameRequest 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: CheckNameResult, or the result of cls(response) - :rtype: ~kusto_management_client.models.CheckNameResult - :raises: ~azure.core.exceptions.HttpResponseError + :return: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(resource_name, 'CheckNameRequest') + 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.CheckNameResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource_name, (IO, bytes)): + _content = resource_name + else: + _json = self._serialize.body(resource_name, "CheckNameRequest") request = build_check_name_availability_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, - template_url=self.check_name_availability.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameResult', pipeline_response) + deserialized = self._deserialize("CheckNameResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/checkNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/checkNameAvailability"} # type: ignore @distributed_trace def list_by_cluster( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> Iterable["_models.DatabaseListResult"]: + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.Database"]: """Returns the list of databases of the given Kusto cluster. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto 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 DatabaseListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~kusto_management_client.models.DatabaseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Database or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kusto.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabaseListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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.DatabaseListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_cluster_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, - template_url=self.list_by_cluster.metadata['url'], + 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) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_cluster_request( - resource_group_name=resource_group_name, - cluster_name=cluster_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -541,7 +578,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -550,98 +589,125 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_cluster.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases'} # type: ignore + list_by_cluster.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - cluster_name: str, - database_name: str, - **kwargs: Any - ) -> "_models.Database": + def get(self, resource_group_name: str, cluster_name: str, database_name: str, **kwargs: Any) -> _models.Database: """Returns a database. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Database, or the result of cls(response) - :rtype: ~kusto_management_client.models.Database - :raises: ~azure.core.exceptions.HttpResponseError + :return: Database or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.Database + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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.Database] - request = build_get_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, - template_url=self.get.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Database', pipeline_response) + deserialized = self._deserialize("Database", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, cluster_name: str, database_name: str, - parameters: "_models.Database", + parameters: Union[_models.Database, IO], + caller_role: Union[str, "_models.CallerRole"] = "Admin", **kwargs: Any - ) -> "_models.Database": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] + ) -> _models.Database: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Database] - _json = self._serialize.body(parameters, 'Database') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Database") - request = build_create_or_update_request_initial( + request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, + caller_role=caller_role, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -649,21 +715,106 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Database', pipeline_response) + deserialized = self._deserialize("Database", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Database', pipeline_response) + deserialized = self._deserialize("Database", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('Database', pipeline_response) + deserialized = self._deserialize("Database", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + parameters: _models.Database, + caller_role: Union[str, "_models.CallerRole"] = "Admin", + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Database]: + """Creates or updates a database. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param parameters: The database parameters supplied to the CreateOrUpdate operation. Required. + :type parameters: ~azure.mgmt.kusto.models.Database + :param caller_role: By default, any user who run operation on a database become an Admin on it. + This property allows the caller to exclude the caller from Admins list. Known values are: + "Admin" and "None". Default value is "Admin". + :type caller_role: str or ~azure.mgmt.kusto.models.CallerRole + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Database or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + parameters: IO, + caller_role: Union[str, "_models.CallerRole"] = "Admin", + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Database]: + """Creates or updates a database. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param parameters: The database parameters supplied to the CreateOrUpdate operation. Required. + :type parameters: IO + :param caller_role: By default, any user who run operation on a database become an Admin on it. + This property allows the caller to exclude the caller from Admins list. Known values are: + "Admin" and "None". Default value is "Admin". + :type caller_role: str or ~azure.mgmt.kusto.models.CallerRole + :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 Database or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -671,19 +822,29 @@ def begin_create_or_update( resource_group_name: str, cluster_name: str, database_name: str, - parameters: "_models.Database", + parameters: Union[_models.Database, IO], + caller_role: Union[str, "_models.CallerRole"] = "Admin", **kwargs: Any - ) -> LROPoller["_models.Database"]: + ) -> LROPoller[_models.Database]: """Creates or updates a database. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str - :param parameters: The database parameters supplied to the CreateOrUpdate operation. - :type parameters: ~kusto_management_client.models.Database + :param parameters: The database parameters supplied to the CreateOrUpdate operation. Is either + a model type or a IO type. Required. + :type parameters: ~azure.mgmt.kusto.models.Database or IO + :param caller_role: By default, any user who run operation on a database become an Admin on it. + This property allows the caller to exclude the caller from Admins list. Known values are: + "Admin" and "None". Default value is "Admin". + :type caller_role: str or ~azure.mgmt.kusto.models.CallerRole + :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 @@ -693,83 +854,110 @@ def begin_create_or_update( :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. :return: An instance of LROPoller that returns either Database or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~kusto_management_client.models.Database] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Database] + 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, database_name=database_name, parameters=parameters, + caller_role=caller_role, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('Database', pipeline_response) + deserialized = self._deserialize("Database", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}"} # type: ignore def _update_initial( self, resource_group_name: str, cluster_name: str, database_name: str, - parameters: "_models.Database", + parameters: Union[_models.Database, IO], + caller_role: Union[str, "_models.CallerRole"] = "Admin", **kwargs: Any - ) -> "_models.Database": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] + ) -> _models.Database: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Database] - _json = self._serialize.body(parameters, 'Database') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Database") - request = build_update_request_initial( + request = build_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, + caller_role=caller_role, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -778,25 +966,114 @@ def _update_initial( response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('Database', pipeline_response) + deserialized = self._deserialize("Database", pipeline_response) if response.status_code == 201: - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - - deserialized = self._deserialize('Database', pipeline_response) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Database", pipeline_response) if response.status_code == 202: - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - - deserialized = self._deserialize('Database', pipeline_response) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Database", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + parameters: _models.Database, + caller_role: Union[str, "_models.CallerRole"] = "Admin", + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Database]: + """Updates a database. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param parameters: The database parameters supplied to the Update operation. Required. + :type parameters: ~azure.mgmt.kusto.models.Database + :param caller_role: By default, any user who run operation on a database become an Admin on it. + This property allows the caller to exclude the caller from Admins list. Known values are: + "Admin" and "None". Default value is "Admin". + :type caller_role: str or ~azure.mgmt.kusto.models.CallerRole + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Database or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def begin_update( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + parameters: IO, + caller_role: Union[str, "_models.CallerRole"] = "Admin", + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Database]: + """Updates a database. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param parameters: The database parameters supplied to the Update operation. Required. + :type parameters: IO + :param caller_role: By default, any user who run operation on a database become an Admin on it. + This property allows the caller to exclude the caller from Admins list. Known values are: + "Admin" and "None". Default value is "Admin". + :type caller_role: str or ~azure.mgmt.kusto.models.CallerRole + :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 Database or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -804,19 +1081,29 @@ def begin_update( resource_group_name: str, cluster_name: str, database_name: str, - parameters: "_models.Database", + parameters: Union[_models.Database, IO], + caller_role: Union[str, "_models.CallerRole"] = "Admin", **kwargs: Any - ) -> LROPoller["_models.Database"]: + ) -> LROPoller[_models.Database]: """Updates a database. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str - :param parameters: The database parameters supplied to the Update operation. - :type parameters: ~kusto_management_client.models.Database + :param parameters: The database parameters supplied to the Update operation. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.kusto.models.Database or IO + :param caller_role: By default, any user who run operation on a database become an Admin on it. + This property allows the caller to exclude the caller from Admins list. Known values are: + "Admin" and "None". Default value is "Admin". + :type caller_role: str or ~azure.mgmt.kusto.models.CallerRole + :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 @@ -826,77 +1113,91 @@ def begin_update( :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. :return: An instance of LROPoller that returns either Database or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~kusto_management_client.models.Database] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Database] + 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, database_name=database_name, parameters=parameters, + caller_role=caller_role, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('Database', pipeline_response) + deserialized = self._deserialize("Database", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}"} # type: ignore - def _delete_initial( - self, - resource_group_name: str, - cluster_name: str, - database_name: str, - **kwargs: Any + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, cluster_name: str, database_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', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( + 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, database_name=database_name, subscription_id=self._config.subscription_id, - template_url=self._delete_initial.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -906,24 +1207,20 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}"} # type: ignore @distributed_trace def begin_delete( - self, - resource_group_name: str, - cluster_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, cluster_name: str, database_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes the database with the given name. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_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. @@ -935,97 +1232,106 @@ def begin_delete( Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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, database_name=database_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) - 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, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}"} # type: ignore @distributed_trace def list_principals( - self, - resource_group_name: str, - cluster_name: str, - database_name: str, - **kwargs: Any - ) -> Iterable["_models.DatabasePrincipalListResult"]: + self, resource_group_name: str, cluster_name: str, database_name: str, **kwargs: Any + ) -> Iterable["_models.DatabasePrincipal"]: """Returns a list of database principals of the given Kusto cluster and database. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabasePrincipalListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~kusto_management_client.models.DatabasePrincipalListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DatabasePrincipal or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kusto.models.DatabasePrincipal] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabasePrincipalListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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.DatabasePrincipalListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_principals_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, - template_url=self.list_principals.metadata['url'], + api_version=api_version, + template_url=self.list_principals.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_principals_request( - resource_group_name=resource_group_name, - cluster_name=cluster_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1039,7 +1345,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1048,11 +1356,71 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_principals.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/listPrincipals'} # type: ignore + list_principals.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/listPrincipals"} # type: ignore + + @overload + def add_principals( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + database_principals_to_add: _models.DatabasePrincipalListRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabasePrincipalListResult: + """Add Database principals permissions. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param database_principals_to_add: List of database principals to add. Required. + :type database_principals_to_add: ~azure.mgmt.kusto.models.DatabasePrincipalListRequest + :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: DatabasePrincipalListResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.DatabasePrincipalListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def add_principals( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + database_principals_to_add: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabasePrincipalListResult: + """Add Database principals permissions. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param database_principals_to_add: List of database principals to add. Required. + :type database_principals_to_add: 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: DatabasePrincipalListResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.DatabasePrincipalListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def add_principals( @@ -1060,62 +1428,148 @@ def add_principals( resource_group_name: str, cluster_name: str, database_name: str, - database_principals_to_add: "_models.DatabasePrincipalListRequest", + database_principals_to_add: Union[_models.DatabasePrincipalListRequest, IO], **kwargs: Any - ) -> "_models.DatabasePrincipalListResult": + ) -> _models.DatabasePrincipalListResult: """Add Database principals permissions. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str - :param database_principals_to_add: List of database principals to add. - :type database_principals_to_add: ~kusto_management_client.models.DatabasePrincipalListRequest + :param database_principals_to_add: List of database principals to add. Is either a model type + or a IO type. Required. + :type database_principals_to_add: ~azure.mgmt.kusto.models.DatabasePrincipalListRequest 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: DatabasePrincipalListResult, or the result of cls(response) - :rtype: ~kusto_management_client.models.DatabasePrincipalListResult - :raises: ~azure.core.exceptions.HttpResponseError + :return: DatabasePrincipalListResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.DatabasePrincipalListResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabasePrincipalListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(database_principals_to_add, 'DatabasePrincipalListRequest') + 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.DatabasePrincipalListResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(database_principals_to_add, (IO, bytes)): + _content = database_principals_to_add + else: + _json = self._serialize.body(database_principals_to_add, "DatabasePrincipalListRequest") request = build_add_principals_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.add_principals.metadata['url'], + content=_content, + template_url=self.add_principals.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DatabasePrincipalListResult', pipeline_response) + deserialized = self._deserialize("DatabasePrincipalListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - add_principals.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/addPrincipals'} # type: ignore + add_principals.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/addPrincipals"} # type: ignore + @overload + def remove_principals( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + database_principals_to_remove: _models.DatabasePrincipalListRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabasePrincipalListResult: + """Remove Database principals permissions. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param database_principals_to_remove: List of database principals to remove. Required. + :type database_principals_to_remove: ~azure.mgmt.kusto.models.DatabasePrincipalListRequest + :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: DatabasePrincipalListResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.DatabasePrincipalListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def remove_principals( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + database_principals_to_remove: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DatabasePrincipalListResult: + """Remove Database principals permissions. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param database_principals_to_remove: List of database principals to remove. Required. + :type database_principals_to_remove: 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: DatabasePrincipalListResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.DatabasePrincipalListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def remove_principals( @@ -1123,60 +1577,84 @@ def remove_principals( resource_group_name: str, cluster_name: str, database_name: str, - database_principals_to_remove: "_models.DatabasePrincipalListRequest", + database_principals_to_remove: Union[_models.DatabasePrincipalListRequest, IO], **kwargs: Any - ) -> "_models.DatabasePrincipalListResult": + ) -> _models.DatabasePrincipalListResult: """Remove Database principals permissions. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str - :param database_principals_to_remove: List of database principals to remove. - :type database_principals_to_remove: - ~kusto_management_client.models.DatabasePrincipalListRequest + :param database_principals_to_remove: List of database principals to remove. Is either a model + type or a IO type. Required. + :type database_principals_to_remove: ~azure.mgmt.kusto.models.DatabasePrincipalListRequest 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: DatabasePrincipalListResult, or the result of cls(response) - :rtype: ~kusto_management_client.models.DatabasePrincipalListResult - :raises: ~azure.core.exceptions.HttpResponseError + :return: DatabasePrincipalListResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.DatabasePrincipalListResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabasePrincipalListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(database_principals_to_remove, 'DatabasePrincipalListRequest') + 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.DatabasePrincipalListResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(database_principals_to_remove, (IO, bytes)): + _content = database_principals_to_remove + else: + _json = self._serialize.body(database_principals_to_remove, "DatabasePrincipalListRequest") request = build_remove_principals_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.remove_principals.metadata['url'], + content=_content, + template_url=self.remove_principals.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DatabasePrincipalListResult', pipeline_response) + deserialized = self._deserialize("DatabasePrincipalListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - remove_principals.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/removePrincipals'} # type: ignore - + remove_principals.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/removePrincipals"} # type: ignore diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_managed_private_endpoints_operations.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_managed_private_endpoints_operations.py index d30d09f6930c..5e3572710a39 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_managed_private_endpoints_operations.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_managed_private_endpoints_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,402 +6,454 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse 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 msrest import Serializer from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_check_name_availability_request( - resource_group_name: str, - cluster_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2022-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpointsCheckNameAvailability') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpointsCheckNameAvailability", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "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"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_list_request( - subscription_id: str, - resource_group_name: str, - cluster_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _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(resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints", + ) # 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'), + "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) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - cluster_name: str, - managed_private_endpoint_name: str, - **kwargs: Any + resource_group_name: str, cluster_name: str, managed_private_endpoint_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}", + ) # 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'), - "managedPrivateEndpointName": _SERIALIZER.url("managed_private_endpoint_name", managed_private_endpoint_name, 'str'), + "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"), + "managedPrivateEndpointName": _SERIALIZER.url( + "managed_private_endpoint_name", managed_private_endpoint_name, "str" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - cluster_name: str, - managed_private_endpoint_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _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, managed_private_endpoint_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2022-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}", + ) # 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'), - "managedPrivateEndpointName": _SERIALIZER.url("managed_private_endpoint_name", managed_private_endpoint_name, 'str'), + "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"), + "managedPrivateEndpointName": _SERIALIZER.url( + "managed_private_endpoint_name", managed_private_endpoint_name, "str" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - cluster_name: str, - managed_private_endpoint_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _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, managed_private_endpoint_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2022-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}", + ) # 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'), - "managedPrivateEndpointName": _SERIALIZER.url("managed_private_endpoint_name", managed_private_endpoint_name, 'str'), + "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"), + "managedPrivateEndpointName": _SERIALIZER.url( + "managed_private_endpoint_name", managed_private_endpoint_name, "str" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - cluster_name: str, - managed_private_endpoint_name: str, - **kwargs: Any + _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, managed_private_endpoint_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}", + ) # 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'), - "managedPrivateEndpointName": _SERIALIZER.url("managed_private_endpoint_name", managed_private_endpoint_name, 'str'), + "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"), + "managedPrivateEndpointName": _SERIALIZER.url( + "managed_private_endpoint_name", managed_private_endpoint_name, "str" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class ManagedPrivateEndpointsOperations(object): - """ManagedPrivateEndpointsOperations 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: ~kusto_management_client.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. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class ManagedPrivateEndpointsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kusto.KustoManagementClient`'s + :attr:`managed_private_endpoints` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + def check_name_availability( + self, + resource_group_name: str, + cluster_name: str, + resource_name: _models.ManagedPrivateEndpointsCheckNameRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the managed private endpoints resource name is valid and is not already in use. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: ~azure.mgmt.kusto.models.ManagedPrivateEndpointsCheckNameRequest + :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: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, + resource_group_name: str, + cluster_name: str, + resource_name: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the managed private endpoints resource name is valid and is not already in use. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: 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: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def check_name_availability( self, resource_group_name: str, cluster_name: str, - resource_name: "_models.ManagedPrivateEndpointsCheckNameRequest", + resource_name: Union[_models.ManagedPrivateEndpointsCheckNameRequest, IO], **kwargs: Any - ) -> "_models.CheckNameResult": + ) -> _models.CheckNameResult: """Checks that the managed private endpoints resource name is valid and is not already in use. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param resource_name: The name of the resource. - :type resource_name: ~kusto_management_client.models.ManagedPrivateEndpointsCheckNameRequest + :param resource_name: The name of the resource. Is either a model type or a IO type. Required. + :type resource_name: ~azure.mgmt.kusto.models.ManagedPrivateEndpointsCheckNameRequest 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: CheckNameResult, or the result of cls(response) - :rtype: ~kusto_management_client.models.CheckNameResult - :raises: ~azure.core.exceptions.HttpResponseError + :return: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameResult] - _json = self._serialize.body(resource_name, 'ManagedPrivateEndpointsCheckNameRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource_name, (IO, bytes)): + _content = resource_name + else: + _json = self._serialize.body(resource_name, "ManagedPrivateEndpointsCheckNameRequest") request = build_check_name_availability_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, - template_url=self.check_name_availability.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameResult', pipeline_response) + deserialized = self._deserialize("CheckNameResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpointsCheckNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpointsCheckNameAvailability"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> Iterable["_models.ManagedPrivateEndpointListResult"]: + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.ManagedPrivateEndpoint"]: """Returns the list of managed private endpoints. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto 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 ManagedPrivateEndpointListResult or the result of + :return: An iterator like instance of either ManagedPrivateEndpoint or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~kusto_management_client.models.ManagedPrivateEndpointListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kusto.models.ManagedPrivateEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedPrivateEndpointListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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.ManagedPrivateEndpointListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_name=cluster_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -414,7 +467,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -423,98 +478,125 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - cluster_name: str, - managed_private_endpoint_name: str, - **kwargs: Any - ) -> "_models.ManagedPrivateEndpoint": + self, resource_group_name: str, cluster_name: str, managed_private_endpoint_name: str, **kwargs: Any + ) -> _models.ManagedPrivateEndpoint: """Gets a managed private endpoint. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param managed_private_endpoint_name: The name of the managed private endpoint. + :param managed_private_endpoint_name: The name of the managed private endpoint. Required. :type managed_private_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagedPrivateEndpoint, or the result of cls(response) - :rtype: ~kusto_management_client.models.ManagedPrivateEndpoint - :raises: ~azure.core.exceptions.HttpResponseError + :return: ManagedPrivateEndpoint or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.ManagedPrivateEndpoint + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedPrivateEndpoint"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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.ManagedPrivateEndpoint] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, managed_private_endpoint_name=managed_private_endpoint_name, - template_url=self.get.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagedPrivateEndpoint', pipeline_response) + deserialized = self._deserialize("ManagedPrivateEndpoint", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, cluster_name: str, managed_private_endpoint_name: str, - parameters: "_models.ManagedPrivateEndpoint", + parameters: Union[_models.ManagedPrivateEndpoint, IO], **kwargs: Any - ) -> "_models.ManagedPrivateEndpoint": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedPrivateEndpoint"] + ) -> _models.ManagedPrivateEndpoint: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ManagedPrivateEndpoint') + 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.ManagedPrivateEndpoint] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ManagedPrivateEndpoint") + + request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, managed_private_endpoint_name=managed_private_endpoint_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -522,21 +604,98 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ManagedPrivateEndpoint', pipeline_response) + deserialized = self._deserialize("ManagedPrivateEndpoint", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ManagedPrivateEndpoint', pipeline_response) + deserialized = self._deserialize("ManagedPrivateEndpoint", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('ManagedPrivateEndpoint', pipeline_response) + deserialized = self._deserialize("ManagedPrivateEndpoint", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + managed_private_endpoint_name: str, + parameters: _models.ManagedPrivateEndpoint, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedPrivateEndpoint]: + """Creates a managed private endpoint. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param managed_private_endpoint_name: The name of the managed private endpoint. Required. + :type managed_private_endpoint_name: str + :param parameters: The managed private endpoint parameters. Required. + :type parameters: ~azure.mgmt.kusto.models.ManagedPrivateEndpoint + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ManagedPrivateEndpoint or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.ManagedPrivateEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + managed_private_endpoint_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedPrivateEndpoint]: + """Creates a managed private endpoint. + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param managed_private_endpoint_name: The name of the managed private endpoint. Required. + :type managed_private_endpoint_name: str + :param parameters: The managed private endpoint 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 ManagedPrivateEndpoint or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.ManagedPrivateEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -544,19 +703,24 @@ def begin_create_or_update( resource_group_name: str, cluster_name: str, managed_private_endpoint_name: str, - parameters: "_models.ManagedPrivateEndpoint", + parameters: Union[_models.ManagedPrivateEndpoint, IO], **kwargs: Any - ) -> LROPoller["_models.ManagedPrivateEndpoint"]: + ) -> LROPoller[_models.ManagedPrivateEndpoint]: """Creates a managed private endpoint. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param managed_private_endpoint_name: The name of the managed private endpoint. + :param managed_private_endpoint_name: The name of the managed private endpoint. Required. :type managed_private_endpoint_name: str - :param parameters: The managed private endpoint parameters. - :type parameters: ~kusto_management_client.models.ManagedPrivateEndpoint + :param parameters: The managed private endpoint parameters. Is either a model type or a IO + type. Required. + :type parameters: ~azure.mgmt.kusto.models.ManagedPrivateEndpoint 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 @@ -567,83 +731,107 @@ def begin_create_or_update( Retry-After header is present. :return: An instance of LROPoller that returns either ManagedPrivateEndpoint or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~kusto_management_client.models.ManagedPrivateEndpoint] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.ManagedPrivateEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedPrivateEndpoint"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagedPrivateEndpoint] + 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, managed_private_endpoint_name=managed_private_endpoint_name, parameters=parameters, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ManagedPrivateEndpoint', pipeline_response) + deserialized = self._deserialize("ManagedPrivateEndpoint", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}"} # type: ignore def _update_initial( self, resource_group_name: str, cluster_name: str, managed_private_endpoint_name: str, - parameters: "_models.ManagedPrivateEndpoint", + parameters: Union[_models.ManagedPrivateEndpoint, IO], **kwargs: Any - ) -> "_models.ManagedPrivateEndpoint": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedPrivateEndpoint"] + ) -> _models.ManagedPrivateEndpoint: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ManagedPrivateEndpoint') + 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.ManagedPrivateEndpoint] - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ManagedPrivateEndpoint") + + request = build_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, managed_private_endpoint_name=managed_private_endpoint_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -652,20 +840,99 @@ def _update_initial( response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('ManagedPrivateEndpoint', pipeline_response) + deserialized = self._deserialize("ManagedPrivateEndpoint", pipeline_response) if response.status_code == 202: - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - - deserialized = self._deserialize('ManagedPrivateEndpoint', pipeline_response) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("ManagedPrivateEndpoint", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + cluster_name: str, + managed_private_endpoint_name: str, + parameters: _models.ManagedPrivateEndpoint, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedPrivateEndpoint]: + """Updates a managed private endpoint. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param managed_private_endpoint_name: The name of the managed private endpoint. Required. + :type managed_private_endpoint_name: str + :param parameters: The managed private endpoint parameters. Required. + :type parameters: ~azure.mgmt.kusto.models.ManagedPrivateEndpoint + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ManagedPrivateEndpoint or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.ManagedPrivateEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + cluster_name: str, + managed_private_endpoint_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedPrivateEndpoint]: + """Updates a managed private endpoint. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param managed_private_endpoint_name: The name of the managed private endpoint. Required. + :type managed_private_endpoint_name: str + :param parameters: The managed private endpoint 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 ManagedPrivateEndpoint or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.ManagedPrivateEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -673,19 +940,24 @@ def begin_update( resource_group_name: str, cluster_name: str, managed_private_endpoint_name: str, - parameters: "_models.ManagedPrivateEndpoint", + parameters: Union[_models.ManagedPrivateEndpoint, IO], **kwargs: Any - ) -> LROPoller["_models.ManagedPrivateEndpoint"]: + ) -> LROPoller[_models.ManagedPrivateEndpoint]: """Updates a managed private endpoint. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param managed_private_endpoint_name: The name of the managed private endpoint. + :param managed_private_endpoint_name: The name of the managed private endpoint. Required. :type managed_private_endpoint_name: str - :param parameters: The managed private endpoint parameters. - :type parameters: ~kusto_management_client.models.ManagedPrivateEndpoint + :param parameters: The managed private endpoint parameters. Is either a model type or a IO + type. Required. + :type parameters: ~azure.mgmt.kusto.models.ManagedPrivateEndpoint 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 @@ -696,77 +968,90 @@ def begin_update( Retry-After header is present. :return: An instance of LROPoller that returns either ManagedPrivateEndpoint or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~kusto_management_client.models.ManagedPrivateEndpoint] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.ManagedPrivateEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedPrivateEndpoint"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagedPrivateEndpoint] + 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, managed_private_endpoint_name=managed_private_endpoint_name, parameters=parameters, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ManagedPrivateEndpoint', pipeline_response) + deserialized = self._deserialize("ManagedPrivateEndpoint", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}"} # type: ignore - def _delete_initial( - self, - resource_group_name: str, - cluster_name: str, - managed_private_endpoint_name: str, - **kwargs: Any + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, cluster_name: str, managed_private_endpoint_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', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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, managed_private_endpoint_name=managed_private_endpoint_name, - template_url=self._delete_initial.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -776,24 +1061,20 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}"} # type: ignore @distributed_trace def begin_delete( - self, - resource_group_name: str, - cluster_name: str, - managed_private_endpoint_name: str, - **kwargs: Any + self, resource_group_name: str, cluster_name: str, managed_private_endpoint_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a managed private endpoint. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param managed_private_endpoint_name: The name of the managed private endpoint. + :param managed_private_endpoint_name: The name of the managed private endpoint. Required. :type managed_private_endpoint_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. @@ -805,41 +1086,46 @@ def begin_delete( Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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, managed_private_endpoint_name=managed_private_endpoint_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) - 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, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}"} # type: ignore diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_operations.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_operations.py index 34e985053546..2079f407eaaf 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_operations.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,106 +6,117 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse 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 msrest import Serializer from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Kusto/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.Kusto/operations") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class Operations(object): - """Operations operations. - - 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: ~kusto_management_client.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. + _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.kusto.KustoManagementClient`'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 __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.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists available operations for the Microsoft.Kusto provider. :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[~kusto_management_client.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.kusto.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', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + 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) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -118,7 +130,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -127,8 +141,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.Kusto/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Kusto/operations"} # type: ignore diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_operations_results_location_operations.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_operations_results_location_operations.py index 14d3cb5fe3f6..9f15a2d5700e 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_operations_results_location_operations.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_operations_results_location_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,111 +6,121 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, 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 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 msrest import Serializer from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - location: str, - operation_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2022-02-01" + +def build_get_request(location: str, operation_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/locations/{location}/operationResults/{operationId}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/locations/{location}/operationResults/{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'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - **kwargs - ) - -class OperationsResultsLocationOperations(object): - """OperationsResultsLocationOperations 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: ~kusto_management_client.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. + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="GET", url=_url, params=_params, **kwargs) + + +class OperationsResultsLocationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kusto.KustoManagementClient`'s + :attr:`operations_results_location` 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 get( - self, - location: str, - operation_id: str, - **kwargs: Any + def get( # pylint: disable=inconsistent-return-statements + self, location: str, operation_id: str, **kwargs: Any ) -> None: """Returns operation results. - :param location: Azure location (region) name. + :param location: Azure location (region) name. Required. :type location: str - :param operation_id: The Guid of the operation ID. + :param operation_id: The Guid of the operation ID. Required. :type operation_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', {})) + 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_get_request( - subscription_id=self._config.subscription_id, location=location, operation_id=operation_id, - template_url=self.get.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -119,5 +130,4 @@ def get( if cls: return cls(pipeline_response, None, {}) - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/locations/{location}/operationResults/{operationId}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/locations/{location}/operationResults/{operationId}"} # type: ignore diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_operations_results_operations.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_operations_results_operations.py index c9682f451f08..a85a1a95e460 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_operations_results_operations.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_operations_results_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,129 +6,136 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, 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 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 msrest import Serializer from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - location: str, - operation_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + +def build_get_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 {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/locations/{location}/operationResults/{operationId}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/locations/{location}/operationResults/{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'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class OperationsResultsOperations(object): - """OperationsResultsOperations 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: ~kusto_management_client.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. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class OperationsResultsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kusto.KustoManagementClient`'s + :attr:`operations_results` 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 get( - self, - location: str, - operation_id: str, - **kwargs: Any - ) -> "_models.OperationResult": + def get(self, location: str, operation_id: str, **kwargs: Any) -> _models.OperationResult: """Returns operation results. - :param location: Azure location (region) name. + :param location: Azure location (region) name. Required. :type location: str - :param operation_id: The Guid of the operation ID. + :param operation_id: The Guid of the operation ID. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationResult, or the result of cls(response) - :rtype: ~kusto_management_client.models.OperationResult - :raises: ~azure.core.exceptions.HttpResponseError + :return: OperationResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.OperationResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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.OperationResult] - request = build_get_request( - subscription_id=self._config.subscription_id, location=location, operation_id=operation_id, - template_url=self.get.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('OperationResult', pipeline_response) + deserialized = self._deserialize("OperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/locations/{location}/operationResults/{operationId}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/locations/{location}/operationResults/{operationId}"} # type: ignore diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_patch.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/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/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_private_endpoint_connections_operations.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_private_endpoint_connections_operations.py index f0d28bc8ea1f..0d7aaf400533 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_private_endpoint_connections_operations.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/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,253 +6,257 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse 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 msrest import Serializer from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +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( - subscription_id: str, - resource_group_name: str, - cluster_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + +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", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateEndpointConnections') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/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'), + "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) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, resource_group_name: str, cluster_name: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/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'), + "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) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, +def build_create_or_update_request( resource_group_name: str, cluster_name: str, private_endpoint_connection_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2022-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/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'), + "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) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, +def build_delete_request( resource_group_name: str, cluster_name: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/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'), + "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) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -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: ~kusto_management_client.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. + _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. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kusto.KustoManagementClient`'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( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnectionListResult"]: + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: """Returns the list of private endpoint connections. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto 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[~kusto_management_client.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.kusto.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', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_name=cluster_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -265,7 +270,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -274,98 +281,125 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateEndpointConnections'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateEndpointConnections"} # type: ignore @distributed_trace 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 a private endpoint connection. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto 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) - :rtype: ~kusto_management_client.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_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', {})) + 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( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, private_endpoint_connection_name=private_endpoint_connection_name, - template_url=self.get.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('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.Kusto/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore 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', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + 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] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + 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, - template_url=self._create_or_update_initial.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -373,18 +407,95 @@ def _create_or_update_initial( raise HttpResponseError(response=response, 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.Kusto/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + 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 with a given name. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto 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: Required. + :type parameters: ~azure.mgmt.kusto.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. + :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.kusto.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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 with a given name. + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto 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: 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.kusto.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -392,19 +503,23 @@ def begin_create_or_update( resource_group_name: str, cluster_name: str, private_endpoint_connection_name: str, - parameters: "_models.PrivateEndpointConnection", + parameters: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> LROPoller["_models.PrivateEndpointConnection"]: + ) -> LROPoller[_models.PrivateEndpointConnection]: """Approve or reject a private endpoint connection with a given name. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto 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: - :type parameters: ~kusto_management_client.models.PrivateEndpointConnection + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.kusto.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 @@ -415,78 +530,90 @@ def begin_create_or_update( 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[~kusto_management_client.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.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, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - def _delete_initial( - self, - resource_group_name: str, - cluster_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + 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 + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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, - template_url=self._delete_initial.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -496,24 +623,20 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace 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 ) -> LROPoller[None]: """Deletes a private endpoint connection with a given name. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto 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. @@ -525,41 +648,46 @@ def begin_delete( Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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) - 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, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_private_link_resources_operations.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_private_link_resources_operations.py index 799048116940..a8420bdacff7 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_private_link_resources_operations.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/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,167 +6,169 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse 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 msrest import Serializer from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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( - subscription_id: str, - resource_group_name: str, - cluster_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + +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", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateLinkResources') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/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'), + "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) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - cluster_name: str, - private_link_resource_name: str, - **kwargs: Any + resource_group_name: str, cluster_name: str, private_link_resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateLinkResources/{privateLinkResourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/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'), + "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"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class PrivateLinkResourcesOperations(object): - """PrivateLinkResourcesOperations 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: ~kusto_management_client.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. + _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.kusto.KustoManagementClient`'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( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> Iterable["_models.PrivateLinkResourceListResult"]: + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateLinkResource"]: """Returns the list of private link resources. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto 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 PrivateLinkResourceListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~kusto_management_client.models.PrivateLinkResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kusto.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, - template_url=self.list.metadata['url'], + 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) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_name=cluster_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -179,7 +182,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -188,63 +193,70 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateLinkResources'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateLinkResources"} # type: ignore @distributed_trace 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 a private link resource. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto 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) - :rtype: ~kusto_management_client.models.PrivateLinkResource - :raises: ~azure.core.exceptions.HttpResponseError + :return: PrivateLinkResource or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.PrivateLinkResource + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, private_link_resource_name=private_link_resource_name, - template_url=self.get.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('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.Kusto/clusters/{clusterName}/privateLinkResources/{privateLinkResourceName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateLinkResources/{privateLinkResourceName}"} # type: ignore diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_scripts_operations.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_scripts_operations.py index bbdadf820a8e..09d3f8042934 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_scripts_operations.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_scripts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,358 +6,338 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse 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 msrest import Serializer from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +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_database_request( - subscription_id: str, - resource_group_name: str, - cluster_name: str, - database_name: str, - **kwargs: Any + resource_group_name: str, cluster_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts", + ) # 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'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "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"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, resource_group_name: str, cluster_name: str, database_name: str, script_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{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'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), - "scriptName": _SERIALIZER.url("script_name", script_name, 'str'), + "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"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "scriptName": _SERIALIZER.url("script_name", script_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, +def build_create_or_update_request( resource_group_name: str, cluster_name: str, database_name: str, script_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2022-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{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'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), - "scriptName": _SERIALIZER.url("script_name", script_name, 'str'), + "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"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "scriptName": _SERIALIZER.url("script_name", script_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( - subscription_id: str, +def build_update_request( resource_group_name: str, cluster_name: str, database_name: str, script_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2022-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{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'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), - "scriptName": _SERIALIZER.url("script_name", script_name, 'str'), + "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"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "scriptName": _SERIALIZER.url("script_name", script_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, +def build_delete_request( resource_group_name: str, cluster_name: str, database_name: str, script_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{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'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), - "scriptName": _SERIALIZER.url("script_name", script_name, 'str'), + "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"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "scriptName": _SERIALIZER.url("script_name", script_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_check_name_availability_request( - resource_group_name: str, - cluster_name: str, - database_name: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, cluster_name: str, database_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-07")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2022-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scriptsCheckNameAvailability') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scriptsCheckNameAvailability", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), - "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"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - -class ScriptsOperations(object): - """ScriptsOperations 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: ~kusto_management_client.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. + _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 ScriptsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.kusto.KustoManagementClient`'s + :attr:`scripts` 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_database( - self, - resource_group_name: str, - cluster_name: str, - database_name: str, - **kwargs: Any - ) -> Iterable["_models.ScriptListResult"]: + self, resource_group_name: str, cluster_name: str, database_name: str, **kwargs: Any + ) -> Iterable["_models.Script"]: """Returns the list of database scripts for given database. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScriptListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~kusto_management_client.models.ScriptListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Script or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kusto.models.Script] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScriptListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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.ScriptListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_database_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, - template_url=self.list_by_database.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_database_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_name=cluster_name, - database_name=database_name, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -370,7 +351,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -379,70 +362,76 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts'} # type: ignore + list_by_database.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - cluster_name: str, - database_name: str, - script_name: str, - **kwargs: Any - ) -> "_models.Script": + self, resource_group_name: str, cluster_name: str, database_name: str, script_name: str, **kwargs: Any + ) -> _models.Script: """Gets a Kusto cluster database script. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str - :param script_name: The name of the Kusto database script. + :param script_name: The name of the Kusto database script. Required. :type script_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Script, or the result of cls(response) - :rtype: ~kusto_management_client.models.Script - :raises: ~azure.core.exceptions.HttpResponseError + :return: Script or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.Script + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Script"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + 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.Script] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, script_name=script_name, - template_url=self.get.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Script', pipeline_response) + deserialized = self._deserialize("Script", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}"} # type: ignore def _create_or_update_initial( self, @@ -450,33 +439,53 @@ def _create_or_update_initial( cluster_name: str, database_name: str, script_name: str, - parameters: "_models.Script", + parameters: Union[_models.Script, IO], **kwargs: Any - ) -> "_models.Script": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Script"] + ) -> _models.Script: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Script') + 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.Script] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Script") + + request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, script_name=script_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -484,21 +493,102 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Script', pipeline_response) + deserialized = self._deserialize("Script", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Script', pipeline_response) + deserialized = self._deserialize("Script", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('Script', pipeline_response) + deserialized = self._deserialize("Script", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + script_name: str, + parameters: _models.Script, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Script]: + """Creates a Kusto database script. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param script_name: The name of the Kusto database script. Required. + :type script_name: str + :param parameters: The Kusto Script parameters contains the KQL to run. Required. + :type parameters: ~azure.mgmt.kusto.models.Script + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Script or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.Script] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + script_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Script]: + """Creates a Kusto database script. + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param script_name: The name of the Kusto database script. Required. + :type script_name: str + :param parameters: The Kusto Script parameters contains the KQL to run. 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 Script or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.Script] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -507,21 +597,26 @@ def begin_create_or_update( cluster_name: str, database_name: str, script_name: str, - parameters: "_models.Script", + parameters: Union[_models.Script, IO], **kwargs: Any - ) -> LROPoller["_models.Script"]: + ) -> LROPoller[_models.Script]: """Creates a Kusto database script. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str - :param script_name: The name of the Kusto database script. + :param script_name: The name of the Kusto database script. Required. :type script_name: str - :param parameters: The Kusto Script parameters contains the KQL to run. - :type parameters: ~kusto_management_client.models.Script + :param parameters: The Kusto Script parameters contains the KQL to run. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.kusto.models.Script 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 @@ -531,52 +626,56 @@ def begin_create_or_update( :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. :return: An instance of LROPoller that returns either Script or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~kusto_management_client.models.Script] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.Script] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Script"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Script] + 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, database_name=database_name, script_name=script_name, parameters=parameters, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('Script', pipeline_response) + deserialized = self._deserialize("Script", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}"} # type: ignore def _update_initial( self, @@ -584,33 +683,53 @@ def _update_initial( cluster_name: str, database_name: str, script_name: str, - parameters: "_models.Script", + parameters: Union[_models.Script, IO], **kwargs: Any - ) -> "_models.Script": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Script"] + ) -> _models.Script: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Script') + 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.Script] - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Script") + + request = build_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, script_name=script_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -619,20 +738,103 @@ def _update_initial( response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('Script', pipeline_response) + deserialized = self._deserialize("Script", pipeline_response) if response.status_code == 202: - response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) - - deserialized = self._deserialize('Script', pipeline_response) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = self._deserialize("Script", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + script_name: str, + parameters: _models.Script, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Script]: + """Updates a database script. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param script_name: The name of the Kusto database script. Required. + :type script_name: str + :param parameters: The Kusto Script parameters contains to the KQL to run. Required. + :type parameters: ~azure.mgmt.kusto.models.Script + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Script or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.Script] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + script_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Script]: + """Updates a database script. + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param script_name: The name of the Kusto database script. Required. + :type script_name: str + :param parameters: The Kusto Script parameters contains to the KQL to run. 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 Script or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.Script] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -641,21 +843,26 @@ def begin_update( cluster_name: str, database_name: str, script_name: str, - parameters: "_models.Script", + parameters: Union[_models.Script, IO], **kwargs: Any - ) -> LROPoller["_models.Script"]: + ) -> LROPoller[_models.Script]: """Updates a database script. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str - :param script_name: The name of the Kusto database script. + :param script_name: The name of the Kusto database script. Required. :type script_name: str - :param parameters: The Kusto Script parameters contains to the KQL to run. - :type parameters: ~kusto_management_client.models.Script + :param parameters: The Kusto Script parameters contains to the KQL to run. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.kusto.models.Script 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 @@ -665,80 +872,92 @@ def begin_update( :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. :return: An instance of LROPoller that returns either Script or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~kusto_management_client.models.Script] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.Script] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Script"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Script] + 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, database_name=database_name, script_name=script_name, parameters=parameters, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('Script', pipeline_response) + deserialized = self._deserialize("Script", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}"} # type: ignore - def _delete_initial( - self, - resource_group_name: str, - cluster_name: str, - database_name: str, - script_name: str, - **kwargs: Any + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, cluster_name: str, database_name: str, script_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', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) 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, database_name=database_name, script_name=script_name, - template_url=self._delete_initial.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -748,27 +967,22 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}"} # type: ignore @distributed_trace def begin_delete( - self, - resource_group_name: str, - cluster_name: str, - database_name: str, - script_name: str, - **kwargs: Any + self, resource_group_name: str, cluster_name: str, database_name: str, script_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a Kusto principalAssignment. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str - :param script_name: The name of the Kusto database script. + :param script_name: The name of the Kusto database script. Required. :type script_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. @@ -780,45 +994,112 @@ def begin_delete( Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.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, database_name=database_name, script_name=script_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) - 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, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}"} # type: ignore + + @overload + def check_name_availability( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + script_name: _models.ScriptCheckNameRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the script name is valid and is not already in use. - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}'} # type: ignore + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param script_name: The name of the script. Required. + :type script_name: ~azure.mgmt.kusto.models.ScriptCheckNameRequest + :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: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, + resource_group_name: str, + cluster_name: str, + database_name: str, + script_name: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the script name is valid and is not already in use. + + :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param database_name: The name of the database in the Kusto cluster. Required. + :type database_name: str + :param script_name: The name of the script. Required. + :type script_name: 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: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def check_name_availability( @@ -826,59 +1107,82 @@ def check_name_availability( resource_group_name: str, cluster_name: str, database_name: str, - script_name: "_models.ScriptCheckNameRequest", + script_name: Union[_models.ScriptCheckNameRequest, IO], **kwargs: Any - ) -> "_models.CheckNameResult": + ) -> _models.CheckNameResult: """Checks that the script name is valid and is not already in use. :param resource_group_name: The name of the resource group containing the Kusto cluster. + Required. :type resource_group_name: str - :param cluster_name: The name of the Kusto cluster. + :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str - :param database_name: The name of the database in the Kusto cluster. + :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str - :param script_name: The name of the script. - :type script_name: ~kusto_management_client.models.ScriptCheckNameRequest + :param script_name: The name of the script. Is either a model type or a IO type. Required. + :type script_name: ~azure.mgmt.kusto.models.ScriptCheckNameRequest 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: CheckNameResult, or the result of cls(response) - :rtype: ~kusto_management_client.models.CheckNameResult - :raises: ~azure.core.exceptions.HttpResponseError + :return: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.kusto.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(script_name, 'ScriptCheckNameRequest') + 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.CheckNameResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(script_name, (IO, bytes)): + _content = script_name + else: + _json = self._serialize.body(script_name, "ScriptCheckNameRequest") request = build_check_name_availability_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + 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) + 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 + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameResult', pipeline_response) + deserialized = self._deserialize("CheckNameResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scriptsCheckNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scriptsCheckNameAvailability"} # type: ignore