diff --git a/sdk/kusto/azure-mgmt-kusto/README.md b/sdk/kusto/azure-mgmt-kusto/README.md index f9aa951bc330..b1d6aa215636 100644 --- a/sdk/kusto/azure-mgmt-kusto/README.md +++ b/sdk/kusto/azure-mgmt-kusto/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure Kusto Management Client Library. -This package has been tested with Python 3.7+. +This package has been tested with Python 3.8+. For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). ## _Disclaimer_ @@ -12,7 +12,7 @@ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For ### Prerequisites -- Python 3.7+ is required to use this package. +- Python 3.8+ is required to use this package. - [Azure subscription](https://azure.microsoft.com/free/) ### Install the package diff --git a/sdk/kusto/azure-mgmt-kusto/_meta.json b/sdk/kusto/azure-mgmt-kusto/_meta.json index ada7e4731a94..a3051e9669c1 100644 --- a/sdk/kusto/azure-mgmt-kusto/_meta.json +++ b/sdk/kusto/azure-mgmt-kusto/_meta.json @@ -1,11 +1,11 @@ { - "commit": "5775c90db370eb73a5cd7ccb36e16c34630a5c8c", + "commit": "9e26e4547273425db4268330dd3e5e12a9253e3e", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.7", + "autorest": "3.10.2", "use": [ - "@autorest/python@6.7.1", - "@autorest/modelerfour@4.26.2" + "@autorest/python@6.19.0", + "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/azure-kusto/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.7.1 --use=@autorest/modelerfour@4.26.2 --version=3.9.7 --version-tolerant=False", + "autorest_command": "autorest specification/azure-kusto/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.19.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --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/_configuration.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/_configuration.py index 7cb697c1fb37..3b80e57a8d21 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/_configuration.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/_configuration.py @@ -8,7 +8,6 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy @@ -19,7 +18,7 @@ from azure.core.credentials import TokenCredential -class KustoManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class KustoManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for KustoManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,14 +28,13 @@ class KustoManagementClientConfiguration(Configuration): # pylint: disable=too- :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-08-15". Note that overriding this + :keyword api_version: Api Version. Default value is "2024-04-13". 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: - super(KustoManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-08-15") + api_version: str = kwargs.pop("api_version", "2024-04-13") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs 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.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( 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 63e091f5e7b2..e2b0cdcf6f5c 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 @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from ._configuration import KustoManagementClientConfiguration @@ -88,7 +91,7 @@ class KustoManagementClient: # pylint: disable=client-accepts-api-version-keywo :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2023-08-15". Note that overriding this + :keyword api_version: Api Version. Default value is "2024-04-13". 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 @@ -105,7 +108,25 @@ def __init__( self._config = KustoManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -148,7 +169,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -168,12 +189,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "KustoManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self 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 f99e77fef986..17dbc073e01b 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/_patch.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # 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(): diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/_serialization.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/_serialization.py index 4bae2292227b..8139854b97bb 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/_serialization.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/_serialization.py @@ -63,8 +63,8 @@ import isodate # type: ignore -from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback -from azure.core.serialization import NULL as AzureCoreNull +from azure.core.exceptions import DeserializationError, SerializationError +from azure.core.serialization import NULL as CoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") @@ -124,7 +124,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: pass return ET.fromstring(data_as_str) # nosec - except ET.ParseError: + except ET.ParseError as err: # 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 @@ -143,7 +143,9 @@ def _json_attemp(data): # 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("XML is invalid") from err + elif content_type.startswith("text/"): + return data_as_str raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod @@ -170,13 +172,6 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], return None -try: - basestring # type: ignore - unicode_str = unicode # type: ignore -except NameError: - basestring = str - unicode_str = str - _LOGGER = logging.getLogger(__name__) try: @@ -295,7 +290,7 @@ class Model(object): _validation: Dict[str, Dict[str, Any]] = {} def __init__(self, **kwargs: Any) -> None: - self.additional_properties: Dict[str, Any] = {} + self.additional_properties: Optional[Dict[str, Any]] = {} for k in kwargs: if k not in self._attribute_map: _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) @@ -340,7 +335,7 @@ def _create_xml_node(cls): return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to azure from this model. + """Return the JSON that would be sent to server from this model. This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. @@ -351,7 +346,7 @@ def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) # type: ignore def as_dict( self, @@ -390,7 +385,7 @@ def my_key_transformer(key, attr_desc, value): :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) # type: ignore @classmethod def _infer_class_models(cls): @@ -415,7 +410,7 @@ def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = N :raises: DeserializationError if something went wrong """ deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def from_dict( @@ -445,7 +440,7 @@ def from_dict( if key_extractors is None else key_extractors ) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def _flatten_subtype(cls, key, objects): @@ -545,7 +540,7 @@ class Serializer(object): "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None): self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -561,7 +556,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): "[]": self.serialize_iter, "{}": self.serialize_dict, } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_transformer = full_restapi_key_transformer self.client_side_validation = True @@ -649,7 +644,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): 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) + local_node.text = str(new_attr) serialized.append(local_node) # type: ignore else: # JSON for k in reversed(keys): # type: ignore @@ -668,7 +663,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): 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) + raise SerializationError(msg) from err else: return serialized @@ -710,7 +705,7 @@ def body(self, data, data_type, **kwargs): ] data = deserializer._deserialize(data_type, data) except DeserializationError as err: - raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + raise SerializationError("Unable to build a model: " + str(err)) from err return self._serialize(data, data_type, **kwargs) @@ -730,6 +725,7 @@ def url(self, name, data, data_type, **kwargs): if kwargs.get("skip_quote") is True: output = str(output) + output = output.replace("{", quote("{")).replace("}", quote("}")) else: output = quote(str(output), safe="") except SerializationError: @@ -744,7 +740,7 @@ def query(self, name, data, data_type, **kwargs): :param str data_type: The type to be serialized from. :keyword bool skip_quote: Whether to skip quote the serialized result. Defaults to False. - :rtype: str + :rtype: str, list :raises: TypeError if serialization fails. :raises: ValueError if data is None """ @@ -753,7 +749,7 @@ def query(self, name, data, data_type, **kwargs): if data_type.startswith("["): internal_data_type = data_type[1:-1] do_quote = not kwargs.get("skip_quote", False) - return str(self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs)) + return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) # Not a list, regular serialization output = self.serialize_data(data, data_type, **kwargs) @@ -804,7 +800,7 @@ def serialize_data(self, data, data_type, **kwargs): raise ValueError("No value for given attribute") try: - if data is AzureCoreNull: + if data is CoreNull: return None if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) @@ -824,7 +820,7 @@ def serialize_data(self, data, data_type, **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) + raise SerializationError(msg.format(data, data_type)) from err else: return self._serialize(data, **kwargs) @@ -993,7 +989,7 @@ def serialize_object(self, attr, **kwargs): 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: + if obj_type is str: return self.serialize_unicode(attr) if obj_type is datetime.datetime: return self.serialize_iso(attr) @@ -1170,10 +1166,10 @@ def serialize_iso(attr, **kwargs): return date + microseconds + "Z" except (ValueError, OverflowError) as err: msg = "Unable to serialize datetime object." - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err except AttributeError as err: msg = "ISO-8601 object must be valid Datetime object." - raise_with_traceback(TypeError, msg, err) + raise TypeError(msg) from err @staticmethod def serialize_unix(attr, **kwargs): @@ -1209,7 +1205,6 @@ def rest_key_extractor(attr, attr_desc, 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:]) @@ -1230,7 +1225,6 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, 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:]) @@ -1371,7 +1365,7 @@ class Deserializer(object): 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: Optional[Mapping[str, Type[ModelType]]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None): self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1391,7 +1385,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): "duration": (isodate.Duration, datetime.timedelta), "iso-8601": (datetime.datetime), } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = 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 @@ -1444,12 +1438,12 @@ def _deserialize(self, target_obj, data): response, class_name = self._classify_target(target_obj, data) - if isinstance(response, basestring): + if isinstance(response, str): return self.deserialize_data(data, response) elif isinstance(response, type) and issubclass(response, Enum): return self.deserialize_enum(data, response) - if data is None: + if data is None or data is CoreNull: return data try: attributes = response._attribute_map # type: ignore @@ -1481,7 +1475,7 @@ def _deserialize(self, target_obj, data): d_attrs[attr] = value except (AttributeError, TypeError, KeyError) as err: msg = "Unable to deserialize to object: " + class_name # type: ignore - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: additional_properties = self._build_additional_properties(attributes, data) return self._instantiate_model(response, d_attrs, additional_properties) @@ -1515,14 +1509,14 @@ def _classify_target(self, target, data): if target is None: return None, None - if isinstance(target, basestring): + if isinstance(target, str): try: target = self.dependencies[target] except KeyError: return target, target try: - target = target._classify(data, self.dependencies) + target = target._classify(data, self.dependencies) # type: ignore except AttributeError: pass # Target is not a Model, no classify return target, target.__class__.__name__ # type: ignore @@ -1578,7 +1572,7 @@ def _unpack_content(raw_data, content_type=None): 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"): + if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore return raw_data @@ -1652,7 +1646,7 @@ def deserialize_data(self, data, data_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) + raise DeserializationError(msg) from err else: return self._deserialize(obj_type, data) @@ -1700,7 +1694,7 @@ def deserialize_object(self, attr, **kwargs): if isinstance(attr, ET.Element): # Do no recurse on XML, just return the tree as-is return attr - if isinstance(attr, basestring): + if isinstance(attr, str): return self.deserialize_basic(attr, "str") obj_type = type(attr) if obj_type in self.basic_types: @@ -1757,7 +1751,7 @@ def deserialize_basic(self, attr, data_type): if data_type == "bool": if attr in [True, False, 1, 0]: return bool(attr) - elif isinstance(attr, basestring): + elif isinstance(attr, str): if attr.lower() in ["true", "1"]: return True elif attr.lower() in ["false", "0"]: @@ -1808,7 +1802,6 @@ def deserialize_enum(data, enum_obj): 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: @@ -1862,10 +1855,10 @@ def deserialize_decimal(attr): if isinstance(attr, ET.Element): attr = attr.text try: - return decimal.Decimal(attr) # type: ignore + return decimal.Decimal(str(attr)) # type: ignore except decimal.DecimalException as err: msg = "Invalid decimal {}".format(attr) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err @staticmethod def deserialize_long(attr): @@ -1893,7 +1886,7 @@ def deserialize_duration(attr): duration = isodate.parse_duration(attr) except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize duration object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return duration @@ -1910,7 +1903,7 @@ def deserialize_date(attr): if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore 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) + return isodate.parse_date(attr, defaultmonth=0, defaultday=0) @staticmethod def deserialize_time(attr): @@ -1945,7 +1938,7 @@ def deserialize_rfc(attr): 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) + raise DeserializationError(msg) from err else: return date_obj @@ -1982,7 +1975,7 @@ def deserialize_iso(attr): raise OverflowError("Hit max or min date") except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -1998,9 +1991,10 @@ def deserialize_unix(attr): if isinstance(attr, ET.Element): attr = int(attr.text) # type: ignore try: + attr = int(attr) 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) + raise DeserializationError(msg) from 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 deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request 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 a78dee7e23cf..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 = "3.3.0" +VERSION = "2.0.0b1" 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 317f696c1f0e..b97a0eb8028d 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 @@ -8,7 +8,6 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy @@ -19,7 +18,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class KustoManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class KustoManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for KustoManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,14 +28,13 @@ class KustoManagementClientConfiguration(Configuration): # pylint: disable=too- :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-08-15". Note that overriding this + :keyword api_version: Api Version. Default value is "2024-04-13". 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: - super(KustoManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-08-15") + api_version: str = kwargs.pop("api_version", "2024-04-13") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k 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.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( 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 ee1de52b0766..b51f17a8f47a 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 @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from .._serialization import Deserializer, Serializer @@ -88,7 +91,7 @@ class KustoManagementClient: # pylint: disable=client-accepts-api-version-keywo :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2023-08-15". Note that overriding this + :keyword api_version: Api Version. Default value is "2024-04-13". 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 @@ -105,7 +108,25 @@ def __init__( self._config = KustoManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -148,7 +169,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -168,12 +191,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "KustoManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self 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 f99e77fef986..17dbc073e01b 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 @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # 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(): 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 28f6bff31453..ae83f1a90628 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,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import AsyncHttpResponse, 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 @@ -30,7 +32,6 @@ 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, @@ -39,6 +40,10 @@ build_list_by_cluster_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -85,7 +90,6 @@ async def check_name_availability( :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: @@ -96,7 +100,7 @@ async def check_name_availability( self, resource_group_name: str, cluster_name: str, - resource_name: IO, + resource_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -110,11 +114,10 @@ async def check_name_availability( :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 + :type resource_name: IO[bytes] :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: @@ -125,7 +128,7 @@ async def check_name_availability( self, resource_group_name: str, cluster_name: str, - resource_name: Union[_models.AttachedDatabaseConfigurationsCheckNameRequest, IO], + resource_name: Union[_models.AttachedDatabaseConfigurationsCheckNameRequest, IO[bytes]], **kwargs: Any ) -> _models.CheckNameResult: """Checks that the attached database configuration resource name is valid and is not already in @@ -137,18 +140,14 @@ async def check_name_availability( :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str :param resource_name: The name of the resource. Is either a - AttachedDatabaseConfigurationsCheckNameRequest type or a IO type. Required. + AttachedDatabaseConfigurationsCheckNameRequest type or a IO[bytes] 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 + IO[bytes] :return: CheckNameResult or the result of cls(response) :rtype: ~azure.mgmt.kusto.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -171,7 +170,7 @@ async def check_name_availability( else: _json = self._serialize.body(resource_name, "AttachedDatabaseConfigurationsCheckNameRequest") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, @@ -179,16 +178,14 @@ async def check_name_availability( content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -198,16 +195,12 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameResult", pipeline_response) + deserialized = self._deserialize("CheckNameResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurationCheckNameAvailability" - } + return deserialized # type: ignore @distributed_trace def list_by_cluster( @@ -220,7 +213,6 @@ def list_by_cluster( :type resource_group_name: str :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 AttachedDatabaseConfiguration or the result of cls(response) :rtype: @@ -233,7 +225,7 @@ def list_by_cluster( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AttachedDatabaseConfigurationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -244,17 +236,15 @@ def list_by_cluster( def prepare_request(next_link=None): if not next_link: - request = build_list_by_cluster_request( + _request = build_list_by_cluster_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_cluster.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -266,13 +256,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AttachedDatabaseConfigurationListResult", pipeline_response) @@ -282,11 +271,11 @@ async def extract_data(pipeline_response): return None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -299,10 +288,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_cluster.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations" - } - @distributed_trace_async async def get( self, resource_group_name: str, cluster_name: str, attached_database_configuration_name: str, **kwargs: Any @@ -317,12 +302,11 @@ async def get( :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: ~azure.mgmt.kusto.models.AttachedDatabaseConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -336,22 +320,20 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AttachedDatabaseConfiguration] = kwargs.pop("cls", None) - request = build_get_request( + _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, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -361,26 +343,22 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AttachedDatabaseConfiguration", pipeline_response) + deserialized = self._deserialize("AttachedDatabaseConfiguration", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, cluster_name: str, attached_database_configuration_name: str, - parameters: Union[_models.AttachedDatabaseConfiguration, IO], + parameters: Union[_models.AttachedDatabaseConfiguration, IO[bytes]], **kwargs: Any - ) -> _models.AttachedDatabaseConfiguration: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -393,7 +371,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AttachedDatabaseConfiguration] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -403,7 +381,7 @@ async def _create_or_update_initial( else: _json = self._serialize.body(parameters, "AttachedDatabaseConfiguration") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, attached_database_configuration_name=attached_database_configuration_name, @@ -412,48 +390,41 @@ async def _create_or_update_initial( 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("AttachedDatabaseConfiguration", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AttachedDatabaseConfiguration", pipeline_response) - if response.status_code == 202: response_headers["Azure-AsyncOperation"] = self._deserialize( "str", response.headers.get("Azure-AsyncOperation") ) - deserialized = self._deserialize("AttachedDatabaseConfiguration", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}" - } - @overload async def begin_create_or_update( self, @@ -480,14 +451,6 @@ async def begin_create_or_update( :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: @@ -501,7 +464,7 @@ async def begin_create_or_update( resource_group_name: str, cluster_name: str, attached_database_configuration_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -517,18 +480,10 @@ async def begin_create_or_update( Required. :type attached_database_configuration_name: str :param parameters: The database parameters supplied to the CreateOrUpdate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :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: @@ -542,7 +497,7 @@ async def begin_create_or_update( resource_group_name: str, cluster_name: str, attached_database_configuration_name: str, - parameters: Union[_models.AttachedDatabaseConfiguration, IO], + parameters: Union[_models.AttachedDatabaseConfiguration, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.AttachedDatabaseConfiguration]: """Creates or updates an attached database configuration. @@ -556,19 +511,8 @@ async def begin_create_or_update( Required. :type attached_database_configuration_name: str :param parameters: The database parameters supplied to the CreateOrUpdate operation. Is either - a AttachedDatabaseConfiguration 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 - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + a AttachedDatabaseConfiguration type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.kusto.models.AttachedDatabaseConfiguration or IO[bytes] :return: An instance of AsyncLROPoller that returns either AttachedDatabaseConfiguration or the result of cls(response) :rtype: @@ -597,12 +541,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AttachedDatabaseConfiguration", pipeline_response) + deserialized = self._deserialize("AttachedDatabaseConfiguration", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -612,22 +557,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.AttachedDatabaseConfiguration].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}" - } + return AsyncLROPoller[_models.AttachedDatabaseConfiguration]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, cluster_name: str, attached_database_configuration_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -639,29 +582,32 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _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, 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -673,12 +619,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -694,14 +640,6 @@ async def begin_delete( :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. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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: @@ -715,7 +653,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, attached_database_configuration_name=attached_database_configuration_name, @@ -725,11 +663,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -738,14 +677,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # 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 ddbdbbebba94..18043de212b8 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,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import AsyncHttpResponse, 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 @@ -30,7 +32,6 @@ 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, @@ -39,6 +40,10 @@ build_list_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -85,7 +90,6 @@ async def check_name_availability( :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: @@ -96,7 +100,7 @@ async def check_name_availability( self, resource_group_name: str, cluster_name: str, - principal_assignment_name: IO, + principal_assignment_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -109,11 +113,10 @@ async def check_name_availability( :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 + :type principal_assignment_name: IO[bytes] :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: @@ -124,7 +127,7 @@ async def check_name_availability( self, resource_group_name: str, cluster_name: str, - principal_assignment_name: Union[_models.ClusterPrincipalAssignmentCheckNameRequest, IO], + principal_assignment_name: Union[_models.ClusterPrincipalAssignmentCheckNameRequest, IO[bytes]], **kwargs: Any ) -> _models.CheckNameResult: """Checks that the principal assignment name is valid and is not already in use. @@ -135,18 +138,14 @@ async def check_name_availability( :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str :param principal_assignment_name: The name of the principal assignment. Is either a - ClusterPrincipalAssignmentCheckNameRequest type or a IO type. Required. + ClusterPrincipalAssignmentCheckNameRequest type or a IO[bytes] type. Required. :type principal_assignment_name: - ~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 + ~azure.mgmt.kusto.models.ClusterPrincipalAssignmentCheckNameRequest or IO[bytes] :return: CheckNameResult or the result of cls(response) :rtype: ~azure.mgmt.kusto.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -169,7 +168,7 @@ async def check_name_availability( else: _json = self._serialize.body(principal_assignment_name, "ClusterPrincipalAssignmentCheckNameRequest") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, @@ -177,16 +176,14 @@ async def check_name_availability( content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -196,16 +193,12 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameResult", pipeline_response) + deserialized = self._deserialize("CheckNameResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/checkPrincipalAssignmentNameAvailability" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -220,12 +213,11 @@ async def get( :type cluster_name: str :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: ~azure.mgmt.kusto.models.ClusterPrincipalAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -239,22 +231,20 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ClusterPrincipalAssignment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_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, - 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -264,26 +254,22 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ClusterPrincipalAssignment", pipeline_response) + deserialized = self._deserialize("ClusterPrincipalAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments/{principalAssignmentName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, cluster_name: str, principal_assignment_name: str, - parameters: Union[_models.ClusterPrincipalAssignment, IO], + parameters: Union[_models.ClusterPrincipalAssignment, IO[bytes]], **kwargs: Any - ) -> _models.ClusterPrincipalAssignment: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -296,7 +282,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ClusterPrincipalAssignment] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -306,7 +292,7 @@ async def _create_or_update_initial( else: _json = self._serialize.body(parameters, "ClusterPrincipalAssignment") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, principal_assignment_name=principal_assignment_name, @@ -315,40 +301,35 @@ async def _create_or_update_initial( 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ClusterPrincipalAssignment", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ClusterPrincipalAssignment", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments/{principalAssignmentName}" - } - @overload async def begin_create_or_update( self, @@ -375,14 +356,6 @@ async def begin_create_or_update( :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] @@ -395,7 +368,7 @@ async def begin_create_or_update( resource_group_name: str, cluster_name: str, principal_assignment_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -411,18 +384,10 @@ async def begin_create_or_update( :type principal_assignment_name: str :param parameters: The Kusto cluster principalAssignment's parameters supplied for the operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :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] @@ -435,7 +400,7 @@ async def begin_create_or_update( resource_group_name: str, cluster_name: str, principal_assignment_name: str, - parameters: Union[_models.ClusterPrincipalAssignment, IO], + parameters: Union[_models.ClusterPrincipalAssignment, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.ClusterPrincipalAssignment]: """Create a Kusto cluster principalAssignment. @@ -448,19 +413,8 @@ async def begin_create_or_update( :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. Is either a ClusterPrincipalAssignment 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 - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + operation. Is either a ClusterPrincipalAssignment type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.kusto.models.ClusterPrincipalAssignment or IO[bytes] :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] @@ -488,12 +442,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ClusterPrincipalAssignment", pipeline_response) + deserialized = self._deserialize("ClusterPrincipalAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -503,22 +458,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.ClusterPrincipalAssignment].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments/{principalAssignmentName}" - } + return AsyncLROPoller[_models.ClusterPrincipalAssignment]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, cluster_name: str, principal_assignment_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -530,29 +483,32 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_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, - 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -564,12 +520,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments/{principalAssignmentName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -584,14 +540,6 @@ async def begin_delete( :type cluster_name: str :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. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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: @@ -605,7 +553,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, principal_assignment_name=principal_assignment_name, @@ -615,11 +563,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -628,17 +577,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments/{principalAssignmentName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def list( @@ -651,7 +596,6 @@ def list( :type resource_group_name: str :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 ClusterPrincipalAssignment or the result of cls(response) :rtype: @@ -664,7 +608,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ClusterPrincipalAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -675,17 +619,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -697,13 +639,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ClusterPrincipalAssignmentListResult", pipeline_response) @@ -713,11 +654,11 @@ async def extract_data(pipeline_response): return None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -729,7 +670,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments" - } 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 f1e2d12d7031..8e5330adae8a 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,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import AsyncHttpResponse, 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 @@ -30,8 +32,8 @@ 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_callout_policies_request, build_add_language_extensions_request, build_check_name_availability_request, build_create_or_update_request, @@ -40,6 +42,8 @@ build_diagnose_virtual_network_request, build_get_request, build_list_by_resource_group_request, + build_list_callout_policies_request, + build_list_follower_databases_get_request, build_list_follower_databases_request, build_list_language_extensions_request, build_list_outbound_network_dependencies_endpoints_request, @@ -47,12 +51,17 @@ build_list_skus_by_resource_request, build_list_skus_request, build_migrate_request, + build_remove_callout_policy_request, build_remove_language_extensions_request, build_start_request, build_stop_request, build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -85,12 +94,11 @@ async def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) :type resource_group_name: str :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: ~azure.mgmt.kusto.models.Cluster :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -104,21 +112,19 @@ async def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Cluster] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -128,27 +134,23 @@ async def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Cluster", pipeline_response) + deserialized = self._deserialize("Cluster", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, cluster_name: str, - parameters: Union[_models.Cluster, IO], + parameters: Union[_models.Cluster, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> _models.Cluster: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -161,7 +163,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Cluster] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -171,7 +173,7 @@ async def _create_or_update_initial( else: _json = self._serialize.body(parameters, "Cluster") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, @@ -181,40 +183,35 @@ async def _create_or_update_initial( 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Cluster", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Cluster", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}" - } - @overload async def begin_create_or_update( self, @@ -248,14 +245,6 @@ async def begin_create_or_update( :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] @@ -267,7 +256,7 @@ async def begin_create_or_update( self, resource_group_name: str, cluster_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, if_none_match: Optional[str] = None, *, @@ -283,7 +272,7 @@ async def begin_create_or_update( :type cluster_name: str :param parameters: The Kusto cluster parameters supplied to the CreateOrUpdate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :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. @@ -295,14 +284,6 @@ async def begin_create_or_update( :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] @@ -314,7 +295,7 @@ async def begin_create_or_update( self, resource_group_name: str, cluster_name: str, - parameters: Union[_models.Cluster, IO], + parameters: Union[_models.Cluster, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any @@ -327,8 +308,8 @@ async def begin_create_or_update( :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 Cluster type or a IO type. Required. - :type parameters: ~azure.mgmt.kusto.models.Cluster or IO + either a Cluster type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.kusto.models.Cluster or IO[bytes] :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. @@ -337,17 +318,6 @@ async def begin_create_or_update( 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] @@ -376,12 +346,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Cluster", pipeline_response) + deserialized = self._deserialize("Cluster", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -391,27 +362,25 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Cluster].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}" - } + return AsyncLROPoller[_models.Cluster]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, resource_group_name: str, cluster_name: str, - parameters: Union[_models.ClusterUpdate, IO], + parameters: Union[_models.ClusterUpdate, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any - ) -> _models.Cluster: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -424,7 +393,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Cluster] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -434,7 +403,7 @@ async def _update_initial( else: _json = self._serialize.body(parameters, "ClusterUpdate") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, @@ -443,54 +412,48 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Cluster", pipeline_response) - if response.status_code == 201: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) 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["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Azure-AsyncOperation"] = self._deserialize( "str", response.headers.get("Azure-AsyncOperation") ) - deserialized = self._deserialize("Cluster", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}" - } - @overload async def begin_update( self, @@ -518,14 +481,6 @@ async def begin_update( :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] @@ -537,7 +492,7 @@ async def begin_update( self, resource_group_name: str, cluster_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, *, content_type: str = "application/json", @@ -551,7 +506,7 @@ async def begin_update( :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 + :type parameters: IO[bytes] :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. @@ -559,14 +514,6 @@ async def begin_update( :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] @@ -578,7 +525,7 @@ async def begin_update( self, resource_group_name: str, cluster_name: str, - parameters: Union[_models.ClusterUpdate, IO], + parameters: Union[_models.ClusterUpdate, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any ) -> AsyncLROPoller[_models.Cluster]: @@ -590,23 +537,12 @@ async def begin_update( :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. Is either a - ClusterUpdate type or a IO type. Required. - :type parameters: ~azure.mgmt.kusto.models.ClusterUpdate or IO + ClusterUpdate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.kusto.models.ClusterUpdate or IO[bytes] :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. 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] @@ -634,12 +570,13 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Cluster", pipeline_response) + deserialized = self._deserialize("Cluster", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -649,22 +586,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Cluster].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}" - } + return AsyncLROPoller[_models.Cluster]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, cluster_name: str, **kwargs: Any - ) -> None: - error_map = { + async def _delete_initial(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -676,28 +609,31 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -709,12 +645,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -725,14 +661,6 @@ async def begin_delete(self, resource_group_name: str, cluster_name: str, **kwar :type resource_group_name: str :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. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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: @@ -746,7 +674,7 @@ async def begin_delete(self, resource_group_name: str, cluster_name: str, **kwar lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, api_version=api_version, @@ -755,11 +683,12 @@ async def begin_delete(self, resource_group_name: str, cluster_name: str, **kwar params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -768,22 +697,16 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _stop_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, cluster_name: str, **kwargs: Any - ) -> None: - error_map = { + async def _stop_initial(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -795,28 +718,31 @@ async def _stop_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -828,12 +754,12 @@ async def _stop_initial( # pylint: disable=inconsistent-return-statements "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _stop_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/stop" - } + return deserialized # type: ignore @distributed_trace_async async def begin_stop(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -844,14 +770,6 @@ async def begin_stop(self, resource_group_name: str, cluster_name: str, **kwargs :type resource_group_name: str :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. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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: @@ -865,7 +783,7 @@ async def begin_stop(self, resource_group_name: str, cluster_name: str, **kwargs lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._stop_initial( # type: ignore + raw_result = await self._stop_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, api_version=api_version, @@ -874,11 +792,12 @@ async def begin_stop(self, resource_group_name: str, cluster_name: str, **kwargs params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -887,22 +806,16 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_stop.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/stop" - } - - async def _start_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, cluster_name: str, **kwargs: Any - ) -> None: - error_map = { + async def _start_initial(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -914,28 +827,31 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_start_request( + _request = build_start_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -947,12 +863,12 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _start_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/start" - } + return deserialized # type: ignore @distributed_trace_async async def begin_start(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -963,14 +879,6 @@ async def begin_start(self, resource_group_name: str, cluster_name: str, **kwarg :type resource_group_name: str :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. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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: @@ -984,7 +892,7 @@ async def begin_start(self, resource_group_name: str, cluster_name: str, **kwarg lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._start_initial( # type: ignore + raw_result = await self._start_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, api_version=api_version, @@ -993,11 +901,12 @@ async def begin_start(self, resource_group_name: str, cluster_name: str, **kwarg params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -1006,26 +915,22 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_start.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/start" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _migrate_initial( # pylint: disable=inconsistent-return-statements + async def _migrate_initial( self, resource_group_name: str, cluster_name: str, - cluster_migrate_request: Union[_models.ClusterMigrateRequest, IO], + cluster_migrate_request: Union[_models.ClusterMigrateRequest, IO[bytes]], **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1038,7 +943,7 @@ async def _migrate_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1048,7 +953,7 @@ async def _migrate_initial( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(cluster_migrate_request, "ClusterMigrateRequest") - request = build_migrate_request( + _request = build_migrate_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, @@ -1056,21 +961,24 @@ async def _migrate_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self._migrate_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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1082,12 +990,12 @@ async def _migrate_initial( # pylint: disable=inconsistent-return-statements "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _migrate_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/migrate" - } + return deserialized # type: ignore @overload async def begin_migrate( @@ -1111,14 +1019,6 @@ async def begin_migrate( :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: @@ -1129,7 +1029,7 @@ async def begin_migrate( self, resource_group_name: str, cluster_name: str, - cluster_migrate_request: IO, + cluster_migrate_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1142,18 +1042,10 @@ async def begin_migrate( :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str :param cluster_migrate_request: The cluster migrate request parameters. Required. - :type cluster_migrate_request: IO + :type cluster_migrate_request: IO[bytes] :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: @@ -1164,7 +1056,7 @@ async def begin_migrate( self, resource_group_name: str, cluster_name: str, - cluster_migrate_request: Union[_models.ClusterMigrateRequest, IO], + cluster_migrate_request: Union[_models.ClusterMigrateRequest, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[None]: """Migrate data from a Kusto cluster to another cluster. @@ -1175,19 +1067,8 @@ async def begin_migrate( :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str :param cluster_migrate_request: The cluster migrate request parameters. Is either a - ClusterMigrateRequest type or a IO type. Required. - :type cluster_migrate_request: ~azure.mgmt.kusto.models.ClusterMigrateRequest 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. + ClusterMigrateRequest type or a IO[bytes] type. Required. + :type cluster_migrate_request: ~azure.mgmt.kusto.models.ClusterMigrateRequest or IO[bytes] :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: @@ -1202,7 +1083,7 @@ async def begin_migrate( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._migrate_initial( # type: ignore + raw_result = await self._migrate_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, cluster_migrate_request=cluster_migrate_request, @@ -1213,11 +1094,12 @@ async def begin_migrate( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -1226,17 +1108,100 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_follower_databases_get( + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.FollowerDatabaseDefinitionGet"]: + """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. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :return: An iterator like instance of either FollowerDatabaseDefinitionGet or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kusto.models.FollowerDatabaseDefinitionGet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.FollowerDatabaseListResultGet] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_follower_databases_get_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("FollowerDatabaseListResultGet", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response - begin_migrate.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/migrate" - } + return AsyncItemPaged(get_next, extract_data) @distributed_trace def list_follower_databases( @@ -1250,7 +1215,6 @@ def list_follower_databases( :type resource_group_name: str :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 FollowerDatabaseDefinition or the result of cls(response) :rtype: @@ -1263,7 +1227,7 @@ def list_follower_databases( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.FollowerDatabaseListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1274,17 +1238,15 @@ def list_follower_databases( def prepare_request(next_link=None): if not next_link: - request = build_list_follower_databases_request( + _request = build_list_follower_databases_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_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) else: # make call to next link with the client's api-version @@ -1296,13 +1258,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("FollowerDatabaseListResult", pipeline_response) @@ -1312,11 +1273,11 @@ async def extract_data(pipeline_response): return None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1329,18 +1290,14 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_follower_databases.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/listFollowerDatabases" - } - - async def _detach_follower_databases_initial( # pylint: disable=inconsistent-return-statements + async def _detach_follower_databases_initial( self, resource_group_name: str, cluster_name: str, - follower_database_to_remove: Union[_models.FollowerDatabaseDefinition, IO], + follower_database_to_remove: Union[_models.FollowerDatabaseDefinition, IO[bytes]], **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1353,7 +1310,7 @@ async def _detach_follower_databases_initial( # pylint: disable=inconsistent-re api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1363,7 +1320,7 @@ async def _detach_follower_databases_initial( # pylint: disable=inconsistent-re else: _json = self._serialize.body(follower_database_to_remove, "FollowerDatabaseDefinition") - request = build_detach_follower_databases_request( + _request = build_detach_follower_databases_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, @@ -1371,21 +1328,24 @@ async def _detach_follower_databases_initial( # pylint: disable=inconsistent-re content_type=content_type, json=_json, 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1397,12 +1357,12 @@ async def _detach_follower_databases_initial( # pylint: disable=inconsistent-re "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _detach_follower_databases_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/detachFollowerDatabases" - } + return deserialized # type: ignore @overload async def begin_detach_follower_databases( @@ -1426,14 +1386,6 @@ async def begin_detach_follower_databases( :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: @@ -1444,7 +1396,7 @@ async def begin_detach_follower_databases( self, resource_group_name: str, cluster_name: str, - follower_database_to_remove: IO, + follower_database_to_remove: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1457,18 +1409,10 @@ async def begin_detach_follower_databases( :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 + :type follower_database_to_remove: IO[bytes] :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: @@ -1479,7 +1423,7 @@ async def begin_detach_follower_databases( self, resource_group_name: str, cluster_name: str, - follower_database_to_remove: Union[_models.FollowerDatabaseDefinition, IO], + follower_database_to_remove: Union[_models.FollowerDatabaseDefinition, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[None]: """Detaches all followers of a database owned by this cluster. @@ -1490,19 +1434,9 @@ async def begin_detach_follower_databases( :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. Is either a - FollowerDatabaseDefinition 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 - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + FollowerDatabaseDefinition type or a IO[bytes] type. Required. + :type follower_database_to_remove: ~azure.mgmt.kusto.models.FollowerDatabaseDefinition or + IO[bytes] :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: @@ -1517,7 +1451,7 @@ async def begin_detach_follower_databases( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._detach_follower_databases_initial( # type: ignore + raw_result = await self._detach_follower_databases_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, follower_database_to_remove=follower_database_to_remove, @@ -1528,11 +1462,12 @@ async def begin_detach_follower_databases( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -1541,22 +1476,18 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_detach_follower_databases.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/detachFollowerDatabases" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _diagnose_virtual_network_initial( self, resource_group_name: str, cluster_name: str, **kwargs: Any - ) -> Optional[_models.DiagnoseVirtualNetworkResult]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1568,51 +1499,48 @@ async def _diagnose_virtual_network_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Optional[_models.DiagnoseVirtualNetworkResult]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_diagnose_virtual_network_request( + _request = build_diagnose_virtual_network_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("DiagnoseVirtualNetworkResult", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Azure-AsyncOperation"] = self._deserialize( "str", response.headers.get("Azure-AsyncOperation") ) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _diagnose_virtual_network_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/diagnoseVirtualNetwork" - } + return deserialized # type: ignore @distributed_trace_async async def begin_diagnose_virtual_network( @@ -1626,14 +1554,6 @@ async def begin_diagnose_virtual_network( :type resource_group_name: str :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. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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 DiagnoseVirtualNetworkResult or the result of cls(response) :rtype: @@ -1658,12 +1578,13 @@ async def begin_diagnose_virtual_network( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DiagnoseVirtualNetworkResult", pipeline_response) + deserialized = self._deserialize("DiagnoseVirtualNetworkResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1673,17 +1594,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.DiagnoseVirtualNetworkResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_diagnose_virtual_network.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/diagnoseVirtualNetwork" - } + return AsyncLROPoller[_models.DiagnoseVirtualNetworkResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Cluster"]: @@ -1692,7 +1611,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Cluster or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kusto.models.Cluster] :raises ~azure.core.exceptions.HttpResponseError: @@ -1703,7 +1621,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ClusterListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1714,16 +1632,14 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1735,13 +1651,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ClusterListResult", pipeline_response) @@ -1751,11 +1666,11 @@ async def extract_data(pipeline_response): return None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1768,15 +1683,10 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters" - } - @distributed_trace 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 Cluster or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kusto.models.Cluster] :raises ~azure.core.exceptions.HttpResponseError: @@ -1787,7 +1697,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Cluster"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ClusterListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1798,15 +1708,13 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Cluster"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1818,13 +1726,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ClusterListResult", pipeline_response) @@ -1834,11 +1741,11 @@ async def extract_data(pipeline_response): return None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1851,13 +1758,10 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/clusters"} - @distributed_trace 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 SkuDescription or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kusto.models.SkuDescription] :raises ~azure.core.exceptions.HttpResponseError: @@ -1868,7 +1772,7 @@ def list_skus(self, **kwargs: Any) -> AsyncIterable["_models.SkuDescription"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SkuDescriptionList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1879,15 +1783,13 @@ def list_skus(self, **kwargs: Any) -> AsyncIterable["_models.SkuDescription"]: def prepare_request(next_link=None): if not next_link: - request = build_list_skus_request( + _request = build_list_skus_request( subscription_id=self._config.subscription_id, 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) else: # make call to next link with the client's api-version @@ -1899,13 +1801,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("SkuDescriptionList", pipeline_response) @@ -1915,11 +1816,11 @@ async def extract_data(pipeline_response): return None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1932,8 +1833,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_skus.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/skus"} - @overload async def check_name_availability( self, @@ -1952,7 +1851,6 @@ async def check_name_availability( :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: @@ -1960,18 +1858,17 @@ async def check_name_availability( @overload async def check_name_availability( - self, location: str, cluster_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, location: str, cluster_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameResult: """Checks that the cluster name is valid and is not already in use. :param location: The name of Azure region. Required. :type location: str :param cluster_name: The name of the cluster. Required. - :type cluster_name: IO + :type cluster_name: IO[bytes] :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: @@ -1979,24 +1876,20 @@ async def check_name_availability( @distributed_trace_async async def check_name_availability( - self, location: str, cluster_name: Union[_models.ClusterCheckNameRequest, IO], **kwargs: Any + self, location: str, cluster_name: Union[_models.ClusterCheckNameRequest, IO[bytes]], **kwargs: Any ) -> _models.CheckNameResult: """Checks that the cluster name is valid and is not already in use. :param location: The name of Azure region. Required. :type location: str - :param cluster_name: The name of the cluster. Is either a ClusterCheckNameRequest 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 + :param cluster_name: The name of the cluster. Is either a ClusterCheckNameRequest type or a + IO[bytes] type. Required. + :type cluster_name: ~azure.mgmt.kusto.models.ClusterCheckNameRequest or IO[bytes] :return: CheckNameResult or the result of cls(response) :rtype: ~azure.mgmt.kusto.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2019,23 +1912,21 @@ async def check_name_availability( else: _json = self._serialize.body(cluster_name, "ClusterCheckNameRequest") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2045,16 +1936,12 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameResult", pipeline_response) + deserialized = self._deserialize("CheckNameResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/locations/{location}/checkNameAvailability" - } + return deserialized # type: ignore @distributed_trace def list_skus_by_resource( @@ -2067,7 +1954,6 @@ def list_skus_by_resource( :type resource_group_name: str :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 AzureResourceSku or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kusto.models.AzureResourceSku] :raises ~azure.core.exceptions.HttpResponseError: @@ -2078,7 +1964,7 @@ def list_skus_by_resource( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ListResourceSkusResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2089,17 +1975,15 @@ def list_skus_by_resource( def prepare_request(next_link=None): if not next_link: - request = build_list_skus_by_resource_request( + _request = build_list_skus_by_resource_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_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) else: # make call to next link with the client's api-version @@ -2111,13 +1995,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListResourceSkusResult", pipeline_response) @@ -2127,11 +2010,11 @@ async def extract_data(pipeline_response): return None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2144,12 +2027,8 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_skus_by_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/skus" - } - @distributed_trace - def list_outbound_network_dependencies_endpoints( + def list_outbound_network_dependencies_endpoints( # pylint: disable=name-too-long 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. @@ -2159,7 +2038,6 @@ def list_outbound_network_dependencies_endpoints( :type resource_group_name: str :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 OutboundNetworkDependenciesEndpoint or the result of cls(response) :rtype: @@ -2172,7 +2050,7 @@ def list_outbound_network_dependencies_endpoints( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OutboundNetworkDependenciesEndpointListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2183,17 +2061,15 @@ def list_outbound_network_dependencies_endpoints( def prepare_request(next_link=None): if not next_link: - request = build_list_outbound_network_dependencies_endpoints_request( + _request = build_list_outbound_network_dependencies_endpoints_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_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) else: # make call to next link with the client's api-version @@ -2205,13 +2081,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OutboundNetworkDependenciesEndpointListResult", pipeline_response) @@ -2221,103 +2096,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_outbound_network_dependencies_endpoints.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/outboundNetworkDependenciesEndpoints" - } - - @distributed_trace - def list_language_extensions( - 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. The name is case insensitive. - Required. - :type resource_group_name: str - :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 LanguageExtension or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kusto.models.LanguageExtension] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.LanguageExtensionsList] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_language_extensions_request( - resource_group_name=resource_group_name, - cluster_name=cluster_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_language_extensions.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("LanguageExtensionsList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2330,18 +2113,14 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_language_extensions.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/listLanguageExtensions" - } - - async def _add_language_extensions_initial( # pylint: disable=inconsistent-return-statements + async def _add_callout_policies_initial( self, resource_group_name: str, cluster_name: str, - language_extensions_to_add: Union[_models.LanguageExtensionsList, IO], + callout_policies: Union[_models.CalloutPoliciesList, IO[bytes]], **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2354,17 +2133,17 @@ async def _add_language_extensions_initial( # pylint: disable=inconsistent-retu api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(language_extensions_to_add, (IOBase, bytes)): - _content = language_extensions_to_add + if isinstance(callout_policies, (IOBase, bytes)): + _content = callout_policies else: - _json = self._serialize.body(language_extensions_to_add, "LanguageExtensionsList") + _json = self._serialize.body(callout_policies, "CalloutPoliciesList") - request = build_add_language_extensions_request( + _request = build_add_callout_policies_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, @@ -2372,21 +2151,24 @@ async def _add_language_extensions_initial( # pylint: disable=inconsistent-retu content_type=content_type, json=_json, 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -2398,112 +2180,85 @@ async def _add_language_extensions_initial( # pylint: disable=inconsistent-retu "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _add_language_extensions_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/addLanguageExtensions" - } + return deserialized # type: ignore @overload - async def begin_add_language_extensions( + async def begin_add_callout_policies( self, resource_group_name: str, cluster_name: str, - language_extensions_to_add: _models.LanguageExtensionsList, + callout_policies: _models.CalloutPoliciesList, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: - """Add a list of language extensions that can run within KQL queries. + """Adds a list of callout policies for engine services. :param resource_group_name: The name of the resource group. The name is case insensitive. 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 + :param callout_policies: The callout policies to add. Required. + :type callout_policies: ~azure.mgmt.kusto.models.CalloutPoliciesList :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( + async def begin_add_callout_policies( self, resource_group_name: str, cluster_name: str, - language_extensions_to_add: IO, + callout_policies: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: - """Add a list of language extensions that can run within KQL queries. + """Adds a list of callout policies for engine services. :param resource_group_name: The name of the resource group. The name is case insensitive. 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 + :param callout_policies: The callout policies to add. Required. + :type callout_policies: IO[bytes] :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( + async def begin_add_callout_policies( self, resource_group_name: str, cluster_name: str, - language_extensions_to_add: Union[_models.LanguageExtensionsList, IO], + callout_policies: Union[_models.CalloutPoliciesList, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[None]: - """Add a list of language extensions that can run within KQL queries. + """Adds a list of callout policies for engine services. :param resource_group_name: The name of the resource group. The name is case insensitive. 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. Is either a - LanguageExtensionsList 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 - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param callout_policies: The callout policies to add. Is either a CalloutPoliciesList type or a + IO[bytes] type. Required. + :type callout_policies: ~azure.mgmt.kusto.models.CalloutPoliciesList or IO[bytes] :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: @@ -2518,10 +2273,10 @@ async def begin_add_language_extensions( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._add_language_extensions_initial( # type: ignore + raw_result = await self._add_callout_policies_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, - language_extensions_to_add=language_extensions_to_add, + callout_policies=callout_policies, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -2529,11 +2284,12 @@ async def begin_add_language_extensions( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -2542,26 +2298,22 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_add_language_extensions.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/addLanguageExtensions" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _remove_language_extensions_initial( # pylint: disable=inconsistent-return-statements + async def _remove_callout_policy_initial( self, resource_group_name: str, cluster_name: str, - language_extensions_to_remove: Union[_models.LanguageExtensionsList, IO], + callout_policy: Union[_models.CalloutPolicyToRemove, IO[bytes]], **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2574,17 +2326,17 @@ async def _remove_language_extensions_initial( # pylint: disable=inconsistent-r api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(language_extensions_to_remove, (IOBase, bytes)): - _content = language_extensions_to_remove + if isinstance(callout_policy, (IOBase, bytes)): + _content = callout_policy else: - _json = self._serialize.body(language_extensions_to_remove, "LanguageExtensionsList") + _json = self._serialize.body(callout_policy, "CalloutPolicyToRemove") - request = build_remove_language_extensions_request( + _request = build_remove_callout_policy_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, @@ -2592,21 +2344,24 @@ async def _remove_language_extensions_initial( # pylint: disable=inconsistent-r content_type=content_type, json=_json, 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -2618,89 +2373,575 @@ async def _remove_language_extensions_initial( # pylint: disable=inconsistent-r "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _remove_language_extensions_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/removeLanguageExtensions" - } + return deserialized # type: ignore @overload - async def begin_remove_language_extensions( + async def begin_remove_callout_policy( self, resource_group_name: str, cluster_name: str, - language_extensions_to_remove: _models.LanguageExtensionsList, + callout_policy: _models.CalloutPolicyToRemove, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: - """Remove a list of language extensions that can run within KQL queries. + """Removes callout policy for engine services. :param resource_group_name: The name of the resource group. The name is case insensitive. 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 + :param callout_policy: The callout policies to remove. Required. + :type callout_policy: ~azure.mgmt.kusto.models.CalloutPolicyToRemove :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( + async def begin_remove_callout_policy( self, resource_group_name: str, cluster_name: str, - language_extensions_to_remove: IO, + callout_policy: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: - """Remove a list of language extensions that can run within KQL queries. + """Removes callout policy for engine services. :param resource_group_name: The name of the resource group. The name is case insensitive. 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 + :param callout_policy: The callout policies to remove. Required. + :type callout_policy: IO[bytes] :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_callout_policy( + self, + resource_group_name: str, + cluster_name: str, + callout_policy: Union[_models.CalloutPolicyToRemove, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Removes callout policy for engine services. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param callout_policy: The callout policies to remove. Is either a CalloutPolicyToRemove type + or a IO[bytes] type. Required. + :type callout_policy: ~azure.mgmt.kusto.models.CalloutPolicyToRemove or IO[bytes] + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._remove_callout_policy_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + callout_policy=callout_policy, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_callout_policies( + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.CalloutPolicy"]: + """Returns the allowed callout policies for the specified service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :return: An iterator like instance of either CalloutPolicy or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kusto.models.CalloutPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.CalloutPoliciesList] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_callout_policies_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("CalloutPoliciesList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_language_extensions( + 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. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.LanguageExtensionsList] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_language_extensions_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("LanguageExtensionsList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _add_language_extensions_initial( + self, + resource_group_name: str, + cluster_name: str, + language_extensions_to_add: Union[_models.LanguageExtensionsList, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(language_extensions_to_add, (IOBase, 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, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # 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. The name is case insensitive. + 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 + :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[bytes], + *, + 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. The name is case insensitive. + 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[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :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: Union[_models.LanguageExtensionsList, IO[bytes]], + **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. The name is case insensitive. + 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. Is either a + LanguageExtensionsList type or a IO[bytes] type. Required. + :type language_extensions_to_add: ~azure.mgmt.kusto.models.LanguageExtensionsList or IO[bytes] + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._add_language_extensions_initial( + 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, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _remove_language_extensions_initial( + self, + resource_group_name: str, + cluster_name: str, + language_extensions_to_remove: Union[_models.LanguageExtensionsList, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(language_extensions_to_remove, (IOBase, 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, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload async def begin_remove_language_extensions( self, resource_group_name: str, cluster_name: str, - language_extensions_to_remove: Union[_models.LanguageExtensionsList, IO], + 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. @@ -2710,20 +2951,62 @@ async def begin_remove_language_extensions( :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. Is either a - LanguageExtensionsList 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. + :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[bytes], + *, + 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. The name is case insensitive. + 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[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :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: Union[_models.LanguageExtensionsList, IO[bytes]], + **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. The name is case insensitive. + 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. Is either a + LanguageExtensionsList type or a IO[bytes] type. Required. + :type language_extensions_to_remove: ~azure.mgmt.kusto.models.LanguageExtensionsList or + IO[bytes] :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: @@ -2738,7 +3021,7 @@ async def begin_remove_language_extensions( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._remove_language_extensions_initial( # type: ignore + raw_result = await self._remove_language_extensions_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, language_extensions_to_remove=language_extensions_to_remove, @@ -2749,11 +3032,12 @@ async def begin_remove_language_extensions( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -2762,14 +3046,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_remove_language_extensions.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/removeLanguageExtensions" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # 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 930542125f49..a53a8e5d6941 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,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import AsyncHttpResponse, 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 @@ -30,7 +32,6 @@ 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, @@ -41,6 +42,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -77,7 +82,6 @@ def list_by_database( :type cluster_name: str :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 DataConnection or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kusto.models.DataConnection] :raises ~azure.core.exceptions.HttpResponseError: @@ -88,7 +92,7 @@ def list_by_database( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DataConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -99,18 +103,16 @@ def list_by_database( def prepare_request(next_link=None): if not next_link: - request = build_list_by_database_request( + _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, 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) else: # make call to next link with the client's api-version @@ -122,13 +124,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DataConnectionListResult", pipeline_response) @@ -138,11 +139,11 @@ async def extract_data(pipeline_response): return None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -155,19 +156,15 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections" - } - async def _data_connection_validation_initial( self, resource_group_name: str, cluster_name: str, database_name: str, - parameters: Union[_models.DataConnectionValidation, IO], + parameters: Union[_models.DataConnectionValidation, IO[bytes]], **kwargs: Any - ) -> Optional[_models.DataConnectionValidationListResult]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -180,7 +177,7 @@ async def _data_connection_validation_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.DataConnectionValidationListResult]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -190,7 +187,7 @@ async def _data_connection_validation_initial( else: _json = self._serialize.body(parameters, "DataConnectionValidation") - request = build_data_connection_validation_request( + _request = build_data_connection_validation_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -199,44 +196,41 @@ async def _data_connection_validation_initial( content_type=content_type, json=_json, 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("DataConnectionValidationListResult", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Azure-AsyncOperation"] = self._deserialize( "str", response.headers.get("Azure-AsyncOperation") ) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _data_connection_validation_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnectionValidation" - } + return deserialized # type: ignore @overload async def begin_data_connection_validation( @@ -264,14 +258,6 @@ async def begin_data_connection_validation( :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: @@ -285,7 +271,7 @@ async def begin_data_connection_validation( resource_group_name: str, cluster_name: str, database_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -301,18 +287,10 @@ async def begin_data_connection_validation( :type database_name: str :param parameters: The data connection parameters supplied to the CreateOrUpdate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 DataConnectionValidationListResult or the result of cls(response) :rtype: @@ -326,7 +304,7 @@ async def begin_data_connection_validation( resource_group_name: str, cluster_name: str, database_name: str, - parameters: Union[_models.DataConnectionValidation, IO], + parameters: Union[_models.DataConnectionValidation, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.DataConnectionValidationListResult]: """Checks that the data connection parameters are valid. @@ -339,19 +317,8 @@ async def begin_data_connection_validation( :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 DataConnectionValidation 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. + either a DataConnectionValidation type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.kusto.models.DataConnectionValidation or IO[bytes] :return: An instance of AsyncLROPoller that returns either DataConnectionValidationListResult or the result of cls(response) :rtype: @@ -380,12 +347,13 @@ async def begin_data_connection_validation( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DataConnectionValidationListResult", pipeline_response) + deserialized = self._deserialize("DataConnectionValidationListResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -395,17 +363,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.DataConnectionValidationListResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_data_connection_validation.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnectionValidation" - } + return AsyncLROPoller[_models.DataConnectionValidationListResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @overload async def check_name_availability( @@ -432,7 +398,6 @@ async def check_name_availability( :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: @@ -444,7 +409,7 @@ async def check_name_availability( resource_group_name: str, cluster_name: str, database_name: str, - data_connection_name: IO, + data_connection_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -459,11 +424,10 @@ async def check_name_availability( :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 + :type data_connection_name: IO[bytes] :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: @@ -475,7 +439,7 @@ async def check_name_availability( resource_group_name: str, cluster_name: str, database_name: str, - data_connection_name: Union[_models.DataConnectionCheckNameRequest, IO], + data_connection_name: Union[_models.DataConnectionCheckNameRequest, IO[bytes]], **kwargs: Any ) -> _models.CheckNameResult: """Checks that the data connection name is valid and is not already in use. @@ -488,17 +452,14 @@ async def check_name_availability( :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. Is either a - DataConnectionCheckNameRequest 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 + DataConnectionCheckNameRequest type or a IO[bytes] type. Required. + :type data_connection_name: ~azure.mgmt.kusto.models.DataConnectionCheckNameRequest or + IO[bytes] :return: CheckNameResult or the result of cls(response) :rtype: ~azure.mgmt.kusto.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -521,7 +482,7 @@ async def check_name_availability( else: _json = self._serialize.body(data_connection_name, "DataConnectionCheckNameRequest") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -530,16 +491,14 @@ async def check_name_availability( content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -549,16 +508,12 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameResult", pipeline_response) + deserialized = self._deserialize("CheckNameResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/checkNameAvailability" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -575,12 +530,11 @@ async def get( :type database_name: str :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: ~azure.mgmt.kusto.models.DataConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -594,23 +548,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DataConnection] = kwargs.pop("cls", None) - request = build_get_request( + _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, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -620,16 +572,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DataConnection", pipeline_response) + deserialized = self._deserialize("DataConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, @@ -637,10 +585,10 @@ async def _create_or_update_initial( cluster_name: str, database_name: str, data_connection_name: str, - parameters: Union[_models.DataConnection, IO], + parameters: Union[_models.DataConnection, IO[bytes]], **kwargs: Any - ) -> _models.DataConnection: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -653,7 +601,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataConnection] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -663,7 +611,7 @@ async def _create_or_update_initial( else: _json = self._serialize.body(parameters, "DataConnection") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -673,48 +621,41 @@ async def _create_or_update_initial( 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("DataConnection", pipeline_response) - - if response.status_code == 201: - 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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}" - } - @overload async def begin_create_or_update( self, @@ -744,14 +685,6 @@ async def begin_create_or_update( :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] @@ -765,7 +698,7 @@ async def begin_create_or_update( cluster_name: str, database_name: str, data_connection_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -783,18 +716,10 @@ async def begin_create_or_update( :type data_connection_name: str :param parameters: The data connection parameters supplied to the CreateOrUpdate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :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] @@ -808,7 +733,7 @@ async def begin_create_or_update( cluster_name: str, database_name: str, data_connection_name: str, - parameters: Union[_models.DataConnection, IO], + parameters: Union[_models.DataConnection, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.DataConnection]: """Creates or updates a data connection. @@ -823,19 +748,8 @@ async def begin_create_or_update( :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 DataConnection 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 - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + either a DataConnection type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.kusto.models.DataConnection or IO[bytes] :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] @@ -864,12 +778,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DataConnection", pipeline_response) + deserialized = self._deserialize("DataConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -879,17 +794,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.DataConnection].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}" - } + return AsyncLROPoller[_models.DataConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, @@ -897,10 +810,10 @@ async def _update_initial( cluster_name: str, database_name: str, data_connection_name: str, - parameters: Union[_models.DataConnection, IO], + parameters: Union[_models.DataConnection, IO[bytes]], **kwargs: Any - ) -> _models.DataConnection: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -913,7 +826,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataConnection] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -923,7 +836,7 @@ async def _update_initial( else: _json = self._serialize.body(parameters, "DataConnection") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -933,54 +846,48 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("DataConnection", pipeline_response) - if response.status_code == 201: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) 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["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Azure-AsyncOperation"] = self._deserialize( "str", response.headers.get("Azure-AsyncOperation") ) - deserialized = self._deserialize("DataConnection", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}" - } - @overload async def begin_update( self, @@ -1009,14 +916,6 @@ async def begin_update( :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] @@ -1030,7 +929,7 @@ async def begin_update( cluster_name: str, database_name: str, data_connection_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1047,18 +946,10 @@ async def begin_update( :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 + :type parameters: IO[bytes] :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] @@ -1072,7 +963,7 @@ async def begin_update( cluster_name: str, database_name: str, data_connection_name: str, - parameters: Union[_models.DataConnection, IO], + parameters: Union[_models.DataConnection, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.DataConnection]: """Updates a data connection. @@ -1087,19 +978,8 @@ async def begin_update( :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. Is either a - DataConnection 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 - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + DataConnection type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.kusto.models.DataConnection or IO[bytes] :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] @@ -1128,12 +1008,13 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DataConnection", pipeline_response) + deserialized = self._deserialize("DataConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1143,22 +1024,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.DataConnection].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}" - } + return AsyncLROPoller[_models.DataConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, cluster_name: str, database_name: str, data_connection_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1170,30 +1049,33 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _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, 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1205,12 +1087,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -1227,14 +1109,6 @@ async def begin_delete( :type database_name: str :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. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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: @@ -1248,7 +1122,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -1259,11 +1133,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -1272,14 +1147,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_database_operations.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_database_operations.py index bde668da9484..b8f7e1557dfb 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_database_operations.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_database_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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._database_operations import build_invite_follower_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -76,7 +79,6 @@ async def invite_follower( :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: DatabaseInviteFollowerResult or the result of cls(response) :rtype: ~azure.mgmt.kusto.models.DatabaseInviteFollowerResult :raises ~azure.core.exceptions.HttpResponseError: @@ -88,7 +90,7 @@ async def invite_follower( resource_group_name: str, cluster_name: str, database_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -103,11 +105,10 @@ async def invite_follower( :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str :param parameters: The follower invitation request parameters. Required. - :type parameters: IO + :type parameters: IO[bytes] :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: DatabaseInviteFollowerResult or the result of cls(response) :rtype: ~azure.mgmt.kusto.models.DatabaseInviteFollowerResult :raises ~azure.core.exceptions.HttpResponseError: @@ -119,7 +120,7 @@ async def invite_follower( resource_group_name: str, cluster_name: str, database_name: str, - parameters: Union[_models.DatabaseInviteFollowerRequest, IO], + parameters: Union[_models.DatabaseInviteFollowerRequest, IO[bytes]], **kwargs: Any ) -> _models.DatabaseInviteFollowerResult: """Generates an invitation token that allows attaching a follower database to this database. @@ -132,17 +133,13 @@ async def invite_follower( :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str :param parameters: The follower invitation request parameters. Is either a - DatabaseInviteFollowerRequest type or a IO type. Required. - :type parameters: ~azure.mgmt.kusto.models.DatabaseInviteFollowerRequest 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 + DatabaseInviteFollowerRequest type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.kusto.models.DatabaseInviteFollowerRequest or IO[bytes] :return: DatabaseInviteFollowerResult or the result of cls(response) :rtype: ~azure.mgmt.kusto.models.DatabaseInviteFollowerResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -165,7 +162,7 @@ async def invite_follower( else: _json = self._serialize.body(parameters, "DatabaseInviteFollowerRequest") - request = build_invite_follower_request( + _request = build_invite_follower_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -174,16 +171,14 @@ async def invite_follower( content_type=content_type, json=_json, content=_content, - template_url=self.invite_follower.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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -193,13 +188,9 @@ async def invite_follower( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DatabaseInviteFollowerResult", pipeline_response) + deserialized = self._deserialize("DatabaseInviteFollowerResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - invite_follower.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/inviteFollower" - } + return deserialized # 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 bbcfa1e01a1f..aa717bd4284f 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,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import AsyncHttpResponse, 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 @@ -30,7 +32,6 @@ 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, @@ -39,6 +40,10 @@ build_list_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -88,7 +93,6 @@ async def check_name_availability( :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: @@ -100,7 +104,7 @@ async def check_name_availability( resource_group_name: str, cluster_name: str, database_name: str, - principal_assignment_name: IO, + principal_assignment_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -115,11 +119,10 @@ async def check_name_availability( :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 + :type principal_assignment_name: IO[bytes] :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: @@ -131,7 +134,7 @@ async def check_name_availability( resource_group_name: str, cluster_name: str, database_name: str, - principal_assignment_name: Union[_models.DatabasePrincipalAssignmentCheckNameRequest, IO], + principal_assignment_name: Union[_models.DatabasePrincipalAssignmentCheckNameRequest, IO[bytes]], **kwargs: Any ) -> _models.CheckNameResult: """Checks that the database principal assignment is valid and is not already in use. @@ -144,18 +147,14 @@ async def check_name_availability( :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. Is either a - DatabasePrincipalAssignmentCheckNameRequest type or a IO type. Required. + DatabasePrincipalAssignmentCheckNameRequest type or a IO[bytes] type. Required. :type principal_assignment_name: - ~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 + ~azure.mgmt.kusto.models.DatabasePrincipalAssignmentCheckNameRequest or IO[bytes] :return: CheckNameResult or the result of cls(response) :rtype: ~azure.mgmt.kusto.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -178,7 +177,7 @@ async def check_name_availability( else: _json = self._serialize.body(principal_assignment_name, "DatabasePrincipalAssignmentCheckNameRequest") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -187,16 +186,14 @@ async def check_name_availability( content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -206,16 +203,12 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameResult", pipeline_response) + deserialized = self._deserialize("CheckNameResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/checkPrincipalAssignmentNameAvailability" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -237,12 +230,11 @@ async def get( :type database_name: str :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: ~azure.mgmt.kusto.models.DatabasePrincipalAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -256,23 +248,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabasePrincipalAssignment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_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, - 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -282,16 +272,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DatabasePrincipalAssignment", pipeline_response) + deserialized = self._deserialize("DatabasePrincipalAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, @@ -299,10 +285,10 @@ async def _create_or_update_initial( cluster_name: str, database_name: str, principal_assignment_name: str, - parameters: Union[_models.DatabasePrincipalAssignment, IO], + parameters: Union[_models.DatabasePrincipalAssignment, IO[bytes]], **kwargs: Any - ) -> _models.DatabasePrincipalAssignment: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -315,7 +301,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DatabasePrincipalAssignment] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -325,7 +311,7 @@ async def _create_or_update_initial( else: _json = self._serialize.body(parameters, "DatabasePrincipalAssignment") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -335,40 +321,35 @@ async def _create_or_update_initial( 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("DatabasePrincipalAssignment", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DatabasePrincipalAssignment", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}" - } - @overload async def begin_create_or_update( self, @@ -398,14 +379,6 @@ async def begin_create_or_update( :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: @@ -420,7 +393,7 @@ async def begin_create_or_update( cluster_name: str, database_name: str, principal_assignment_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -438,18 +411,10 @@ async def begin_create_or_update( :type principal_assignment_name: str :param parameters: The Kusto principalAssignments parameters supplied for the operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 DatabasePrincipalAssignment or the result of cls(response) :rtype: @@ -464,7 +429,7 @@ async def begin_create_or_update( cluster_name: str, database_name: str, principal_assignment_name: str, - parameters: Union[_models.DatabasePrincipalAssignment, IO], + parameters: Union[_models.DatabasePrincipalAssignment, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.DatabasePrincipalAssignment]: """Creates a Kusto cluster database principalAssignment. @@ -479,19 +444,8 @@ async def begin_create_or_update( :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 DatabasePrincipalAssignment 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. + either a DatabasePrincipalAssignment type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.kusto.models.DatabasePrincipalAssignment or IO[bytes] :return: An instance of AsyncLROPoller that returns either DatabasePrincipalAssignment or the result of cls(response) :rtype: @@ -521,12 +475,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DatabasePrincipalAssignment", pipeline_response) + deserialized = self._deserialize("DatabasePrincipalAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -536,27 +491,25 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.DatabasePrincipalAssignment].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}" - } + return AsyncLROPoller[_models.DatabasePrincipalAssignment]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, cluster_name: str, database_name: str, principal_assignment_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -568,30 +521,33 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_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, - 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -603,12 +559,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -630,14 +586,6 @@ async def begin_delete( :type database_name: str :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. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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: @@ -651,7 +599,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -662,11 +610,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -675,17 +624,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def list( @@ -700,7 +645,6 @@ def list( :type cluster_name: str :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 DatabasePrincipalAssignment or the result of cls(response) :rtype: @@ -713,7 +657,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabasePrincipalAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -724,18 +668,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_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, - 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) else: # make call to next link with the client's api-version @@ -747,13 +689,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DatabasePrincipalAssignmentListResult", pipeline_response) @@ -763,11 +704,11 @@ async def extract_data(pipeline_response): return None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -779,7 +720,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments" - } 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 c6db5b25ff42..fce8d38a6e70 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,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import AsyncHttpResponse, 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 @@ -30,7 +32,6 @@ 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, @@ -43,6 +44,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -88,7 +93,6 @@ async def check_name_availability( :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: @@ -99,7 +103,7 @@ async def check_name_availability( self, resource_group_name: str, cluster_name: str, - resource_name: IO, + resource_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -112,11 +116,10 @@ async def check_name_availability( :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 + :type resource_name: IO[bytes] :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: @@ -127,7 +130,7 @@ async def check_name_availability( self, resource_group_name: str, cluster_name: str, - resource_name: Union[_models.CheckNameRequest, IO], + resource_name: Union[_models.CheckNameRequest, IO[bytes]], **kwargs: Any ) -> _models.CheckNameResult: """Checks that the databases resource name is valid and is not already in use. @@ -137,18 +140,14 @@ async def check_name_availability( :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. Is either a CheckNameRequest 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 + :param resource_name: The name of the resource. Is either a CheckNameRequest type or a + IO[bytes] type. Required. + :type resource_name: ~azure.mgmt.kusto.models.CheckNameRequest or IO[bytes] :return: CheckNameResult or the result of cls(response) :rtype: ~azure.mgmt.kusto.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -171,7 +170,7 @@ async def check_name_availability( else: _json = self._serialize.body(resource_name, "CheckNameRequest") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, @@ -179,16 +178,14 @@ async def check_name_availability( content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -198,16 +195,12 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameResult", pipeline_response) + deserialized = self._deserialize("CheckNameResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/checkNameAvailability" - } + return deserialized # type: ignore @distributed_trace def list_by_cluster( @@ -232,7 +225,6 @@ def list_by_cluster( a skiptoken parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skiptoken: str - :keyword callable cls: A custom type or function that will be passed the direct response :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: @@ -243,7 +235,7 @@ def list_by_cluster( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -254,19 +246,17 @@ def list_by_cluster( def prepare_request(next_link=None): if not next_link: - request = build_list_by_cluster_request( + _request = build_list_by_cluster_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, top=top, skiptoken=skiptoken, 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) else: # make call to next link with the client's api-version @@ -278,13 +268,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DatabaseListResult", pipeline_response) @@ -294,11 +283,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -311,10 +300,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_cluster.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases" - } - @distributed_trace_async async def get( self, resource_group_name: str, cluster_name: str, database_name: str, **kwargs: Any @@ -328,12 +313,11 @@ async def get( :type cluster_name: str :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: ~azure.mgmt.kusto.models.Database :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -347,22 +331,20 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Database] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_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, - 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -372,27 +354,23 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Database", pipeline_response) + deserialized = self._deserialize("Database", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, cluster_name: str, database_name: str, - parameters: Union[_models.Database, IO], + parameters: Union[_models.Database, IO[bytes]], caller_role: Union[str, _models.CallerRole] = "Admin", **kwargs: Any - ) -> _models.Database: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -405,7 +383,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Database] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -415,7 +393,7 @@ async def _create_or_update_initial( else: _json = self._serialize.body(parameters, "Database") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -425,48 +403,41 @@ async def _create_or_update_initial( 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Database", pipeline_response) - - if response.status_code == 201: - 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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}" - } - @overload async def begin_create_or_update( self, @@ -497,14 +468,6 @@ async def begin_create_or_update( :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] @@ -517,7 +480,7 @@ async def begin_create_or_update( resource_group_name: str, cluster_name: str, database_name: str, - parameters: IO, + parameters: IO[bytes], caller_role: Union[str, _models.CallerRole] = "Admin", *, content_type: str = "application/json", @@ -533,7 +496,7 @@ async def begin_create_or_update( :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 + :type parameters: IO[bytes] :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". @@ -541,14 +504,6 @@ async def begin_create_or_update( :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] @@ -561,7 +516,7 @@ async def begin_create_or_update( resource_group_name: str, cluster_name: str, database_name: str, - parameters: Union[_models.Database, IO], + parameters: Union[_models.Database, IO[bytes]], caller_role: Union[str, _models.CallerRole] = "Admin", **kwargs: Any ) -> AsyncLROPoller[_models.Database]: @@ -575,23 +530,12 @@ async def begin_create_or_update( :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. Is either - a Database type or a IO type. Required. - :type parameters: ~azure.mgmt.kusto.models.Database or IO + a Database type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.kusto.models.Database or IO[bytes] :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 - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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] @@ -620,12 +564,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Database", pipeline_response) + deserialized = self._deserialize("Database", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -635,28 +580,26 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Database].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}" - } + return AsyncLROPoller[_models.Database]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, resource_group_name: str, cluster_name: str, database_name: str, - parameters: Union[_models.Database, IO], + parameters: Union[_models.Database, IO[bytes]], caller_role: Union[str, _models.CallerRole] = "Admin", **kwargs: Any - ) -> _models.Database: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -669,7 +612,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Database] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -679,7 +622,7 @@ async def _update_initial( else: _json = self._serialize.body(parameters, "Database") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -689,54 +632,48 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Database", pipeline_response) - if response.status_code == 201: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) 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["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Azure-AsyncOperation"] = self._deserialize( "str", response.headers.get("Azure-AsyncOperation") ) - deserialized = self._deserialize("Database", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}" - } - @overload async def begin_update( self, @@ -767,14 +704,6 @@ async def begin_update( :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] @@ -787,7 +716,7 @@ async def begin_update( resource_group_name: str, cluster_name: str, database_name: str, - parameters: IO, + parameters: IO[bytes], caller_role: Union[str, _models.CallerRole] = "Admin", *, content_type: str = "application/json", @@ -803,7 +732,7 @@ async def begin_update( :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 + :type parameters: IO[bytes] :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". @@ -811,14 +740,6 @@ async def begin_update( :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] @@ -831,7 +752,7 @@ async def begin_update( resource_group_name: str, cluster_name: str, database_name: str, - parameters: Union[_models.Database, IO], + parameters: Union[_models.Database, IO[bytes]], caller_role: Union[str, _models.CallerRole] = "Admin", **kwargs: Any ) -> AsyncLROPoller[_models.Database]: @@ -845,23 +766,12 @@ async def begin_update( :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. Is either a - Database type or a IO type. Required. - :type parameters: ~azure.mgmt.kusto.models.Database or IO + Database type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.kusto.models.Database or IO[bytes] :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 - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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] @@ -890,12 +800,13 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Database", pipeline_response) + deserialized = self._deserialize("Database", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -905,22 +816,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Database].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}" - } + return AsyncLROPoller[_models.Database]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, cluster_name: str, database_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -932,29 +841,32 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_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, - 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -966,12 +878,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -986,14 +898,6 @@ async def begin_delete( :type cluster_name: str :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. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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: @@ -1007,7 +911,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -1017,11 +921,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -1030,17 +935,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def list_principals( @@ -1055,7 +956,6 @@ def list_principals( :type cluster_name: str :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 DatabasePrincipal or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kusto.models.DatabasePrincipal] :raises ~azure.core.exceptions.HttpResponseError: @@ -1066,7 +966,7 @@ def list_principals( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabasePrincipalListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1077,18 +977,16 @@ def list_principals( def prepare_request(next_link=None): if not next_link: - request = build_list_principals_request( + _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, 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) else: # make call to next link with the client's api-version @@ -1100,13 +998,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DatabasePrincipalListResult", pipeline_response) @@ -1116,11 +1013,11 @@ async def extract_data(pipeline_response): return None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1133,10 +1030,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_principals.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/listPrincipals" - } - @overload async def add_principals( self, @@ -1162,7 +1055,6 @@ async def add_principals( :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: @@ -1174,7 +1066,7 @@ async def add_principals( resource_group_name: str, cluster_name: str, database_name: str, - database_principals_to_add: IO, + database_principals_to_add: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1189,11 +1081,10 @@ async def add_principals( :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 + :type database_principals_to_add: IO[bytes] :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: @@ -1205,7 +1096,7 @@ async def add_principals( resource_group_name: str, cluster_name: str, database_name: str, - database_principals_to_add: Union[_models.DatabasePrincipalListRequest, IO], + database_principals_to_add: Union[_models.DatabasePrincipalListRequest, IO[bytes]], **kwargs: Any ) -> _models.DatabasePrincipalListResult: """Add Database principals permissions. @@ -1218,17 +1109,14 @@ async def add_principals( :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. Is either a - DatabasePrincipalListRequest 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 + DatabasePrincipalListRequest type or a IO[bytes] type. Required. + :type database_principals_to_add: ~azure.mgmt.kusto.models.DatabasePrincipalListRequest or + IO[bytes] :return: DatabasePrincipalListResult or the result of cls(response) :rtype: ~azure.mgmt.kusto.models.DatabasePrincipalListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1251,7 +1139,7 @@ async def add_principals( else: _json = self._serialize.body(database_principals_to_add, "DatabasePrincipalListRequest") - request = build_add_principals_request( + _request = build_add_principals_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -1260,16 +1148,14 @@ async def add_principals( content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1279,16 +1165,12 @@ async def add_principals( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DatabasePrincipalListResult", pipeline_response) + deserialized = self._deserialize("DatabasePrincipalListResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - add_principals.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/addPrincipals" - } + return deserialized # type: ignore @overload async def remove_principals( @@ -1315,7 +1197,6 @@ async def remove_principals( :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: @@ -1327,7 +1208,7 @@ async def remove_principals( resource_group_name: str, cluster_name: str, database_name: str, - database_principals_to_remove: IO, + database_principals_to_remove: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1342,11 +1223,10 @@ async def remove_principals( :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 + :type database_principals_to_remove: IO[bytes] :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: @@ -1358,7 +1238,7 @@ async def remove_principals( resource_group_name: str, cluster_name: str, database_name: str, - database_principals_to_remove: Union[_models.DatabasePrincipalListRequest, IO], + database_principals_to_remove: Union[_models.DatabasePrincipalListRequest, IO[bytes]], **kwargs: Any ) -> _models.DatabasePrincipalListResult: """Remove Database principals permissions. @@ -1371,18 +1251,14 @@ async def remove_principals( :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. Is either a - DatabasePrincipalListRequest type or a IO type. Required. + DatabasePrincipalListRequest type or a IO[bytes] 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 + IO[bytes] :return: DatabasePrincipalListResult or the result of cls(response) :rtype: ~azure.mgmt.kusto.models.DatabasePrincipalListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1405,7 +1281,7 @@ async def remove_principals( else: _json = self._serialize.body(database_principals_to_remove, "DatabasePrincipalListRequest") - request = build_remove_principals_request( + _request = build_remove_principals_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -1414,16 +1290,14 @@ async def remove_principals( content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1433,13 +1307,9 @@ async def remove_principals( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DatabasePrincipalListResult", pipeline_response) + deserialized = self._deserialize("DatabasePrincipalListResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - remove_principals.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/removePrincipals" - } + return deserialized # 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 feeaeb1876d4..c1e8d802873e 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,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import AsyncHttpResponse, 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 @@ -30,7 +32,6 @@ 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, @@ -40,6 +41,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -85,7 +90,6 @@ async def check_name_availability( :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: @@ -96,7 +100,7 @@ async def check_name_availability( self, resource_group_name: str, cluster_name: str, - resource_name: IO, + resource_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -109,11 +113,10 @@ async def check_name_availability( :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 + :type resource_name: IO[bytes] :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: @@ -124,7 +127,7 @@ async def check_name_availability( self, resource_group_name: str, cluster_name: str, - resource_name: Union[_models.ManagedPrivateEndpointsCheckNameRequest, IO], + resource_name: Union[_models.ManagedPrivateEndpointsCheckNameRequest, IO[bytes]], **kwargs: Any ) -> _models.CheckNameResult: """Checks that the managed private endpoints resource name is valid and is not already in use. @@ -135,17 +138,14 @@ async def check_name_availability( :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str :param resource_name: The name of the resource. Is either a - ManagedPrivateEndpointsCheckNameRequest 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 + ManagedPrivateEndpointsCheckNameRequest type or a IO[bytes] type. Required. + :type resource_name: ~azure.mgmt.kusto.models.ManagedPrivateEndpointsCheckNameRequest or + IO[bytes] :return: CheckNameResult or the result of cls(response) :rtype: ~azure.mgmt.kusto.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -168,7 +168,7 @@ async def check_name_availability( else: _json = self._serialize.body(resource_name, "ManagedPrivateEndpointsCheckNameRequest") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, @@ -176,16 +176,14 @@ async def check_name_availability( content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -195,16 +193,12 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameResult", pipeline_response) + deserialized = self._deserialize("CheckNameResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpointsCheckNameAvailability" - } + return deserialized # type: ignore @distributed_trace def list( @@ -217,7 +211,6 @@ def list( :type resource_group_name: str :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 ManagedPrivateEndpoint or the result of cls(response) :rtype: @@ -230,7 +223,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedPrivateEndpointListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -241,17 +234,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -263,13 +254,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ManagedPrivateEndpointListResult", pipeline_response) @@ -279,11 +269,11 @@ async def extract_data(pipeline_response): return None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -296,10 +286,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints" - } - @distributed_trace_async async def get( self, resource_group_name: str, cluster_name: str, managed_private_endpoint_name: str, **kwargs: Any @@ -313,12 +299,11 @@ async def get( :type cluster_name: str :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: ~azure.mgmt.kusto.models.ManagedPrivateEndpoint :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -332,22 +317,20 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedPrivateEndpoint] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_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, - 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -357,26 +340,22 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ManagedPrivateEndpoint", pipeline_response) + deserialized = self._deserialize("ManagedPrivateEndpoint", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, cluster_name: str, managed_private_endpoint_name: str, - parameters: Union[_models.ManagedPrivateEndpoint, IO], + parameters: Union[_models.ManagedPrivateEndpoint, IO[bytes]], **kwargs: Any - ) -> _models.ManagedPrivateEndpoint: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -389,7 +368,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ManagedPrivateEndpoint] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -399,7 +378,7 @@ async def _create_or_update_initial( else: _json = self._serialize.body(parameters, "ManagedPrivateEndpoint") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, managed_private_endpoint_name=managed_private_endpoint_name, @@ -408,48 +387,41 @@ async def _create_or_update_initial( 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("ManagedPrivateEndpoint", pipeline_response) - - if response.status_code == 201: - 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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}" - } - @overload async def begin_create_or_update( self, @@ -475,14 +447,6 @@ async def begin_create_or_update( :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] @@ -495,7 +459,7 @@ async def begin_create_or_update( resource_group_name: str, cluster_name: str, managed_private_endpoint_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -510,18 +474,10 @@ async def begin_create_or_update( :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 + :type parameters: IO[bytes] :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] @@ -534,7 +490,7 @@ async def begin_create_or_update( resource_group_name: str, cluster_name: str, managed_private_endpoint_name: str, - parameters: Union[_models.ManagedPrivateEndpoint, IO], + parameters: Union[_models.ManagedPrivateEndpoint, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.ManagedPrivateEndpoint]: """Creates a managed private endpoint. @@ -547,19 +503,8 @@ async def begin_create_or_update( :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. Is either a ManagedPrivateEndpoint - 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 - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.kusto.models.ManagedPrivateEndpoint or IO[bytes] :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] @@ -587,12 +532,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedPrivateEndpoint", pipeline_response) + deserialized = self._deserialize("ManagedPrivateEndpoint", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -602,27 +548,25 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.ManagedPrivateEndpoint].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}" - } + return AsyncLROPoller[_models.ManagedPrivateEndpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, resource_group_name: str, cluster_name: str, managed_private_endpoint_name: str, - parameters: Union[_models.ManagedPrivateEndpoint, IO], + parameters: Union[_models.ManagedPrivateEndpoint, IO[bytes]], **kwargs: Any - ) -> _models.ManagedPrivateEndpoint: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -635,7 +579,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ManagedPrivateEndpoint] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -645,7 +589,7 @@ async def _update_initial( else: _json = self._serialize.body(parameters, "ManagedPrivateEndpoint") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, managed_private_endpoint_name=managed_private_endpoint_name, @@ -654,46 +598,42 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("ManagedPrivateEndpoint", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Azure-AsyncOperation"] = self._deserialize( "str", response.headers.get("Azure-AsyncOperation") ) - deserialized = self._deserialize("ManagedPrivateEndpoint", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}" - } - @overload async def begin_update( self, @@ -719,14 +659,6 @@ async def begin_update( :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] @@ -739,7 +671,7 @@ async def begin_update( resource_group_name: str, cluster_name: str, managed_private_endpoint_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -754,18 +686,10 @@ async def begin_update( :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 + :type parameters: IO[bytes] :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] @@ -778,7 +702,7 @@ async def begin_update( resource_group_name: str, cluster_name: str, managed_private_endpoint_name: str, - parameters: Union[_models.ManagedPrivateEndpoint, IO], + parameters: Union[_models.ManagedPrivateEndpoint, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.ManagedPrivateEndpoint]: """Updates a managed private endpoint. @@ -791,19 +715,8 @@ async def begin_update( :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. Is either a ManagedPrivateEndpoint - 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 - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.kusto.models.ManagedPrivateEndpoint or IO[bytes] :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] @@ -831,12 +744,13 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedPrivateEndpoint", pipeline_response) + deserialized = self._deserialize("ManagedPrivateEndpoint", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -846,22 +760,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.ManagedPrivateEndpoint].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}" - } + return AsyncLROPoller[_models.ManagedPrivateEndpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, cluster_name: str, managed_private_endpoint_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -873,29 +785,32 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_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, - 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -907,12 +822,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -927,14 +842,6 @@ async def begin_delete( :type cluster_name: str :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. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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: @@ -948,7 +855,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, managed_private_endpoint_name=managed_private_endpoint_name, @@ -958,11 +865,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -971,14 +879,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # 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 d6edf53261a5..4aa9776530ac 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,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,16 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,7 +59,6 @@ def __init__(self, *args, **kwargs) -> None: 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 Operation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kusto.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -67,7 +69,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -78,14 +80,12 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -97,13 +97,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -113,11 +112,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -129,5 +128,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Kusto/operations"} 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 0b6c592fdfae..208f700495a1 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,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -60,12 +63,11 @@ async def get( # pylint: disable=inconsistent-return-statements :type location: str :param operation_id: The ID of an ongoing async operation. 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) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -79,21 +81,19 @@ async def get( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( location=location, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -109,8 +109,4 @@ async def get( # pylint: disable=inconsistent-return-statements ) if cls: - return cls(pipeline_response, None, response_headers) - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/locations/{location}/operationResults/{operationId}" - } + return cls(pipeline_response, None, response_headers) # 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 765b046973eb..c58f32a3686a 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,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -58,12 +61,11 @@ async def get(self, location: str, operation_id: str, **kwargs: Any) -> _models. :type location: str :param operation_id: The ID of an ongoing async operation. 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: ~azure.mgmt.kusto.models.OperationResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -77,21 +79,19 @@ async def get(self, location: str, operation_id: str, **kwargs: Any) -> _models. api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationResult] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( location=location, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -101,13 +101,9 @@ async def get(self, location: str, operation_id: str, **kwargs: Any) -> _models. error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("OperationResult", pipeline_response) + deserialized = self._deserialize("OperationResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/locations/{location}/operationResults/{operationId}" - } + return deserialized # type: ignore 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 f3c684bcc97e..a0de7e97b5c5 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,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import AsyncHttpResponse, 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 @@ -30,7 +32,6 @@ 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, build_delete_request, @@ -38,6 +39,10 @@ build_list_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -72,7 +77,6 @@ def list( :type resource_group_name: str :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 PrivateEndpointConnection or the result of cls(response) :rtype: @@ -85,7 +89,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,17 +100,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -118,13 +120,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) @@ -134,11 +135,11 @@ async def extract_data(pipeline_response): return None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -151,10 +152,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateEndpointConnections" - } - @distributed_trace_async async def get( self, resource_group_name: str, cluster_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -168,12 +165,11 @@ async def get( :type cluster_name: str :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: ~azure.mgmt.kusto.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -187,22 +183,20 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, cluster_name=cluster_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -212,26 +206,22 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, cluster_name: str, private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO], + parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any - ) -> _models.PrivateEndpointConnection: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -244,7 +234,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -254,7 +244,7 @@ async def _create_or_update_initial( else: _json = self._serialize.body(parameters, "PrivateEndpointConnection") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -263,40 +253,35 @@ async def _create_or_update_initial( 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - @overload async def begin_create_or_update( self, @@ -322,14 +307,6 @@ async def begin_create_or_update( :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] @@ -342,7 +319,7 @@ async def begin_create_or_update( resource_group_name: str, cluster_name: str, private_endpoint_connection_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -357,18 +334,10 @@ async def begin_create_or_update( :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 + :type parameters: IO[bytes] :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] @@ -381,7 +350,7 @@ async def begin_create_or_update( resource_group_name: str, cluster_name: str, private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO], + parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Approve or reject a private endpoint connection with a given name. @@ -393,19 +362,8 @@ async def begin_create_or_update( :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: Is either a PrivateEndpointConnection 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 - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param parameters: Is either a PrivateEndpointConnection type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.kusto.models.PrivateEndpointConnection or IO[bytes] :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] @@ -433,12 +391,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -448,22 +407,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.PrivateEndpointConnection].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return AsyncLROPoller[_models.PrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, cluster_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -475,29 +432,32 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, cluster_name=cluster_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -509,12 +469,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -529,14 +489,6 @@ async def begin_delete( :type cluster_name: str :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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: @@ -550,7 +502,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -560,11 +512,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -573,14 +526,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # 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 2f1deb9ea4ed..e4152c1365f3 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,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,17 +20,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -64,7 +67,6 @@ def list( :type resource_group_name: str :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 PrivateLinkResource or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kusto.models.PrivateLinkResource] :raises ~azure.core.exceptions.HttpResponseError: @@ -75,7 +77,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -86,17 +88,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -108,13 +108,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) @@ -124,11 +123,11 @@ async def extract_data(pipeline_response): return None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -141,10 +140,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateLinkResources" - } - @distributed_trace_async async def get( self, resource_group_name: str, cluster_name: str, private_link_resource_name: str, **kwargs: Any @@ -158,12 +153,11 @@ async def get( :type cluster_name: str :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: ~azure.mgmt.kusto.models.PrivateLinkResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -177,22 +171,20 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, cluster_name=cluster_name, private_link_resource_name=private_link_resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -202,13 +194,9 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateLinkResource", pipeline_response) + deserialized = self._deserialize("PrivateLinkResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateLinkResources/{privateLinkResourceName}" - } + return deserialized # type: ignore diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_sandbox_custom_images_operations.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_sandbox_custom_images_operations.py index e9a0200fe1fe..4604deb8c85b 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_sandbox_custom_images_operations.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_sandbox_custom_images_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import AsyncHttpResponse, 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 @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._sandbox_custom_images_operations import ( build_check_name_availability_request, build_create_or_update_request, @@ -40,6 +41,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -74,7 +79,6 @@ def list_by_cluster( :type resource_group_name: str :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 SandboxCustomImage or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kusto.models.SandboxCustomImage] :raises ~azure.core.exceptions.HttpResponseError: @@ -85,7 +89,7 @@ def list_by_cluster( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SandboxCustomImagesListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,17 +100,15 @@ def list_by_cluster( def prepare_request(next_link=None): if not next_link: - request = build_list_by_cluster_request( + _request = build_list_by_cluster_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_cluster.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -118,13 +120,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("SandboxCustomImagesListResult", pipeline_response) @@ -134,11 +135,11 @@ async def extract_data(pipeline_response): return None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -151,10 +152,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_cluster.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/sandboxCustomImages" - } - @distributed_trace_async async def get( self, resource_group_name: str, cluster_name: str, sandbox_custom_image_name: str, **kwargs: Any @@ -168,12 +165,11 @@ async def get( :type cluster_name: str :param sandbox_custom_image_name: The name of the sandbox custom image. Required. :type sandbox_custom_image_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SandboxCustomImage or the result of cls(response) :rtype: ~azure.mgmt.kusto.models.SandboxCustomImage :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -187,22 +183,20 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SandboxCustomImage] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, cluster_name=cluster_name, sandbox_custom_image_name=sandbox_custom_image_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -212,26 +206,22 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SandboxCustomImage", pipeline_response) + deserialized = self._deserialize("SandboxCustomImage", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/sandboxCustomImages/{sandboxCustomImageName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, cluster_name: str, sandbox_custom_image_name: str, - parameters: Union[_models.SandboxCustomImage, IO], + parameters: Union[_models.SandboxCustomImage, IO[bytes]], **kwargs: Any - ) -> _models.SandboxCustomImage: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -244,7 +234,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SandboxCustomImage] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -254,7 +244,7 @@ async def _create_or_update_initial( else: _json = self._serialize.body(parameters, "SandboxCustomImage") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, sandbox_custom_image_name=sandbox_custom_image_name, @@ -263,40 +253,35 @@ async def _create_or_update_initial( 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("SandboxCustomImage", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SandboxCustomImage", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/sandboxCustomImages/{sandboxCustomImageName}" - } - @overload async def begin_create_or_update( self, @@ -322,14 +307,6 @@ async def begin_create_or_update( :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 SandboxCustomImage or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.SandboxCustomImage] @@ -342,7 +319,7 @@ async def begin_create_or_update( resource_group_name: str, cluster_name: str, sandbox_custom_image_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -357,18 +334,10 @@ async def begin_create_or_update( :param sandbox_custom_image_name: The name of the sandbox custom image. Required. :type sandbox_custom_image_name: str :param parameters: The sandbox custom image parameters. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 SandboxCustomImage or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.SandboxCustomImage] @@ -381,7 +350,7 @@ async def begin_create_or_update( resource_group_name: str, cluster_name: str, sandbox_custom_image_name: str, - parameters: Union[_models.SandboxCustomImage, IO], + parameters: Union[_models.SandboxCustomImage, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.SandboxCustomImage]: """Creates or updates a sandbox custom image. @@ -394,19 +363,8 @@ async def begin_create_or_update( :param sandbox_custom_image_name: The name of the sandbox custom image. Required. :type sandbox_custom_image_name: str :param parameters: The sandbox custom image parameters. Is either a SandboxCustomImage type or - a IO type. Required. - :type parameters: ~azure.mgmt.kusto.models.SandboxCustomImage 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. + a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.kusto.models.SandboxCustomImage or IO[bytes] :return: An instance of AsyncLROPoller that returns either SandboxCustomImage or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.SandboxCustomImage] @@ -434,12 +392,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SandboxCustomImage", pipeline_response) + deserialized = self._deserialize("SandboxCustomImage", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -449,27 +408,25 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.SandboxCustomImage].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/sandboxCustomImages/{sandboxCustomImageName}" - } + return AsyncLROPoller[_models.SandboxCustomImage]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, resource_group_name: str, cluster_name: str, sandbox_custom_image_name: str, - parameters: Union[_models.SandboxCustomImage, IO], + parameters: Union[_models.SandboxCustomImage, IO[bytes]], **kwargs: Any - ) -> _models.SandboxCustomImage: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -482,7 +439,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SandboxCustomImage] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -492,7 +449,7 @@ async def _update_initial( else: _json = self._serialize.body(parameters, "SandboxCustomImage") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, sandbox_custom_image_name=sandbox_custom_image_name, @@ -501,49 +458,42 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("SandboxCustomImage", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SandboxCustomImage", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Azure-AsyncOperation"] = self._deserialize( "str", response.headers.get("Azure-AsyncOperation") ) - deserialized = self._deserialize("SandboxCustomImage", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/sandboxCustomImages/{sandboxCustomImageName}" - } - @overload async def begin_update( self, @@ -569,14 +519,6 @@ async def begin_update( :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 SandboxCustomImage or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.SandboxCustomImage] @@ -589,7 +531,7 @@ async def begin_update( resource_group_name: str, cluster_name: str, sandbox_custom_image_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -604,18 +546,10 @@ async def begin_update( :param sandbox_custom_image_name: The name of the sandbox custom image. Required. :type sandbox_custom_image_name: str :param parameters: The sandbox custom image parameters. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 SandboxCustomImage or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.SandboxCustomImage] @@ -628,7 +562,7 @@ async def begin_update( resource_group_name: str, cluster_name: str, sandbox_custom_image_name: str, - parameters: Union[_models.SandboxCustomImage, IO], + parameters: Union[_models.SandboxCustomImage, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.SandboxCustomImage]: """Updates a sandbox custom image. @@ -641,19 +575,8 @@ async def begin_update( :param sandbox_custom_image_name: The name of the sandbox custom image. Required. :type sandbox_custom_image_name: str :param parameters: The sandbox custom image parameters. Is either a SandboxCustomImage type or - a IO type. Required. - :type parameters: ~azure.mgmt.kusto.models.SandboxCustomImage 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. + a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.kusto.models.SandboxCustomImage or IO[bytes] :return: An instance of AsyncLROPoller that returns either SandboxCustomImage or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.kusto.models.SandboxCustomImage] @@ -681,12 +604,13 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SandboxCustomImage", pipeline_response) + deserialized = self._deserialize("SandboxCustomImage", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -696,22 +620,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.SandboxCustomImage].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/sandboxCustomImages/{sandboxCustomImageName}" - } + return AsyncLROPoller[_models.SandboxCustomImage]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, cluster_name: str, sandbox_custom_image_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -723,29 +645,32 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, cluster_name=cluster_name, sandbox_custom_image_name=sandbox_custom_image_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -757,12 +682,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/sandboxCustomImages/{sandboxCustomImageName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -777,14 +702,6 @@ async def begin_delete( :type cluster_name: str :param sandbox_custom_image_name: The name of the sandbox custom image. Required. :type sandbox_custom_image_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -798,7 +715,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, sandbox_custom_image_name=sandbox_custom_image_name, @@ -808,11 +725,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -821,17 +739,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/sandboxCustomImages/{sandboxCustomImageName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @overload async def check_name_availability( @@ -855,7 +769,6 @@ async def check_name_availability( :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: @@ -866,7 +779,7 @@ async def check_name_availability( self, resource_group_name: str, cluster_name: str, - resource_name: IO, + resource_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -879,11 +792,10 @@ async def check_name_availability( :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 + :type resource_name: IO[bytes] :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: @@ -894,7 +806,7 @@ async def check_name_availability( self, resource_group_name: str, cluster_name: str, - resource_name: Union[_models.SandboxCustomImagesCheckNameRequest, IO], + resource_name: Union[_models.SandboxCustomImagesCheckNameRequest, IO[bytes]], **kwargs: Any ) -> _models.CheckNameResult: """Checks that the sandbox custom image resource name is valid and is not already in use. @@ -905,17 +817,13 @@ async def check_name_availability( :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str :param resource_name: The name of the resource. Is either a SandboxCustomImagesCheckNameRequest - type or a IO type. Required. - :type resource_name: ~azure.mgmt.kusto.models.SandboxCustomImagesCheckNameRequest 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 + type or a IO[bytes] type. Required. + :type resource_name: ~azure.mgmt.kusto.models.SandboxCustomImagesCheckNameRequest or IO[bytes] :return: CheckNameResult or the result of cls(response) :rtype: ~azure.mgmt.kusto.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -938,7 +846,7 @@ async def check_name_availability( else: _json = self._serialize.body(resource_name, "SandboxCustomImagesCheckNameRequest") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, @@ -946,16 +854,14 @@ async def check_name_availability( content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -965,13 +871,9 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameResult", pipeline_response) + deserialized = self._deserialize("CheckNameResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/sandboxCustomImagesCheckNameAvailability" - } + return deserialized # 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 26f9bdc107c7..0e274c1a52e7 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,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import AsyncHttpResponse, 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 @@ -30,7 +32,6 @@ 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, @@ -40,6 +41,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -76,7 +81,6 @@ def list_by_database( :type cluster_name: str :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 Script or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.kusto.models.Script] :raises ~azure.core.exceptions.HttpResponseError: @@ -87,7 +91,7 @@ def list_by_database( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ScriptListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -98,18 +102,16 @@ def list_by_database( def prepare_request(next_link=None): if not next_link: - request = build_list_by_database_request( + _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, 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) else: # make call to next link with the client's api-version @@ -121,13 +123,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ScriptListResult", pipeline_response) @@ -137,11 +138,11 @@ async def extract_data(pipeline_response): return None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -154,10 +155,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts" - } - @distributed_trace_async async def get( self, resource_group_name: str, cluster_name: str, database_name: str, script_name: str, **kwargs: Any @@ -173,12 +170,11 @@ async def get( :type database_name: str :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: ~azure.mgmt.kusto.models.Script :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -192,23 +188,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Script] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_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, - 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) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -218,16 +212,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Script", pipeline_response) + deserialized = self._deserialize("Script", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, @@ -235,10 +225,10 @@ async def _create_or_update_initial( cluster_name: str, database_name: str, script_name: str, - parameters: Union[_models.Script, IO], + parameters: Union[_models.Script, IO[bytes]], **kwargs: Any - ) -> _models.Script: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -251,7 +241,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Script] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -261,7 +251,7 @@ async def _create_or_update_initial( else: _json = self._serialize.body(parameters, "Script") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -271,48 +261,41 @@ async def _create_or_update_initial( 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Script", pipeline_response) - - if response.status_code == 201: - 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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}" - } - @overload async def begin_create_or_update( self, @@ -341,14 +324,6 @@ async def begin_create_or_update( :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] @@ -362,7 +337,7 @@ async def begin_create_or_update( cluster_name: str, database_name: str, script_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -379,18 +354,10 @@ async def begin_create_or_update( :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 + :type parameters: IO[bytes] :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] @@ -404,7 +371,7 @@ async def begin_create_or_update( cluster_name: str, database_name: str, script_name: str, - parameters: Union[_models.Script, IO], + parameters: Union[_models.Script, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Script]: """Creates a Kusto database script. @@ -419,19 +386,8 @@ async def begin_create_or_update( :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. Is either a Script 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 - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.kusto.models.Script or IO[bytes] :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] @@ -460,12 +416,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Script", pipeline_response) + deserialized = self._deserialize("Script", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -475,17 +432,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Script].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}" - } + return AsyncLROPoller[_models.Script]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, @@ -493,10 +448,10 @@ async def _update_initial( cluster_name: str, database_name: str, script_name: str, - parameters: Union[_models.Script, IO], + parameters: Union[_models.Script, IO[bytes]], **kwargs: Any - ) -> _models.Script: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -509,7 +464,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Script] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -519,7 +474,7 @@ async def _update_initial( else: _json = self._serialize.body(parameters, "Script") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -529,46 +484,42 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Script", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Azure-AsyncOperation"] = self._deserialize( "str", response.headers.get("Azure-AsyncOperation") ) - deserialized = self._deserialize("Script", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}" - } - @overload async def begin_update( self, @@ -597,14 +548,6 @@ async def begin_update( :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] @@ -618,7 +561,7 @@ async def begin_update( cluster_name: str, database_name: str, script_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -635,18 +578,10 @@ async def begin_update( :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 + :type parameters: IO[bytes] :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] @@ -660,7 +595,7 @@ async def begin_update( cluster_name: str, database_name: str, script_name: str, - parameters: Union[_models.Script, IO], + parameters: Union[_models.Script, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Script]: """Updates a database script. @@ -675,19 +610,8 @@ async def begin_update( :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. Is either a Script - 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 - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.kusto.models.Script or IO[bytes] :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] @@ -716,12 +640,13 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Script", pipeline_response) + deserialized = self._deserialize("Script", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -731,22 +656,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Script].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}" - } + return AsyncLROPoller[_models.Script]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, cluster_name: str, database_name: str, script_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -758,30 +681,33 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_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, - 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -793,12 +719,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -815,14 +741,6 @@ async def begin_delete( :type database_name: str :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. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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: @@ -836,7 +754,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -847,11 +765,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -860,17 +779,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @overload async def check_name_availability( @@ -897,7 +812,6 @@ async def check_name_availability( :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: @@ -909,7 +823,7 @@ async def check_name_availability( resource_group_name: str, cluster_name: str, database_name: str, - script_name: IO, + script_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -924,11 +838,10 @@ async def check_name_availability( :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 + :type script_name: IO[bytes] :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: @@ -940,7 +853,7 @@ async def check_name_availability( resource_group_name: str, cluster_name: str, database_name: str, - script_name: Union[_models.ScriptCheckNameRequest, IO], + script_name: Union[_models.ScriptCheckNameRequest, IO[bytes]], **kwargs: Any ) -> _models.CheckNameResult: """Checks that the script name is valid and is not already in use. @@ -952,18 +865,14 @@ async def check_name_availability( :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. Is either a ScriptCheckNameRequest 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 + :param script_name: The name of the script. Is either a ScriptCheckNameRequest type or a + IO[bytes] type. Required. + :type script_name: ~azure.mgmt.kusto.models.ScriptCheckNameRequest or IO[bytes] :return: CheckNameResult or the result of cls(response) :rtype: ~azure.mgmt.kusto.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -986,7 +895,7 @@ async def check_name_availability( else: _json = self._serialize.body(script_name, "ScriptCheckNameRequest") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -995,16 +904,14 @@ async def check_name_availability( content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1014,13 +921,9 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameResult", pipeline_response) + deserialized = self._deserialize("CheckNameResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scriptsCheckNameAvailability" - } + return deserialized # type: ignore diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_skus_operations.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_skus_operations.py index 9a0217d203f6..26b735680f02 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_skus_operations.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/aio/operations/_skus_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,16 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._skus_operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -58,7 +61,6 @@ def list(self, location: str, **kwargs: Any) -> AsyncIterable["_models.SkuDescri :param location: The name of Azure region. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :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: @@ -69,7 +71,7 @@ def list(self, location: str, **kwargs: Any) -> AsyncIterable["_models.SkuDescri api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SkuDescriptionList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -80,16 +82,14 @@ def list(self, location: str, **kwargs: Any) -> AsyncIterable["_models.SkuDescri def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( location=location, 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) else: # make call to next link with the client's api-version @@ -101,13 +101,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("SkuDescriptionList", pipeline_response) @@ -117,11 +116,11 @@ async def extract_data(pipeline_response): return None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -133,5 +132,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/locations/{location}/skus"} 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 c55311857679..6cdd3072bdf6 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 @@ -13,6 +13,9 @@ from ._models_py3 import AzureCapacity from ._models_py3 import AzureResourceSku from ._models_py3 import AzureSku +from ._models_py3 import CalloutPoliciesList +from ._models_py3 import CalloutPolicy +from ._models_py3 import CalloutPolicyToRemove from ._models_py3 import CheckNameRequest from ._models_py3 import CheckNameResult from ._models_py3 import Cluster @@ -51,7 +54,9 @@ from ._models_py3 import EventGridDataConnection from ._models_py3 import EventHubDataConnection from ._models_py3 import FollowerDatabaseDefinition +from ._models_py3 import FollowerDatabaseDefinitionGet from ._models_py3 import FollowerDatabaseListResult +from ._models_py3 import FollowerDatabaseListResultGet from ._models_py3 import Identity from ._models_py3 import IotHubDataConnection from ._models_py3 import KeyVaultProperties @@ -102,6 +107,7 @@ 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 CalloutType from ._kusto_management_client_enums import ClusterNetworkAccessFlag from ._kusto_management_client_enums import ClusterPrincipalRole from ._kusto_management_client_enums import Compression @@ -122,16 +128,20 @@ from ._kusto_management_client_enums import LanguageExtensionImageName from ._kusto_management_client_enums import LanguageExtensionName from ._kusto_management_client_enums import MigrationClusterRole +from ._kusto_management_client_enums import OutboundAccess +from ._kusto_management_client_enums import PrincipalPermissionsAction 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 ScriptLevel from ._kusto_management_client_enums import State from ._kusto_management_client_enums import Status from ._kusto_management_client_enums import Type from ._kusto_management_client_enums import VnetState +from ._kusto_management_client_enums import ZoneStatus from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk @@ -144,6 +154,9 @@ "AzureCapacity", "AzureResourceSku", "AzureSku", + "CalloutPoliciesList", + "CalloutPolicy", + "CalloutPolicyToRemove", "CheckNameRequest", "CheckNameResult", "Cluster", @@ -182,7 +195,9 @@ "EventGridDataConnection", "EventHubDataConnection", "FollowerDatabaseDefinition", + "FollowerDatabaseDefinitionGet", "FollowerDatabaseListResult", + "FollowerDatabaseListResultGet", "Identity", "IotHubDataConnection", "KeyVaultProperties", @@ -232,6 +247,7 @@ "AzureSkuTier", "BlobStorageEventType", "CallerRole", + "CalloutType", "ClusterNetworkAccessFlag", "ClusterPrincipalRole", "Compression", @@ -252,16 +268,20 @@ "LanguageExtensionImageName", "LanguageExtensionName", "MigrationClusterRole", + "OutboundAccess", + "PrincipalPermissionsAction", "PrincipalType", "PrincipalsModificationKind", "ProvisioningState", "PublicIPType", "PublicNetworkAccess", "Reason", + "ScriptLevel", "State", "Status", "Type", "VnetState", + "ZoneStatus", ] __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 bcd40215c6d2..9f79f40b56d5 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 @@ -108,6 +108,24 @@ class CallerRole(str, Enum, metaclass=CaseInsensitiveEnumMeta): NONE = "None" +class CalloutType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the callout service, specifying the kind of external resource or service being + accessed. + """ + + KUSTO = "kusto" + SQL = "sql" + COSMOSDB = "cosmosdb" + EXTERNAL_DATA = "external_data" + AZURE_DIGITAL_TWINS = "azure_digital_twins" + SANDBOX_ARTIFACTS = "sandbox_artifacts" + WEBAPI = "webapi" + MYSQL = "mysql" + POSTGRESQL = "postgresql" + GENEVAMETRICS = "genevametrics" + AZURE_OPENAI = "azure_openai" + + 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'. @@ -122,6 +140,7 @@ class ClusterPrincipalRole(str, Enum, metaclass=CaseInsensitiveEnumMeta): ALL_DATABASES_ADMIN = "AllDatabasesAdmin" ALL_DATABASES_VIEWER = "AllDatabasesViewer" + ALL_DATABASES_MONITOR = "AllDatabasesMonitor" class Compression(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -296,6 +315,8 @@ class LanguageExtensionImageName(str, Enum, metaclass=CaseInsensitiveEnumMeta): PYTHON3_10_8 = "Python3_10_8" PYTHON3_10_8_DL = "Python3_10_8_DL" PYTHON_CUSTOM_IMAGE = "PythonCustomImage" + PYTHON3_11_7 = "Python3_11_7" + PYTHON3_11_7_DL = "Python3_11_7_DL" class LanguageExtensionName(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -312,6 +333,20 @@ class MigrationClusterRole(str, Enum, metaclass=CaseInsensitiveEnumMeta): DESTINATION = "Destination" +class OutboundAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates whether outbound access is permitted for the specified URI pattern.""" + + ALLOW = "Allow" + DENY = "Deny" + + +class PrincipalPermissionsAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates if the permissions for the script caller are kept following completion of the script.""" + + RETAIN_PERMISSION_ON_SCRIPT_COMPLETION = "RetainPermissionOnScriptCompletion" + REMOVE_PERMISSION_ON_SCRIPT_COMPLETION = "RemovePermissionOnScriptCompletion" + + class PrincipalsModificationKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The principals modification kind of the database.""" @@ -363,6 +398,15 @@ class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): ALREADY_EXISTS = "AlreadyExists" +class ScriptLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Differentiates between the type of script commands included - Database or Cluster. The default + is Database. + """ + + DATABASE = "Database" + CLUSTER = "Cluster" + + class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The state of the resource.""" @@ -403,3 +447,11 @@ class VnetState(str, Enum, metaclass=CaseInsensitiveEnumMeta): ENABLED = "Enabled" DISABLED = "Disabled" + + +class ZoneStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates whether the cluster is zonal or non-zonal.""" + + NON_ZONAL = "NonZonal" + ZONAL_INCONSISTENCY = "ZonalInconsistency" + ZONAL = "Zonal" 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 20bd97f12add..e70dc66d3253 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 @@ -50,7 +50,7 @@ class Resource(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -86,7 +86,7 @@ class ProxyResource(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -95,22 +95,6 @@ class ProxyResource(Resource): :vartype type: str """ - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - class AttachedDatabaseConfiguration(ProxyResource): # pylint: disable=too-many-instance-attributes """Class representing an attached database configuration. @@ -118,7 +102,7 @@ class AttachedDatabaseConfiguration(ProxyResource): # pylint: disable=too-many- Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -247,12 +231,12 @@ def __init__(self, *, value: Optional[List["_models.AttachedDatabaseConfiguratio self.value = value -class AttachedDatabaseConfigurationsCheckNameRequest(_serialization.Model): +class AttachedDatabaseConfigurationsCheckNameRequest(_serialization.Model): # pylint: disable=name-too-long """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. + All required parameters must be populated in order to send to server. :ivar name: Attached database resource name. Required. :vartype name: str @@ -286,7 +270,7 @@ def __init__(self, *, name: str, **kwargs: Any) -> None: class AzureCapacity(_serialization.Model): """Azure capacity definition. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar scale_type: Scale type. Required. Known values are: "automatic", "manual", and "none". :vartype scale_type: str or ~azure.mgmt.kusto.models.AzureScaleType @@ -380,7 +364,7 @@ def __init__( class AzureSku(_serialization.Model): """Azure SKU definition. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :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", @@ -459,10 +443,117 @@ def __init__( self.tier = tier +class CalloutPoliciesList(_serialization.Model): + """A list of the service's callout policy objects. + + :ivar value: A list of the service's callout policies. + :vartype value: list[~azure.mgmt.kusto.models.CalloutPolicy] + :ivar next_link: The URL to get the next set of callout policies list results if there are any. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[CalloutPolicy]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.CalloutPolicy"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: A list of the service's callout policies. + :paramtype value: list[~azure.mgmt.kusto.models.CalloutPolicy] + :keyword next_link: The URL to get the next set of callout policies list results if there are + any. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class CalloutPolicy(_serialization.Model): + """Configuration for external callout policies, including URI patterns, access types, and service + types. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar callout_uri_regex: Regular expression or FQDN pattern for the callout URI. + :vartype callout_uri_regex: str + :ivar callout_type: Type of the callout service, specifying the kind of external resource or + service being accessed. Known values are: "kusto", "sql", "cosmosdb", "external_data", + "azure_digital_twins", "sandbox_artifacts", "webapi", "mysql", "postgresql", "genevametrics", + and "azure_openai". + :vartype callout_type: str or ~azure.mgmt.kusto.models.CalloutType + :ivar outbound_access: Indicates whether outbound access is permitted for the specified URI + pattern. Known values are: "Allow" and "Deny". + :vartype outbound_access: str or ~azure.mgmt.kusto.models.OutboundAccess + :ivar callout_id: Unique identifier for the callout configuration. + :vartype callout_id: str + """ + + _validation = { + "callout_id": {"readonly": True}, + } + + _attribute_map = { + "callout_uri_regex": {"key": "calloutUriRegex", "type": "str"}, + "callout_type": {"key": "calloutType", "type": "str"}, + "outbound_access": {"key": "outboundAccess", "type": "str"}, + "callout_id": {"key": "calloutId", "type": "str"}, + } + + def __init__( + self, + *, + callout_uri_regex: Optional[str] = None, + callout_type: Optional[Union[str, "_models.CalloutType"]] = None, + outbound_access: Optional[Union[str, "_models.OutboundAccess"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword callout_uri_regex: Regular expression or FQDN pattern for the callout URI. + :paramtype callout_uri_regex: str + :keyword callout_type: Type of the callout service, specifying the kind of external resource or + service being accessed. Known values are: "kusto", "sql", "cosmosdb", "external_data", + "azure_digital_twins", "sandbox_artifacts", "webapi", "mysql", "postgresql", "genevametrics", + and "azure_openai". + :paramtype callout_type: str or ~azure.mgmt.kusto.models.CalloutType + :keyword outbound_access: Indicates whether outbound access is permitted for the specified URI + pattern. Known values are: "Allow" and "Deny". + :paramtype outbound_access: str or ~azure.mgmt.kusto.models.OutboundAccess + """ + super().__init__(**kwargs) + self.callout_uri_regex = callout_uri_regex + self.callout_type = callout_type + self.outbound_access = outbound_access + self.callout_id = None + + +class CalloutPolicyToRemove(_serialization.Model): + """Configuration for an external callout policy to remove. + + :ivar callout_id: Unique identifier for the callout configuration. + :vartype callout_id: str + """ + + _attribute_map = { + "callout_id": {"key": "calloutId", "type": "str"}, + } + + def __init__(self, *, callout_id: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword callout_id: Unique identifier for the callout configuration. + :paramtype callout_id: str + """ + super().__init__(**kwargs) + self.callout_id = callout_id + + 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. + All required parameters must be populated in order to send to server. :ivar name: Resource name. Required. :vartype name: str @@ -552,10 +643,10 @@ class TrackedResource(Resource): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -600,10 +691,10 @@ class Cluster(TrackedResource): # pylint: disable=too-many-instance-attributes 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. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -678,6 +769,8 @@ class Cluster(TrackedResource): # pylint: disable=too-many-instance-attributes :ivar allowed_fqdn_list: List of allowed FQDNs(Fully Qualified Domain Name) for egress from Cluster. :vartype allowed_fqdn_list: list[str] + :ivar callout_policies: List of callout policies for egress from Cluster. + :vartype callout_policies: list[~azure.mgmt.kusto.models.CalloutPolicy] :ivar public_ip_type: Indicates what public IP type to create - IPv4 (default), or DualStack (both IPv4 and IPv6). Known values are: "IPv4" and "DualStack". :vartype public_ip_type: str or ~azure.mgmt.kusto.models.PublicIPType @@ -688,6 +781,9 @@ class Cluster(TrackedResource): # pylint: disable=too-many-instance-attributes :ivar migration_cluster: Properties of the peer cluster involved in a migration to/from this cluster. :vartype migration_cluster: ~azure.mgmt.kusto.models.MigrationClusterProperties + :ivar zone_status: Indicates whether the cluster is zonal or non-zonal. Known values are: + "NonZonal", "ZonalInconsistency", and "Zonal". + :vartype zone_status: str or ~azure.mgmt.kusto.models.ZoneStatus """ _validation = { @@ -705,6 +801,7 @@ class Cluster(TrackedResource): # pylint: disable=too-many-instance-attributes "state_reason": {"readonly": True}, "private_endpoint_connections": {"readonly": True}, "migration_cluster": {"readonly": True}, + "zone_status": {"readonly": True}, } _attribute_map = { @@ -742,6 +839,7 @@ class Cluster(TrackedResource): # pylint: disable=too-many-instance-attributes "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]"}, + "callout_policies": {"key": "properties.calloutPolicies", "type": "[CalloutPolicy]"}, "public_ip_type": {"key": "properties.publicIPType", "type": "str"}, "virtual_cluster_graduation_properties": { "key": "properties.virtualClusterGraduationProperties", @@ -752,6 +850,7 @@ class Cluster(TrackedResource): # pylint: disable=too-many-instance-attributes "type": "[PrivateEndpointConnection]", }, "migration_cluster": {"key": "properties.migrationCluster", "type": "MigrationClusterProperties"}, + "zone_status": {"key": "properties.zoneStatus", "type": "str"}, } def __init__( # pylint: disable=too-many-locals @@ -778,6 +877,7 @@ def __init__( # pylint: disable=too-many-locals enable_auto_stop: bool = True, restrict_outbound_network_access: Union[str, "_models.ClusterNetworkAccessFlag"] = "Disabled", allowed_fqdn_list: Optional[List[str]] = None, + callout_policies: Optional[List["_models.CalloutPolicy"]] = None, public_ip_type: Union[str, "_models.PublicIPType"] = "IPv4", virtual_cluster_graduation_properties: Optional[str] = None, **kwargs: Any @@ -836,6 +936,8 @@ def __init__( # pylint: disable=too-many-locals :keyword allowed_fqdn_list: List of allowed FQDNs(Fully Qualified Domain Name) for egress from Cluster. :paramtype allowed_fqdn_list: list[str] + :keyword callout_policies: List of callout policies for egress from Cluster. + :paramtype callout_policies: list[~azure.mgmt.kusto.models.CalloutPolicy] :keyword public_ip_type: Indicates what public IP type to create - IPv4 (default), or DualStack (both IPv4 and IPv6). Known values are: "IPv4" and "DualStack". :paramtype public_ip_type: str or ~azure.mgmt.kusto.models.PublicIPType @@ -869,10 +971,12 @@ def __init__( # pylint: disable=too-many-locals self.enable_auto_stop = enable_auto_stop self.restrict_outbound_network_access = restrict_outbound_network_access self.allowed_fqdn_list = allowed_fqdn_list + self.callout_policies = callout_policies self.public_ip_type = public_ip_type self.virtual_cluster_graduation_properties = virtual_cluster_graduation_properties self.private_endpoint_connections = None self.migration_cluster = None + self.zone_status = None class ClusterCheckNameRequest(_serialization.Model): @@ -880,7 +984,7 @@ class ClusterCheckNameRequest(_serialization.Model): 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. + All required parameters must be populated in order to send to server. :ivar name: Cluster name. Required. :vartype name: str @@ -933,7 +1037,7 @@ def __init__(self, *, value: Optional[List["_models.Cluster"]] = None, **kwargs: class ClusterMigrateRequest(_serialization.Model): """A cluster migrate request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar cluster_resource_id: Resource ID of the destination cluster or kusto pool. Required. :vartype cluster_resource_id: str @@ -962,7 +1066,7 @@ class ClusterPrincipalAssignment(ProxyResource): # pylint: disable=too-many-ins Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -972,8 +1076,8 @@ class ClusterPrincipalAssignment(ProxyResource): # pylint: disable=too-many-ins :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. Known values are: "AllDatabasesAdmin" and - "AllDatabasesViewer". + :ivar role: Cluster principal role. Known values are: "AllDatabasesAdmin", + "AllDatabasesViewer", and "AllDatabasesMonitor". :vartype role: str or ~azure.mgmt.kusto.models.ClusterPrincipalRole :ivar tenant_id: The tenant id of the principal. :vartype tenant_id: str @@ -1027,8 +1131,8 @@ def __init__( :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. Known values are: "AllDatabasesAdmin" and - "AllDatabasesViewer". + :keyword role: Cluster principal role. Known values are: "AllDatabasesAdmin", + "AllDatabasesViewer", and "AllDatabasesMonitor". :paramtype role: str or ~azure.mgmt.kusto.models.ClusterPrincipalRole :keyword tenant_id: The tenant id of the principal. :paramtype tenant_id: str @@ -1046,12 +1150,12 @@ def __init__( self.aad_object_id = None -class ClusterPrincipalAssignmentCheckNameRequest(_serialization.Model): +class ClusterPrincipalAssignmentCheckNameRequest(_serialization.Model): # pylint: disable=name-too-long """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. + All required parameters must be populated in order to send to server. :ivar name: Principal Assignment resource name. Required. :vartype name: str @@ -1107,7 +1211,7 @@ class ClusterUpdate(Resource): # pylint: disable=too-many-instance-attributes Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -1178,6 +1282,8 @@ class ClusterUpdate(Resource): # pylint: disable=too-many-instance-attributes :ivar allowed_fqdn_list: List of allowed FQDNs(Fully Qualified Domain Name) for egress from Cluster. :vartype allowed_fqdn_list: list[str] + :ivar callout_policies: List of callout policies for egress from Cluster. + :vartype callout_policies: list[~azure.mgmt.kusto.models.CalloutPolicy] :ivar public_ip_type: Indicates what public IP type to create - IPv4 (default), or DualStack (both IPv4 and IPv6). Known values are: "IPv4" and "DualStack". :vartype public_ip_type: str or ~azure.mgmt.kusto.models.PublicIPType @@ -1188,6 +1294,9 @@ class ClusterUpdate(Resource): # pylint: disable=too-many-instance-attributes :ivar migration_cluster: Properties of the peer cluster involved in a migration to/from this cluster. :vartype migration_cluster: ~azure.mgmt.kusto.models.MigrationClusterProperties + :ivar zone_status: Indicates whether the cluster is zonal or non-zonal. Known values are: + "NonZonal", "ZonalInconsistency", and "Zonal". + :vartype zone_status: str or ~azure.mgmt.kusto.models.ZoneStatus """ _validation = { @@ -1201,6 +1310,7 @@ class ClusterUpdate(Resource): # pylint: disable=too-many-instance-attributes "state_reason": {"readonly": True}, "private_endpoint_connections": {"readonly": True}, "migration_cluster": {"readonly": True}, + "zone_status": {"readonly": True}, } _attribute_map = { @@ -1236,6 +1346,7 @@ class ClusterUpdate(Resource): # pylint: disable=too-many-instance-attributes "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]"}, + "callout_policies": {"key": "properties.calloutPolicies", "type": "[CalloutPolicy]"}, "public_ip_type": {"key": "properties.publicIPType", "type": "str"}, "virtual_cluster_graduation_properties": { "key": "properties.virtualClusterGraduationProperties", @@ -1246,6 +1357,7 @@ class ClusterUpdate(Resource): # pylint: disable=too-many-instance-attributes "type": "[PrivateEndpointConnection]", }, "migration_cluster": {"key": "properties.migrationCluster", "type": "MigrationClusterProperties"}, + "zone_status": {"key": "properties.zoneStatus", "type": "str"}, } def __init__( # pylint: disable=too-many-locals @@ -1272,6 +1384,7 @@ def __init__( # pylint: disable=too-many-locals enable_auto_stop: bool = True, restrict_outbound_network_access: Union[str, "_models.ClusterNetworkAccessFlag"] = "Disabled", allowed_fqdn_list: Optional[List[str]] = None, + callout_policies: Optional[List["_models.CalloutPolicy"]] = None, public_ip_type: Union[str, "_models.PublicIPType"] = "IPv4", virtual_cluster_graduation_properties: Optional[str] = None, **kwargs: Any @@ -1330,6 +1443,8 @@ def __init__( # pylint: disable=too-many-locals :keyword allowed_fqdn_list: List of allowed FQDNs(Fully Qualified Domain Name) for egress from Cluster. :paramtype allowed_fqdn_list: list[str] + :keyword callout_policies: List of callout policies for egress from Cluster. + :paramtype callout_policies: list[~azure.mgmt.kusto.models.CalloutPolicy] :keyword public_ip_type: Indicates what public IP type to create - IPv4 (default), or DualStack (both IPv4 and IPv6). Known values are: "IPv4" and "DualStack". :paramtype public_ip_type: str or ~azure.mgmt.kusto.models.PublicIPType @@ -1363,13 +1478,17 @@ def __init__( # pylint: disable=too-many-locals self.enable_auto_stop = enable_auto_stop self.restrict_outbound_network_access = restrict_outbound_network_access self.allowed_fqdn_list = allowed_fqdn_list + self.callout_policies = callout_policies self.public_ip_type = public_ip_type self.virtual_cluster_graduation_properties = virtual_cluster_graduation_properties self.private_endpoint_connections = None self.migration_cluster = None + self.zone_status = None -class ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties(_serialization.Model): +class ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties( + _serialization.Model +): # pylint: disable=name-too-long """ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties. Variables are only populated by the server, and will be ignored when sending a request. @@ -1405,10 +1524,10 @@ class DataConnection(ProxyResource): 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. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -1461,10 +1580,10 @@ class CosmosDbDataConnection(DataConnection): # pylint: disable=too-many-instan 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. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -1585,10 +1704,10 @@ class Database(ProxyResource): 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. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -1632,7 +1751,7 @@ def __init__(self, *, location: Optional[str] = None, **kwargs: Any) -> None: class DatabaseInviteFollowerRequest(_serialization.Model): """The request to invite a follower to a database. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar invitee_email: The email of the invited user for which the follower invitation is generated. Required. @@ -1722,7 +1841,7 @@ class DatabasePrincipal(_serialization.Model): 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. + All required parameters must be populated in order to send to server. :ivar role: Database principal role. Required. Known values are: "Admin", "Ingestor", "Monitor", "User", "UnrestrictedViewer", and "Viewer". @@ -1800,7 +1919,7 @@ class DatabasePrincipalAssignment(ProxyResource): # pylint: disable=too-many-in Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -1884,12 +2003,12 @@ def __init__( self.aad_object_id = None -class DatabasePrincipalAssignmentCheckNameRequest(_serialization.Model): +class DatabasePrincipalAssignmentCheckNameRequest(_serialization.Model): # pylint: disable=name-too-long """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. + All required parameters must be populated in order to send to server. :ivar name: Principal Assignment resource name. Required. :vartype name: str @@ -2004,7 +2123,7 @@ class DataConnectionCheckNameRequest(_serialization.Model): 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. + All required parameters must be populated in order to send to server. :ivar name: Data Connection name. Required. :vartype name: str @@ -2303,10 +2422,10 @@ class EventGridDataConnection(DataConnection): # pylint: disable=too-many-insta 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. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -2465,10 +2584,10 @@ class EventHubDataConnection(DataConnection): # pylint: disable=too-many-instan 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. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -2619,7 +2738,7 @@ class FollowerDatabaseDefinition(_serialization.Model): 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. + All required parameters must be populated in order to send to server. :ivar cluster_resource_id: Resource id of the cluster that follows a database owned by this cluster. Required. @@ -2670,6 +2789,67 @@ def __init__(self, *, cluster_resource_id: str, attached_database_configuration_ self.database_share_origin = None +class FollowerDatabaseDefinitionGet(_serialization.Model): + """A class representing follower database object. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar cluster_resource_id: Resource id of the cluster that follows a database owned by this + cluster. + :vartype cluster_resource_id: str + :ivar attached_database_configuration_name: Resource name of the attached database + configuration in the follower cluster. + :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 = { + "database_name": {"readonly": True}, + "table_level_sharing_properties": {"readonly": True}, + "database_share_origin": {"readonly": True}, + } + + _attribute_map = { + "cluster_resource_id": {"key": "properties.clusterResourceId", "type": "str"}, + "attached_database_configuration_name": {"key": "properties.attachedDatabaseConfigurationName", "type": "str"}, + "database_name": {"key": "properties.databaseName", "type": "str"}, + "table_level_sharing_properties": { + "key": "properties.tableLevelSharingProperties", + "type": "TableLevelSharingProperties", + }, + "database_share_origin": {"key": "properties.databaseShareOrigin", "type": "str"}, + } + + def __init__( + self, + *, + cluster_resource_id: Optional[str] = None, + attached_database_configuration_name: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword cluster_resource_id: Resource id of the cluster that follows a database owned by this + cluster. + :paramtype cluster_resource_id: str + :keyword attached_database_configuration_name: Resource name of the attached database + configuration in the follower cluster. + :paramtype attached_database_configuration_name: str + """ + 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(_serialization.Model): """The list Kusto database principals operation response. @@ -2690,12 +2870,46 @@ def __init__(self, *, value: Optional[List["_models.FollowerDatabaseDefinition"] self.value = value +class FollowerDatabaseListResultGet(_serialization.Model): + """The list Kusto database principals operation response. + + :ivar value: The list of follower database result. + :vartype value: list[~azure.mgmt.kusto.models.FollowerDatabaseDefinitionGet] + :ivar next_link: The URL to get the next set of follower databases list results if there are + any. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[FollowerDatabaseDefinitionGet]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.FollowerDatabaseDefinitionGet"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: The list of follower database result. + :paramtype value: list[~azure.mgmt.kusto.models.FollowerDatabaseDefinitionGet] + :keyword next_link: The URL to get the next set of follower databases list results if there are + any. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar principal_id: The principal ID of resource identity. :vartype principal_id: str @@ -2708,7 +2922,7 @@ class Identity(_serialization.Model): :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}'. + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. # pylint: disable=line-too-long :vartype user_assigned_identities: dict[str, ~azure.mgmt.kusto.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] """ @@ -2746,7 +2960,7 @@ def __init__( :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}'. + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. # pylint: disable=line-too-long :paramtype user_assigned_identities: dict[str, ~azure.mgmt.kusto.models.ComponentsSgqdofSchemasIdentityPropertiesUserassignedidentitiesAdditionalproperties] """ @@ -2762,10 +2976,10 @@ class IotHubDataConnection(DataConnection): # pylint: disable=too-many-instance 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. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -2948,7 +3162,8 @@ class LanguageExtension(_serialization.Model): :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 :ivar language_extension_image_name: The language extension image name. Known values are: "R", - "Python3_6_5", "Python3_10_8", "Python3_10_8_DL", and "PythonCustomImage". + "Python3_6_5", "Python3_10_8", "Python3_10_8_DL", "PythonCustomImage", "Python3_11_7", and + "Python3_11_7_DL". :vartype language_extension_image_name: str or ~azure.mgmt.kusto.models.LanguageExtensionImageName :ivar language_extension_custom_image_name: The language extension custom image name. @@ -2974,7 +3189,8 @@ def __init__( "R". :paramtype language_extension_name: str or ~azure.mgmt.kusto.models.LanguageExtensionName :keyword language_extension_image_name: The language extension image name. Known values are: - "R", "Python3_6_5", "Python3_10_8", "Python3_10_8_DL", and "PythonCustomImage". + "R", "Python3_6_5", "Python3_10_8", "Python3_10_8_DL", "PythonCustomImage", "Python3_11_7", and + "Python3_11_7_DL". :paramtype language_extension_image_name: str or ~azure.mgmt.kusto.models.LanguageExtensionImageName :keyword language_extension_custom_image_name: The language extension custom image name. @@ -3032,7 +3248,7 @@ class ManagedPrivateEndpoint(ProxyResource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -3131,7 +3347,7 @@ class ManagedPrivateEndpointsCheckNameRequest(_serialization.Model): 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. + All required parameters must be populated in order to send to server. :ivar name: Managed private endpoint resource name. Required. :vartype name: str @@ -3420,7 +3636,7 @@ def __init__( 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. + All required parameters must be populated in order to send to server. :ivar version: The version of the template defined, for instance 1. Required. :vartype version: int @@ -3473,7 +3689,7 @@ class OutboundNetworkDependenciesEndpoint(ProxyResource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -3531,12 +3747,12 @@ def __init__( self.provisioning_state = None -class OutboundNetworkDependenciesEndpointListResult(_serialization.Model): +class OutboundNetworkDependenciesEndpointListResult(_serialization.Model): # pylint: disable=name-too-long """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. + All required parameters must be populated in order to send to server. :ivar value: Collection of resources. Required. :vartype value: list[~azure.mgmt.kusto.models.OutboundNetworkDependenciesEndpoint] @@ -3570,7 +3786,7 @@ class PrivateEndpointConnection(ProxyResource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -3684,7 +3900,7 @@ class PrivateLinkResource(Resource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -3750,7 +3966,7 @@ def __init__(self, *, value: Optional[List["_models.PrivateLinkResource"]] = Non self.value = value -class PrivateLinkServiceConnectionStateProperty(_serialization.Model): +class PrivateLinkServiceConnectionStateProperty(_serialization.Model): # pylint: disable=name-too-long """Connection State of the Private Endpoint Connection. Variables are only populated by the server, and will be ignored when sending a request. @@ -3792,10 +4008,10 @@ class ReadOnlyFollowingDatabase(Database): # pylint: disable=too-many-instance- 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. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -3908,10 +4124,10 @@ class ReadWriteDatabase(Database): # pylint: disable=too-many-instance-attribut 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. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -4063,7 +4279,7 @@ class SandboxCustomImage(ProxyResource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -4072,8 +4288,13 @@ class SandboxCustomImage(ProxyResource): :vartype type: str :ivar language: The language name, for example Python. "Python" :vartype language: str or ~azure.mgmt.kusto.models.Language - :ivar language_version: The version of the language. + :ivar language_version: The version of the language. Either this property or baseImageName + should be specified. :vartype language_version: str + :ivar base_image_name: The base image name on which the custom image is built on top of. It can + be one of the LanguageExtensionImageName (e.g.: 'Python3_10_8', 'Python3_10_8_DL') or the name + of an existing custom image. Either this property or languageVersion should be specified. + :vartype base_image_name: str :ivar requirements_file_content: The requirements file content. :vartype requirements_file_content: str :ivar provisioning_state: The provisioned state of the resource. Known values are: "Running", @@ -4094,6 +4315,7 @@ class SandboxCustomImage(ProxyResource): "type": {"key": "type", "type": "str"}, "language": {"key": "properties.language", "type": "str"}, "language_version": {"key": "properties.languageVersion", "type": "str"}, + "base_image_name": {"key": "properties.baseImageName", "type": "str"}, "requirements_file_content": {"key": "properties.requirementsFileContent", "type": "str"}, "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } @@ -4103,20 +4325,27 @@ def __init__( *, language: Optional[Union[str, "_models.Language"]] = None, language_version: Optional[str] = None, + base_image_name: Optional[str] = None, requirements_file_content: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword language: The language name, for example Python. "Python" :paramtype language: str or ~azure.mgmt.kusto.models.Language - :keyword language_version: The version of the language. + :keyword language_version: The version of the language. Either this property or baseImageName + should be specified. :paramtype language_version: str + :keyword base_image_name: The base image name on which the custom image is built on top of. It + can be one of the LanguageExtensionImageName (e.g.: 'Python3_10_8', 'Python3_10_8_DL') or the + name of an existing custom image. Either this property or languageVersion should be specified. + :paramtype base_image_name: str :keyword requirements_file_content: The requirements file content. :paramtype requirements_file_content: str """ super().__init__(**kwargs) self.language = language self.language_version = language_version + self.base_image_name = base_image_name self.requirements_file_content = requirements_file_content self.provisioning_state = None @@ -4126,7 +4355,7 @@ class SandboxCustomImagesCheckNameRequest(_serialization.Model): 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. + All required parameters must be populated in order to send to server. :ivar name: Sandbox custom image resource name. Required. :vartype name: str @@ -4188,13 +4417,13 @@ def __init__( self.value = value -class Script(ProxyResource): +class Script(ProxyResource): # pylint: disable=too-many-instance-attributes """Class representing a database script. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -4220,6 +4449,14 @@ class Script(ProxyResource): :ivar provisioning_state: The provisioned state of the resource. Known values are: "Running", "Creating", "Deleting", "Succeeded", "Failed", "Moving", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.kusto.models.ProvisioningState + :ivar script_level: Differentiates between the type of script commands included - Database or + Cluster. The default is Database. Known values are: "Database" and "Cluster". + :vartype script_level: str or ~azure.mgmt.kusto.models.ScriptLevel + :ivar principal_permissions_action: Indicates if the permissions for the script caller are kept + following completion of the script. Known values are: "RetainPermissionOnScriptCompletion" and + "RemovePermissionOnScriptCompletion". + :vartype principal_permissions_action: str or + ~azure.mgmt.kusto.models.PrincipalPermissionsAction """ _validation = { @@ -4241,6 +4478,8 @@ class Script(ProxyResource): "force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"}, "continue_on_errors": {"key": "properties.continueOnErrors", "type": "bool"}, "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "script_level": {"key": "properties.scriptLevel", "type": "str"}, + "principal_permissions_action": {"key": "properties.principalPermissionsAction", "type": "str"}, } def __init__( @@ -4251,6 +4490,8 @@ def __init__( script_content: Optional[str] = None, force_update_tag: Optional[str] = None, continue_on_errors: bool = False, + script_level: Optional[Union[str, "_models.ScriptLevel"]] = None, + principal_permissions_action: Optional[Union[str, "_models.PrincipalPermissionsAction"]] = None, **kwargs: Any ) -> None: """ @@ -4269,6 +4510,14 @@ def __init__( :keyword continue_on_errors: Flag that indicates whether to continue if one of the command fails. :paramtype continue_on_errors: bool + :keyword script_level: Differentiates between the type of script commands included - Database + or Cluster. The default is Database. Known values are: "Database" and "Cluster". + :paramtype script_level: str or ~azure.mgmt.kusto.models.ScriptLevel + :keyword principal_permissions_action: Indicates if the permissions for the script caller are + kept following completion of the script. Known values are: "RetainPermissionOnScriptCompletion" + and "RemovePermissionOnScriptCompletion". + :paramtype principal_permissions_action: str or + ~azure.mgmt.kusto.models.PrincipalPermissionsAction """ super().__init__(**kwargs) self.system_data = None @@ -4278,6 +4527,8 @@ def __init__( self.force_update_tag = force_update_tag self.continue_on_errors = continue_on_errors self.provisioning_state = None + self.script_level = script_level + self.principal_permissions_action = principal_permissions_action class ScriptCheckNameRequest(_serialization.Model): @@ -4285,7 +4536,7 @@ class ScriptCheckNameRequest(_serialization.Model): 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. + All required parameters must be populated in order to send to server. :ivar name: Script name. Required. :vartype name: str @@ -4409,7 +4660,7 @@ def __init__(self, **kwargs: Any) -> None: class SkuLocationInfoItem(_serialization.Model): """The locations and zones info for SKU. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar location: The available location of the SKU. Required. :vartype location: str @@ -4640,7 +4891,7 @@ def __init__(self, *, value: Optional[str] = None, **kwargs: Any) -> None: class VirtualNetworkConfiguration(_serialization.Model): """A class that contains virtual network definition. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar subnet_id: The subnet resource id. Required. :vartype subnet_id: str 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 7a3e5ead52b0..6ccc8a25f891 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,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +50,7 @@ def build_check_name_availability_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -81,7 +86,7 @@ def build_list_by_cluster_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -118,7 +123,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -158,7 +163,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -201,7 +206,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -273,7 +278,6 @@ def check_name_availability( :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: @@ -284,7 +288,7 @@ def check_name_availability( self, resource_group_name: str, cluster_name: str, - resource_name: IO, + resource_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -298,11 +302,10 @@ def check_name_availability( :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 + :type resource_name: IO[bytes] :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: @@ -313,7 +316,7 @@ def check_name_availability( self, resource_group_name: str, cluster_name: str, - resource_name: Union[_models.AttachedDatabaseConfigurationsCheckNameRequest, IO], + resource_name: Union[_models.AttachedDatabaseConfigurationsCheckNameRequest, IO[bytes]], **kwargs: Any ) -> _models.CheckNameResult: """Checks that the attached database configuration resource name is valid and is not already in @@ -325,18 +328,14 @@ def check_name_availability( :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str :param resource_name: The name of the resource. Is either a - AttachedDatabaseConfigurationsCheckNameRequest type or a IO type. Required. + AttachedDatabaseConfigurationsCheckNameRequest type or a IO[bytes] 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 + IO[bytes] :return: CheckNameResult or the result of cls(response) :rtype: ~azure.mgmt.kusto.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -359,7 +358,7 @@ def check_name_availability( else: _json = self._serialize.body(resource_name, "AttachedDatabaseConfigurationsCheckNameRequest") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, @@ -367,16 +366,14 @@ def check_name_availability( content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -386,16 +383,12 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameResult", pipeline_response) + deserialized = self._deserialize("CheckNameResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurationCheckNameAvailability" - } + return deserialized # type: ignore @distributed_trace def list_by_cluster( @@ -408,7 +401,6 @@ def list_by_cluster( :type resource_group_name: str :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 AttachedDatabaseConfiguration or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kusto.models.AttachedDatabaseConfiguration] @@ -420,7 +412,7 @@ def list_by_cluster( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AttachedDatabaseConfigurationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -431,17 +423,15 @@ def list_by_cluster( def prepare_request(next_link=None): if not next_link: - request = build_list_by_cluster_request( + _request = build_list_by_cluster_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_cluster.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -453,13 +443,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AttachedDatabaseConfigurationListResult", pipeline_response) @@ -469,11 +458,11 @@ def extract_data(pipeline_response): return None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -486,10 +475,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_cluster.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations" - } - @distributed_trace def get( self, resource_group_name: str, cluster_name: str, attached_database_configuration_name: str, **kwargs: Any @@ -504,12 +489,11 @@ def get( :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: ~azure.mgmt.kusto.models.AttachedDatabaseConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -523,22 +507,20 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AttachedDatabaseConfiguration] = kwargs.pop("cls", None) - request = build_get_request( + _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, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -548,26 +530,22 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AttachedDatabaseConfiguration", pipeline_response) + deserialized = self._deserialize("AttachedDatabaseConfiguration", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, cluster_name: str, attached_database_configuration_name: str, - parameters: Union[_models.AttachedDatabaseConfiguration, IO], + parameters: Union[_models.AttachedDatabaseConfiguration, IO[bytes]], **kwargs: Any - ) -> _models.AttachedDatabaseConfiguration: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -580,7 +558,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AttachedDatabaseConfiguration] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -590,7 +568,7 @@ def _create_or_update_initial( else: _json = self._serialize.body(parameters, "AttachedDatabaseConfiguration") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, attached_database_configuration_name=attached_database_configuration_name, @@ -599,48 +577,41 @@ def _create_or_update_initial( 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("AttachedDatabaseConfiguration", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AttachedDatabaseConfiguration", pipeline_response) - if response.status_code == 202: response_headers["Azure-AsyncOperation"] = self._deserialize( "str", response.headers.get("Azure-AsyncOperation") ) - deserialized = self._deserialize("AttachedDatabaseConfiguration", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}" - } - @overload def begin_create_or_update( self, @@ -667,14 +638,6 @@ def begin_create_or_update( :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] @@ -687,7 +650,7 @@ def begin_create_or_update( resource_group_name: str, cluster_name: str, attached_database_configuration_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -703,18 +666,10 @@ def begin_create_or_update( Required. :type attached_database_configuration_name: str :param parameters: The database parameters supplied to the CreateOrUpdate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :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] @@ -727,7 +682,7 @@ def begin_create_or_update( resource_group_name: str, cluster_name: str, attached_database_configuration_name: str, - parameters: Union[_models.AttachedDatabaseConfiguration, IO], + parameters: Union[_models.AttachedDatabaseConfiguration, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.AttachedDatabaseConfiguration]: """Creates or updates an attached database configuration. @@ -741,19 +696,8 @@ def begin_create_or_update( Required. :type attached_database_configuration_name: str :param parameters: The database parameters supplied to the CreateOrUpdate operation. Is either - a AttachedDatabaseConfiguration 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 - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + a AttachedDatabaseConfiguration type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.kusto.models.AttachedDatabaseConfiguration or IO[bytes] :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] @@ -781,12 +725,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AttachedDatabaseConfiguration", pipeline_response) + deserialized = self._deserialize("AttachedDatabaseConfiguration", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -796,22 +741,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.AttachedDatabaseConfiguration].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}" - } + return LROPoller[_models.AttachedDatabaseConfiguration]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, cluster_name: str, attached_database_configuration_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -823,29 +766,32 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _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, 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -857,12 +803,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -878,14 +824,6 @@ def begin_delete( :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. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~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: @@ -899,7 +837,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, attached_database_configuration_name=attached_database_configuration_name, @@ -909,11 +847,12 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -922,14 +861,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # 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 c65f43bcff71..b6ae23d88085 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,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +50,7 @@ def build_check_name_availability_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -81,7 +86,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -117,7 +122,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -156,7 +161,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -190,7 +195,7 @@ def build_list_request(resource_group_name: str, cluster_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -259,7 +264,6 @@ def check_name_availability( :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: @@ -270,7 +274,7 @@ def check_name_availability( self, resource_group_name: str, cluster_name: str, - principal_assignment_name: IO, + principal_assignment_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -283,11 +287,10 @@ def check_name_availability( :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 + :type principal_assignment_name: IO[bytes] :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: @@ -298,7 +301,7 @@ def check_name_availability( self, resource_group_name: str, cluster_name: str, - principal_assignment_name: Union[_models.ClusterPrincipalAssignmentCheckNameRequest, IO], + principal_assignment_name: Union[_models.ClusterPrincipalAssignmentCheckNameRequest, IO[bytes]], **kwargs: Any ) -> _models.CheckNameResult: """Checks that the principal assignment name is valid and is not already in use. @@ -309,18 +312,14 @@ def check_name_availability( :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str :param principal_assignment_name: The name of the principal assignment. Is either a - ClusterPrincipalAssignmentCheckNameRequest type or a IO type. Required. + ClusterPrincipalAssignmentCheckNameRequest type or a IO[bytes] type. Required. :type principal_assignment_name: - ~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 + ~azure.mgmt.kusto.models.ClusterPrincipalAssignmentCheckNameRequest or IO[bytes] :return: CheckNameResult or the result of cls(response) :rtype: ~azure.mgmt.kusto.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -343,7 +342,7 @@ def check_name_availability( else: _json = self._serialize.body(principal_assignment_name, "ClusterPrincipalAssignmentCheckNameRequest") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, @@ -351,16 +350,14 @@ def check_name_availability( content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -370,16 +367,12 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameResult", pipeline_response) + deserialized = self._deserialize("CheckNameResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/checkPrincipalAssignmentNameAvailability" - } + return deserialized # type: ignore @distributed_trace def get( @@ -394,12 +387,11 @@ def get( :type cluster_name: str :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: ~azure.mgmt.kusto.models.ClusterPrincipalAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -413,22 +405,20 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ClusterPrincipalAssignment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_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, - 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -438,26 +428,22 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ClusterPrincipalAssignment", pipeline_response) + deserialized = self._deserialize("ClusterPrincipalAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments/{principalAssignmentName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, cluster_name: str, principal_assignment_name: str, - parameters: Union[_models.ClusterPrincipalAssignment, IO], + parameters: Union[_models.ClusterPrincipalAssignment, IO[bytes]], **kwargs: Any - ) -> _models.ClusterPrincipalAssignment: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -470,7 +456,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ClusterPrincipalAssignment] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -480,7 +466,7 @@ def _create_or_update_initial( else: _json = self._serialize.body(parameters, "ClusterPrincipalAssignment") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, principal_assignment_name=principal_assignment_name, @@ -489,40 +475,35 @@ def _create_or_update_initial( 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ClusterPrincipalAssignment", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ClusterPrincipalAssignment", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments/{principalAssignmentName}" - } - @overload def begin_create_or_update( self, @@ -549,14 +530,6 @@ def begin_create_or_update( :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] @@ -569,7 +542,7 @@ def begin_create_or_update( resource_group_name: str, cluster_name: str, principal_assignment_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -585,18 +558,10 @@ def begin_create_or_update( :type principal_assignment_name: str :param parameters: The Kusto cluster principalAssignment's parameters supplied for the operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :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] @@ -609,7 +574,7 @@ def begin_create_or_update( resource_group_name: str, cluster_name: str, principal_assignment_name: str, - parameters: Union[_models.ClusterPrincipalAssignment, IO], + parameters: Union[_models.ClusterPrincipalAssignment, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.ClusterPrincipalAssignment]: """Create a Kusto cluster principalAssignment. @@ -622,19 +587,8 @@ def begin_create_or_update( :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. Is either a ClusterPrincipalAssignment 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 - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + operation. Is either a ClusterPrincipalAssignment type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.kusto.models.ClusterPrincipalAssignment or IO[bytes] :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] @@ -662,12 +616,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ClusterPrincipalAssignment", pipeline_response) + deserialized = self._deserialize("ClusterPrincipalAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -677,22 +632,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.ClusterPrincipalAssignment].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments/{principalAssignmentName}" - } + return LROPoller[_models.ClusterPrincipalAssignment]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, cluster_name: str, principal_assignment_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -704,29 +657,32 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_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, - 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -738,12 +694,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments/{principalAssignmentName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -758,14 +714,6 @@ def begin_delete( :type cluster_name: str :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. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~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: @@ -779,7 +727,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, principal_assignment_name=principal_assignment_name, @@ -789,11 +737,12 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -802,17 +751,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments/{principalAssignmentName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def list( @@ -825,7 +770,6 @@ def list( :type resource_group_name: str :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 ClusterPrincipalAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kusto.models.ClusterPrincipalAssignment] @@ -837,7 +781,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ClusterPrincipalAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -848,17 +792,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -870,13 +812,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ClusterPrincipalAssignmentListResult", pipeline_response) @@ -886,11 +827,11 @@ def extract_data(pipeline_response): return None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -902,7 +843,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/principalAssignments" - } 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 d0d17cad45ee..ff0f5b7e01c0 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,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +48,7 @@ def build_get_request(resource_group_name: str, cluster_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -82,7 +87,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -122,7 +127,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -160,7 +165,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -191,7 +196,7 @@ def build_stop_request(resource_group_name: str, cluster_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -224,7 +229,7 @@ def build_start_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -257,7 +262,7 @@ def build_migrate_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -287,13 +292,46 @@ def build_migrate_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) +def build_list_follower_databases_get_request( # pylint: disable=name-too-long + 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: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _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", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str", pattern=r"^.*$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + def build_list_follower_databases_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -326,7 +364,7 @@ def build_detach_follower_databases_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -362,7 +400,7 @@ def build_diagnose_virtual_network_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -393,7 +431,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -423,7 +461,7 @@ 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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -447,7 +485,7 @@ 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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -471,7 +509,7 @@ def build_check_name_availability_request(location: str, subscription_id: str, * _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -504,7 +542,7 @@ def build_list_skus_by_resource_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -531,13 +569,13 @@ def build_list_skus_by_resource_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_outbound_network_dependencies_endpoints_request( +def build_list_outbound_network_dependencies_endpoints_request( # pylint: disable=name-too-long 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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -564,13 +602,118 @@ def build_list_outbound_network_dependencies_endpoints_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) +def build_add_callout_policies_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: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/addCalloutPolicies", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str", pattern=r"^.*$"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_remove_callout_policy_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: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/removeCalloutPolicy", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str", pattern=r"^.*$"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_callout_policies_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: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/listCalloutPolicies", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str", pattern=r"^.*$"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + def build_list_language_extensions_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -603,7 +746,7 @@ def build_add_language_extensions_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -639,7 +782,7 @@ def build_remove_language_extensions_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -697,12 +840,11 @@ def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> _mo :type resource_group_name: str :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: ~azure.mgmt.kusto.models.Cluster :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -716,21 +858,19 @@ def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> _mo api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Cluster] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -740,27 +880,23 @@ def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> _mo error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Cluster", pipeline_response) + deserialized = self._deserialize("Cluster", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, cluster_name: str, - parameters: Union[_models.Cluster, IO], + parameters: Union[_models.Cluster, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> _models.Cluster: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -773,7 +909,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Cluster] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -783,7 +919,7 @@ def _create_or_update_initial( else: _json = self._serialize.body(parameters, "Cluster") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, @@ -793,40 +929,35 @@ def _create_or_update_initial( 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Cluster", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Cluster", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}" - } - @overload def begin_create_or_update( self, @@ -860,14 +991,6 @@ def begin_create_or_update( :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: @@ -878,7 +1001,7 @@ def begin_create_or_update( self, resource_group_name: str, cluster_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, if_none_match: Optional[str] = None, *, @@ -894,7 +1017,7 @@ def begin_create_or_update( :type cluster_name: str :param parameters: The Kusto cluster parameters supplied to the CreateOrUpdate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :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. @@ -906,14 +1029,6 @@ def begin_create_or_update( :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: @@ -924,7 +1039,7 @@ def begin_create_or_update( self, resource_group_name: str, cluster_name: str, - parameters: Union[_models.Cluster, IO], + parameters: Union[_models.Cluster, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any @@ -937,8 +1052,8 @@ def begin_create_or_update( :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 Cluster type or a IO type. Required. - :type parameters: ~azure.mgmt.kusto.models.Cluster or IO + either a Cluster type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.kusto.models.Cluster or IO[bytes] :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. @@ -947,17 +1062,6 @@ def begin_create_or_update( 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: @@ -985,12 +1089,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Cluster", pipeline_response) + deserialized = self._deserialize("Cluster", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1000,27 +1105,25 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Cluster].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}" - } + return LROPoller[_models.Cluster]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, resource_group_name: str, cluster_name: str, - parameters: Union[_models.ClusterUpdate, IO], + parameters: Union[_models.ClusterUpdate, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any - ) -> _models.Cluster: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1033,7 +1136,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Cluster] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1043,7 +1146,7 @@ def _update_initial( else: _json = self._serialize.body(parameters, "ClusterUpdate") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, @@ -1052,54 +1155,48 @@ def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Cluster", pipeline_response) - if response.status_code == 201: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) 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["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Azure-AsyncOperation"] = self._deserialize( "str", response.headers.get("Azure-AsyncOperation") ) - deserialized = self._deserialize("Cluster", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}" - } - @overload def begin_update( self, @@ -1127,14 +1224,6 @@ def begin_update( :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: @@ -1145,7 +1234,7 @@ def begin_update( self, resource_group_name: str, cluster_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, *, content_type: str = "application/json", @@ -1159,7 +1248,7 @@ def begin_update( :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 + :type parameters: IO[bytes] :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. @@ -1167,14 +1256,6 @@ def begin_update( :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: @@ -1185,7 +1266,7 @@ def begin_update( self, resource_group_name: str, cluster_name: str, - parameters: Union[_models.ClusterUpdate, IO], + parameters: Union[_models.ClusterUpdate, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any ) -> LROPoller[_models.Cluster]: @@ -1197,23 +1278,12 @@ def begin_update( :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. Is either a - ClusterUpdate type or a IO type. Required. - :type parameters: ~azure.mgmt.kusto.models.ClusterUpdate or IO + ClusterUpdate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.kusto.models.ClusterUpdate or IO[bytes] :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. 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: @@ -1240,12 +1310,13 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Cluster", pipeline_response) + deserialized = self._deserialize("Cluster", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1255,22 +1326,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Cluster].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}" - } + return LROPoller[_models.Cluster]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, cluster_name: str, **kwargs: Any - ) -> None: - error_map = { + def _delete_initial(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1282,28 +1349,31 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1315,12 +1385,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> LROPoller[None]: @@ -1331,14 +1401,6 @@ def begin_delete(self, resource_group_name: str, cluster_name: str, **kwargs: An :type resource_group_name: str :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. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~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: @@ -1352,7 +1414,7 @@ def begin_delete(self, resource_group_name: str, cluster_name: str, **kwargs: An lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, api_version=api_version, @@ -1361,11 +1423,12 @@ def begin_delete(self, resource_group_name: str, cluster_name: str, **kwargs: An params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -1374,22 +1437,16 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _stop_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, cluster_name: str, **kwargs: Any - ) -> None: - error_map = { + def _stop_initial(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1401,28 +1458,31 @@ def _stop_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1434,12 +1494,12 @@ def _stop_initial( # pylint: disable=inconsistent-return-statements "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _stop_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/stop" - } + return deserialized # type: ignore @distributed_trace def begin_stop(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> LROPoller[None]: @@ -1450,14 +1510,6 @@ def begin_stop(self, resource_group_name: str, cluster_name: str, **kwargs: Any) :type resource_group_name: str :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. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~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: @@ -1471,7 +1523,7 @@ def begin_stop(self, resource_group_name: str, cluster_name: str, **kwargs: Any) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._stop_initial( # type: ignore + raw_result = self._stop_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, api_version=api_version, @@ -1480,11 +1532,12 @@ def begin_stop(self, resource_group_name: str, cluster_name: str, **kwargs: Any) params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -1493,22 +1546,16 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_stop.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/stop" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _start_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, cluster_name: str, **kwargs: Any - ) -> None: - error_map = { + def _start_initial(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1520,28 +1567,31 @@ def _start_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_start_request( + _request = build_start_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1553,12 +1603,12 @@ def _start_initial( # pylint: disable=inconsistent-return-statements "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _start_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/start" - } + return deserialized # type: ignore @distributed_trace def begin_start(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> LROPoller[None]: @@ -1569,14 +1619,6 @@ def begin_start(self, resource_group_name: str, cluster_name: str, **kwargs: Any :type resource_group_name: str :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. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~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: @@ -1590,7 +1632,7 @@ def begin_start(self, resource_group_name: str, cluster_name: str, **kwargs: Any lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._start_initial( # type: ignore + raw_result = self._start_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, api_version=api_version, @@ -1599,11 +1641,12 @@ def begin_start(self, resource_group_name: str, cluster_name: str, **kwargs: Any params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -1612,26 +1655,22 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_start.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/start" - } - - def _migrate_initial( # pylint: disable=inconsistent-return-statements + def _migrate_initial( self, resource_group_name: str, cluster_name: str, - cluster_migrate_request: Union[_models.ClusterMigrateRequest, IO], + cluster_migrate_request: Union[_models.ClusterMigrateRequest, IO[bytes]], **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1644,7 +1683,7 @@ def _migrate_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1654,7 +1693,7 @@ def _migrate_initial( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(cluster_migrate_request, "ClusterMigrateRequest") - request = build_migrate_request( + _request = build_migrate_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, @@ -1662,21 +1701,24 @@ def _migrate_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self._migrate_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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1688,12 +1730,12 @@ def _migrate_initial( # pylint: disable=inconsistent-return-statements "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _migrate_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/migrate" - } + return deserialized # type: ignore @overload def begin_migrate( @@ -1717,14 +1759,6 @@ def begin_migrate( :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: @@ -1735,7 +1769,7 @@ def begin_migrate( self, resource_group_name: str, cluster_name: str, - cluster_migrate_request: IO, + cluster_migrate_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1748,18 +1782,10 @@ def begin_migrate( :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str :param cluster_migrate_request: The cluster migrate request parameters. Required. - :type cluster_migrate_request: IO + :type cluster_migrate_request: IO[bytes] :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: @@ -1770,7 +1796,7 @@ def begin_migrate( self, resource_group_name: str, cluster_name: str, - cluster_migrate_request: Union[_models.ClusterMigrateRequest, IO], + cluster_migrate_request: Union[_models.ClusterMigrateRequest, IO[bytes]], **kwargs: Any ) -> LROPoller[None]: """Migrate data from a Kusto cluster to another cluster. @@ -1781,19 +1807,8 @@ def begin_migrate( :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str :param cluster_migrate_request: The cluster migrate request parameters. Is either a - ClusterMigrateRequest type or a IO type. Required. - :type cluster_migrate_request: ~azure.mgmt.kusto.models.ClusterMigrateRequest 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. + ClusterMigrateRequest type or a IO[bytes] type. Required. + :type cluster_migrate_request: ~azure.mgmt.kusto.models.ClusterMigrateRequest or IO[bytes] :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: @@ -1808,7 +1823,7 @@ def begin_migrate( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._migrate_initial( # type: ignore + raw_result = self._migrate_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, cluster_migrate_request=cluster_migrate_request, @@ -1819,11 +1834,12 @@ def begin_migrate( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -1832,22 +1848,18 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_migrate.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/migrate" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace - def list_follower_databases( + def list_follower_databases_get( self, resource_group_name: str, cluster_name: str, **kwargs: Any - ) -> Iterable["_models.FollowerDatabaseDefinition"]: + ) -> Iterable["_models.FollowerDatabaseDefinitionGet"]: """Returns a list of databases that are owned by this cluster and were followed by another cluster. @@ -1856,19 +1868,18 @@ def list_follower_databases( :type resource_group_name: str :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 FollowerDatabaseDefinition or the result of + :return: An iterator like instance of either FollowerDatabaseDefinitionGet or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kusto.models.FollowerDatabaseDefinition] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kusto.models.FollowerDatabaseDefinitionGet] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.FollowerDatabaseListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.FollowerDatabaseListResultGet] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1879,17 +1890,15 @@ def list_follower_databases( def prepare_request(next_link=None): if not next_link: - request = build_list_follower_databases_request( + _request = build_list_follower_databases_get_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.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) else: # make call to next link with the client's api-version @@ -1901,27 +1910,26 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): - deserialized = self._deserialize("FollowerDatabaseListResult", pipeline_response) + deserialized = self._deserialize("FollowerDatabaseListResultGet", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1934,18 +1942,30 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_follower_databases.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/listFollowerDatabases" - } + @distributed_trace + def list_follower_databases( + 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. - def _detach_follower_databases_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - cluster_name: str, - follower_database_to_remove: Union[_models.FollowerDatabaseDefinition, IO], - **kwargs: Any - ) -> None: - error_map = { + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :return: An iterator like instance of either FollowerDatabaseDefinition or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kusto.models.FollowerDatabaseDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.FollowerDatabaseListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1953,44 +1973,117 @@ def _detach_follower_databases_initial( # pylint: disable=inconsistent-return-s } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + def prepare_request(next_link=None): + if not next_link: - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + _request = build_list_follower_databases_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(follower_database_to_remove, (IOBase, bytes)): - _content = follower_database_to_remove - else: - _json = self._serialize.body(follower_database_to_remove, "FollowerDatabaseDefinition") + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request - request = build_detach_follower_databases_request( - resource_group_name=resource_group_name, - cluster_name=cluster_name, - subscription_id=self._config.subscription_id, + def extract_data(pipeline_response): + deserialized = self._deserialize("FollowerDatabaseListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _detach_follower_databases_initial( + self, + resource_group_name: str, + cluster_name: str, + follower_database_to_remove: Union[_models.FollowerDatabaseDefinition, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(follower_database_to_remove, (IOBase, bytes)): + _content = follower_database_to_remove + else: + _json = self._serialize.body(follower_database_to_remove, "FollowerDatabaseDefinition") + + _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, 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -2002,12 +2095,12 @@ def _detach_follower_databases_initial( # pylint: disable=inconsistent-return-s "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _detach_follower_databases_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/detachFollowerDatabases" - } + return deserialized # type: ignore @overload def begin_detach_follower_databases( @@ -2031,14 +2124,6 @@ def begin_detach_follower_databases( :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: @@ -2049,7 +2134,7 @@ def begin_detach_follower_databases( self, resource_group_name: str, cluster_name: str, - follower_database_to_remove: IO, + follower_database_to_remove: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -2062,18 +2147,10 @@ def begin_detach_follower_databases( :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 + :type follower_database_to_remove: IO[bytes] :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: @@ -2084,7 +2161,7 @@ def begin_detach_follower_databases( self, resource_group_name: str, cluster_name: str, - follower_database_to_remove: Union[_models.FollowerDatabaseDefinition, IO], + follower_database_to_remove: Union[_models.FollowerDatabaseDefinition, IO[bytes]], **kwargs: Any ) -> LROPoller[None]: """Detaches all followers of a database owned by this cluster. @@ -2095,19 +2172,9 @@ def begin_detach_follower_databases( :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. Is either a - FollowerDatabaseDefinition 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 - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + FollowerDatabaseDefinition type or a IO[bytes] type. Required. + :type follower_database_to_remove: ~azure.mgmt.kusto.models.FollowerDatabaseDefinition or + IO[bytes] :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: @@ -2122,7 +2189,7 @@ def begin_detach_follower_databases( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._detach_follower_databases_initial( # type: ignore + raw_result = self._detach_follower_databases_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, follower_database_to_remove=follower_database_to_remove, @@ -2133,11 +2200,12 @@ def begin_detach_follower_databases( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -2146,22 +2214,18 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_detach_follower_databases.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/detachFollowerDatabases" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _diagnose_virtual_network_initial( self, resource_group_name: str, cluster_name: str, **kwargs: Any - ) -> Optional[_models.DiagnoseVirtualNetworkResult]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2173,51 +2237,48 @@ def _diagnose_virtual_network_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Optional[_models.DiagnoseVirtualNetworkResult]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_diagnose_virtual_network_request( + _request = build_diagnose_virtual_network_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("DiagnoseVirtualNetworkResult", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Azure-AsyncOperation"] = self._deserialize( "str", response.headers.get("Azure-AsyncOperation") ) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _diagnose_virtual_network_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/diagnoseVirtualNetwork" - } + return deserialized # type: ignore @distributed_trace def begin_diagnose_virtual_network( @@ -2231,14 +2292,6 @@ def begin_diagnose_virtual_network( :type resource_group_name: str :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. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~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 DiagnoseVirtualNetworkResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.DiagnoseVirtualNetworkResult] @@ -2262,12 +2315,13 @@ def begin_diagnose_virtual_network( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DiagnoseVirtualNetworkResult", pipeline_response) + deserialized = self._deserialize("DiagnoseVirtualNetworkResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -2277,17 +2331,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.DiagnoseVirtualNetworkResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_diagnose_virtual_network.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/diagnoseVirtualNetwork" - } + return LROPoller[_models.DiagnoseVirtualNetworkResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Cluster"]: @@ -2296,7 +2348,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Cluster or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kusto.models.Cluster] :raises ~azure.core.exceptions.HttpResponseError: @@ -2307,7 +2358,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ClusterListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2318,16 +2369,14 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -2339,13 +2388,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ClusterListResult", pipeline_response) @@ -2355,11 +2403,11 @@ def extract_data(pipeline_response): return None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2372,15 +2420,10 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters" - } - @distributed_trace 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 Cluster or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kusto.models.Cluster] :raises ~azure.core.exceptions.HttpResponseError: @@ -2391,7 +2434,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Cluster"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ClusterListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2402,15 +2445,13 @@ def list(self, **kwargs: Any) -> Iterable["_models.Cluster"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -2422,13 +2463,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ClusterListResult", pipeline_response) @@ -2438,11 +2478,11 @@ def extract_data(pipeline_response): return None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2455,13 +2495,10 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/clusters"} - @distributed_trace 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 SkuDescription or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kusto.models.SkuDescription] :raises ~azure.core.exceptions.HttpResponseError: @@ -2472,7 +2509,7 @@ def list_skus(self, **kwargs: Any) -> Iterable["_models.SkuDescription"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SkuDescriptionList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2483,15 +2520,13 @@ def list_skus(self, **kwargs: Any) -> Iterable["_models.SkuDescription"]: def prepare_request(next_link=None): if not next_link: - request = build_list_skus_request( + _request = build_list_skus_request( subscription_id=self._config.subscription_id, 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) else: # make call to next link with the client's api-version @@ -2503,13 +2538,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("SkuDescriptionList", pipeline_response) @@ -2519,11 +2553,11 @@ def extract_data(pipeline_response): return None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2536,8 +2570,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_skus.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/skus"} - @overload def check_name_availability( self, @@ -2556,7 +2588,6 @@ def check_name_availability( :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: @@ -2564,18 +2595,17 @@ def check_name_availability( @overload def check_name_availability( - self, location: str, cluster_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, location: str, cluster_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameResult: """Checks that the cluster name is valid and is not already in use. :param location: The name of Azure region. Required. :type location: str :param cluster_name: The name of the cluster. Required. - :type cluster_name: IO + :type cluster_name: IO[bytes] :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: @@ -2583,24 +2613,20 @@ def check_name_availability( @distributed_trace def check_name_availability( - self, location: str, cluster_name: Union[_models.ClusterCheckNameRequest, IO], **kwargs: Any + self, location: str, cluster_name: Union[_models.ClusterCheckNameRequest, IO[bytes]], **kwargs: Any ) -> _models.CheckNameResult: """Checks that the cluster name is valid and is not already in use. :param location: The name of Azure region. Required. :type location: str - :param cluster_name: The name of the cluster. Is either a ClusterCheckNameRequest 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 + :param cluster_name: The name of the cluster. Is either a ClusterCheckNameRequest type or a + IO[bytes] type. Required. + :type cluster_name: ~azure.mgmt.kusto.models.ClusterCheckNameRequest or IO[bytes] :return: CheckNameResult or the result of cls(response) :rtype: ~azure.mgmt.kusto.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2623,23 +2649,21 @@ def check_name_availability( else: _json = self._serialize.body(cluster_name, "ClusterCheckNameRequest") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2649,16 +2673,12 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameResult", pipeline_response) + deserialized = self._deserialize("CheckNameResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/locations/{location}/checkNameAvailability" - } + return deserialized # type: ignore @distributed_trace def list_skus_by_resource( @@ -2671,7 +2691,6 @@ def list_skus_by_resource( :type resource_group_name: str :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 AzureResourceSku or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kusto.models.AzureResourceSku] :raises ~azure.core.exceptions.HttpResponseError: @@ -2682,7 +2701,7 @@ def list_skus_by_resource( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ListResourceSkusResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2693,17 +2712,15 @@ def list_skus_by_resource( def prepare_request(next_link=None): if not next_link: - request = build_list_skus_by_resource_request( + _request = build_list_skus_by_resource_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_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) else: # make call to next link with the client's api-version @@ -2715,13 +2732,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListResourceSkusResult", pipeline_response) @@ -2731,11 +2747,11 @@ def extract_data(pipeline_response): return None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2748,12 +2764,8 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_skus_by_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/skus" - } - @distributed_trace - def list_outbound_network_dependencies_endpoints( + def list_outbound_network_dependencies_endpoints( # pylint: disable=name-too-long 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. @@ -2763,7 +2775,6 @@ def list_outbound_network_dependencies_endpoints( :type resource_group_name: str :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 OutboundNetworkDependenciesEndpoint or the result of cls(response) :rtype: @@ -2776,7 +2787,7 @@ def list_outbound_network_dependencies_endpoints( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OutboundNetworkDependenciesEndpointListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2787,17 +2798,15 @@ def list_outbound_network_dependencies_endpoints( def prepare_request(next_link=None): if not next_link: - request = build_list_outbound_network_dependencies_endpoints_request( + _request = build_list_outbound_network_dependencies_endpoints_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_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) else: # make call to next link with the client's api-version @@ -2809,13 +2818,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OutboundNetworkDependenciesEndpointListResult", pipeline_response) @@ -2825,11 +2833,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2842,9 +2850,475 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_outbound_network_dependencies_endpoints.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/outboundNetworkDependenciesEndpoints" - } + def _add_callout_policies_initial( + self, + resource_group_name: str, + cluster_name: str, + callout_policies: Union[_models.CalloutPoliciesList, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(callout_policies, (IOBase, bytes)): + _content = callout_policies + else: + _json = self._serialize.body(callout_policies, "CalloutPoliciesList") + + _request = build_add_callout_policies_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_add_callout_policies( + self, + resource_group_name: str, + cluster_name: str, + callout_policies: _models.CalloutPoliciesList, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Adds a list of callout policies for engine services. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param callout_policies: The callout policies to add. Required. + :type callout_policies: ~azure.mgmt.kusto.models.CalloutPoliciesList + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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_callout_policies( + self, + resource_group_name: str, + cluster_name: str, + callout_policies: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Adds a list of callout policies for engine services. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param callout_policies: The callout policies to add. Required. + :type callout_policies: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :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_callout_policies( + self, + resource_group_name: str, + cluster_name: str, + callout_policies: Union[_models.CalloutPoliciesList, IO[bytes]], + **kwargs: Any + ) -> LROPoller[None]: + """Adds a list of callout policies for engine services. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param callout_policies: The callout policies to add. Is either a CalloutPoliciesList type or a + IO[bytes] type. Required. + :type callout_policies: ~azure.mgmt.kusto.models.CalloutPoliciesList or IO[bytes] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._add_callout_policies_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + callout_policies=callout_policies, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _remove_callout_policy_initial( + self, + resource_group_name: str, + cluster_name: str, + callout_policy: Union[_models.CalloutPolicyToRemove, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(callout_policy, (IOBase, bytes)): + _content = callout_policy + else: + _json = self._serialize.body(callout_policy, "CalloutPolicyToRemove") + + _request = build_remove_callout_policy_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_remove_callout_policy( + self, + resource_group_name: str, + cluster_name: str, + callout_policy: _models.CalloutPolicyToRemove, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Removes callout policy for engine services. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param callout_policy: The callout policies to remove. Required. + :type callout_policy: ~azure.mgmt.kusto.models.CalloutPolicyToRemove + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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_callout_policy( + self, + resource_group_name: str, + cluster_name: str, + callout_policy: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Removes callout policy for engine services. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param callout_policy: The callout policies to remove. Required. + :type callout_policy: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :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_callout_policy( + self, + resource_group_name: str, + cluster_name: str, + callout_policy: Union[_models.CalloutPolicyToRemove, IO[bytes]], + **kwargs: Any + ) -> LROPoller[None]: + """Removes callout policy for engine services. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :param callout_policy: The callout policies to remove. Is either a CalloutPolicyToRemove type + or a IO[bytes] type. Required. + :type callout_policy: ~azure.mgmt.kusto.models.CalloutPolicyToRemove or IO[bytes] + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._remove_callout_policy_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + callout_policy=callout_policy, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_callout_policies( + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.CalloutPolicy"]: + """Returns the allowed callout policies for the specified service. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the Kusto cluster. Required. + :type cluster_name: str + :return: An iterator like instance of either CalloutPolicy or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kusto.models.CalloutPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.CalloutPoliciesList] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_callout_policies_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("CalloutPoliciesList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) @distributed_trace def list_language_extensions( @@ -2857,7 +3331,6 @@ def list_language_extensions( :type resource_group_name: str :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 LanguageExtension or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kusto.models.LanguageExtension] :raises ~azure.core.exceptions.HttpResponseError: @@ -2868,7 +3341,7 @@ def list_language_extensions( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.LanguageExtensionsList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2879,17 +3352,15 @@ def list_language_extensions( def prepare_request(next_link=None): if not next_link: - request = build_list_language_extensions_request( + _request = build_list_language_extensions_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_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) else: # make call to next link with the client's api-version @@ -2901,13 +3372,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("LanguageExtensionsList", pipeline_response) @@ -2917,11 +3387,11 @@ def extract_data(pipeline_response): return None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2934,18 +3404,14 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_language_extensions.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/listLanguageExtensions" - } - - def _add_language_extensions_initial( # pylint: disable=inconsistent-return-statements + def _add_language_extensions_initial( self, resource_group_name: str, cluster_name: str, - language_extensions_to_add: Union[_models.LanguageExtensionsList, IO], + language_extensions_to_add: Union[_models.LanguageExtensionsList, IO[bytes]], **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2958,7 +3424,7 @@ def _add_language_extensions_initial( # pylint: disable=inconsistent-return-sta api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -2968,7 +3434,7 @@ def _add_language_extensions_initial( # pylint: disable=inconsistent-return-sta else: _json = self._serialize.body(language_extensions_to_add, "LanguageExtensionsList") - request = build_add_language_extensions_request( + _request = build_add_language_extensions_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, @@ -2976,21 +3442,24 @@ def _add_language_extensions_initial( # pylint: disable=inconsistent-return-sta content_type=content_type, json=_json, 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -3002,12 +3471,12 @@ def _add_language_extensions_initial( # pylint: disable=inconsistent-return-sta "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _add_language_extensions_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/addLanguageExtensions" - } + return deserialized # type: ignore @overload def begin_add_language_extensions( @@ -3031,14 +3500,6 @@ def begin_add_language_extensions( :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: @@ -3049,7 +3510,7 @@ def begin_add_language_extensions( self, resource_group_name: str, cluster_name: str, - language_extensions_to_add: IO, + language_extensions_to_add: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -3062,18 +3523,10 @@ def begin_add_language_extensions( :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 + :type language_extensions_to_add: IO[bytes] :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: @@ -3084,7 +3537,7 @@ def begin_add_language_extensions( self, resource_group_name: str, cluster_name: str, - language_extensions_to_add: Union[_models.LanguageExtensionsList, IO], + language_extensions_to_add: Union[_models.LanguageExtensionsList, IO[bytes]], **kwargs: Any ) -> LROPoller[None]: """Add a list of language extensions that can run within KQL queries. @@ -3095,19 +3548,8 @@ def begin_add_language_extensions( :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str :param language_extensions_to_add: The language extensions to add. Is either a - LanguageExtensionsList 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 - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + LanguageExtensionsList type or a IO[bytes] type. Required. + :type language_extensions_to_add: ~azure.mgmt.kusto.models.LanguageExtensionsList or IO[bytes] :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: @@ -3122,7 +3564,7 @@ def begin_add_language_extensions( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._add_language_extensions_initial( # type: ignore + raw_result = self._add_language_extensions_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, language_extensions_to_add=language_extensions_to_add, @@ -3133,11 +3575,12 @@ def begin_add_language_extensions( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -3146,26 +3589,22 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_add_language_extensions.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/addLanguageExtensions" - } - - def _remove_language_extensions_initial( # pylint: disable=inconsistent-return-statements + def _remove_language_extensions_initial( self, resource_group_name: str, cluster_name: str, - language_extensions_to_remove: Union[_models.LanguageExtensionsList, IO], + language_extensions_to_remove: Union[_models.LanguageExtensionsList, IO[bytes]], **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -3178,7 +3617,7 @@ def _remove_language_extensions_initial( # pylint: disable=inconsistent-return- api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -3188,7 +3627,7 @@ def _remove_language_extensions_initial( # pylint: disable=inconsistent-return- else: _json = self._serialize.body(language_extensions_to_remove, "LanguageExtensionsList") - request = build_remove_language_extensions_request( + _request = build_remove_language_extensions_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, @@ -3196,21 +3635,24 @@ def _remove_language_extensions_initial( # pylint: disable=inconsistent-return- content_type=content_type, json=_json, 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -3222,12 +3664,12 @@ def _remove_language_extensions_initial( # pylint: disable=inconsistent-return- "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _remove_language_extensions_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/removeLanguageExtensions" - } + return deserialized # type: ignore @overload def begin_remove_language_extensions( @@ -3251,14 +3693,6 @@ def begin_remove_language_extensions( :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: @@ -3269,7 +3703,7 @@ def begin_remove_language_extensions( self, resource_group_name: str, cluster_name: str, - language_extensions_to_remove: IO, + language_extensions_to_remove: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -3282,18 +3716,10 @@ def begin_remove_language_extensions( :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 + :type language_extensions_to_remove: IO[bytes] :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: @@ -3304,7 +3730,7 @@ def begin_remove_language_extensions( self, resource_group_name: str, cluster_name: str, - language_extensions_to_remove: Union[_models.LanguageExtensionsList, IO], + language_extensions_to_remove: Union[_models.LanguageExtensionsList, IO[bytes]], **kwargs: Any ) -> LROPoller[None]: """Remove a list of language extensions that can run within KQL queries. @@ -3315,19 +3741,9 @@ def begin_remove_language_extensions( :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str :param language_extensions_to_remove: The language extensions to remove. Is either a - LanguageExtensionsList 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 - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + LanguageExtensionsList type or a IO[bytes] type. Required. + :type language_extensions_to_remove: ~azure.mgmt.kusto.models.LanguageExtensionsList or + IO[bytes] :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: @@ -3342,7 +3758,7 @@ def begin_remove_language_extensions( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._remove_language_extensions_initial( # type: ignore + raw_result = self._remove_language_extensions_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, language_extensions_to_remove=language_extensions_to_remove, @@ -3353,11 +3769,12 @@ def begin_remove_language_extensions( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -3366,14 +3783,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_remove_language_extensions.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/removeLanguageExtensions" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # 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 73f2eed1f6ef..886673a3b24d 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,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +50,7 @@ def build_list_by_database_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -79,7 +84,7 @@ def build_data_connection_validation_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -116,7 +121,7 @@ def build_check_name_availability_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -158,7 +163,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -198,7 +203,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -241,7 +246,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -284,7 +289,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -345,7 +350,6 @@ def list_by_database( :type cluster_name: str :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 DataConnection or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kusto.models.DataConnection] :raises ~azure.core.exceptions.HttpResponseError: @@ -356,7 +360,7 @@ def list_by_database( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DataConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -367,18 +371,16 @@ def list_by_database( def prepare_request(next_link=None): if not next_link: - request = build_list_by_database_request( + _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, 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) else: # make call to next link with the client's api-version @@ -390,13 +392,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DataConnectionListResult", pipeline_response) @@ -406,11 +407,11 @@ def extract_data(pipeline_response): return None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -423,19 +424,15 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections" - } - def _data_connection_validation_initial( self, resource_group_name: str, cluster_name: str, database_name: str, - parameters: Union[_models.DataConnectionValidation, IO], + parameters: Union[_models.DataConnectionValidation, IO[bytes]], **kwargs: Any - ) -> Optional[_models.DataConnectionValidationListResult]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -448,7 +445,7 @@ def _data_connection_validation_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.DataConnectionValidationListResult]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -458,7 +455,7 @@ def _data_connection_validation_initial( else: _json = self._serialize.body(parameters, "DataConnectionValidation") - request = build_data_connection_validation_request( + _request = build_data_connection_validation_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -467,44 +464,41 @@ def _data_connection_validation_initial( content_type=content_type, json=_json, 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("DataConnectionValidationListResult", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Azure-AsyncOperation"] = self._deserialize( "str", response.headers.get("Azure-AsyncOperation") ) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _data_connection_validation_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnectionValidation" - } + return deserialized # type: ignore @overload def begin_data_connection_validation( @@ -532,14 +526,6 @@ def begin_data_connection_validation( :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: @@ -553,7 +539,7 @@ def begin_data_connection_validation( resource_group_name: str, cluster_name: str, database_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -569,18 +555,10 @@ def begin_data_connection_validation( :type database_name: str :param parameters: The data connection parameters supplied to the CreateOrUpdate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 DataConnectionValidationListResult or the result of cls(response) :rtype: @@ -594,7 +572,7 @@ def begin_data_connection_validation( resource_group_name: str, cluster_name: str, database_name: str, - parameters: Union[_models.DataConnectionValidation, IO], + parameters: Union[_models.DataConnectionValidation, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.DataConnectionValidationListResult]: """Checks that the data connection parameters are valid. @@ -607,19 +585,8 @@ def begin_data_connection_validation( :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 DataConnectionValidation 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. + either a DataConnectionValidation type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.kusto.models.DataConnectionValidation or IO[bytes] :return: An instance of LROPoller that returns either DataConnectionValidationListResult or the result of cls(response) :rtype: @@ -648,12 +615,13 @@ def begin_data_connection_validation( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DataConnectionValidationListResult", pipeline_response) + deserialized = self._deserialize("DataConnectionValidationListResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -663,17 +631,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.DataConnectionValidationListResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_data_connection_validation.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnectionValidation" - } + return LROPoller[_models.DataConnectionValidationListResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @overload def check_name_availability( @@ -700,7 +666,6 @@ def check_name_availability( :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: @@ -712,7 +677,7 @@ def check_name_availability( resource_group_name: str, cluster_name: str, database_name: str, - data_connection_name: IO, + data_connection_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -727,11 +692,10 @@ def check_name_availability( :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 + :type data_connection_name: IO[bytes] :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: @@ -743,7 +707,7 @@ def check_name_availability( resource_group_name: str, cluster_name: str, database_name: str, - data_connection_name: Union[_models.DataConnectionCheckNameRequest, IO], + data_connection_name: Union[_models.DataConnectionCheckNameRequest, IO[bytes]], **kwargs: Any ) -> _models.CheckNameResult: """Checks that the data connection name is valid and is not already in use. @@ -756,17 +720,14 @@ def check_name_availability( :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. Is either a - DataConnectionCheckNameRequest 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 + DataConnectionCheckNameRequest type or a IO[bytes] type. Required. + :type data_connection_name: ~azure.mgmt.kusto.models.DataConnectionCheckNameRequest or + IO[bytes] :return: CheckNameResult or the result of cls(response) :rtype: ~azure.mgmt.kusto.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -789,7 +750,7 @@ def check_name_availability( else: _json = self._serialize.body(data_connection_name, "DataConnectionCheckNameRequest") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -798,16 +759,14 @@ def check_name_availability( content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -817,16 +776,12 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameResult", pipeline_response) + deserialized = self._deserialize("CheckNameResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/checkNameAvailability" - } + return deserialized # type: ignore @distributed_trace def get( @@ -843,12 +798,11 @@ def get( :type database_name: str :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: ~azure.mgmt.kusto.models.DataConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -862,23 +816,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DataConnection] = kwargs.pop("cls", None) - request = build_get_request( + _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, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -888,16 +840,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DataConnection", pipeline_response) + deserialized = self._deserialize("DataConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, @@ -905,10 +853,10 @@ def _create_or_update_initial( cluster_name: str, database_name: str, data_connection_name: str, - parameters: Union[_models.DataConnection, IO], + parameters: Union[_models.DataConnection, IO[bytes]], **kwargs: Any - ) -> _models.DataConnection: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -921,7 +869,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataConnection] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -931,7 +879,7 @@ def _create_or_update_initial( else: _json = self._serialize.body(parameters, "DataConnection") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -941,48 +889,41 @@ def _create_or_update_initial( 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("DataConnection", pipeline_response) - - if response.status_code == 201: - 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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}" - } - @overload def begin_create_or_update( self, @@ -1012,14 +953,6 @@ def begin_create_or_update( :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] @@ -1033,7 +966,7 @@ def begin_create_or_update( cluster_name: str, database_name: str, data_connection_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1051,18 +984,10 @@ def begin_create_or_update( :type data_connection_name: str :param parameters: The data connection parameters supplied to the CreateOrUpdate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :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] @@ -1076,7 +1001,7 @@ def begin_create_or_update( cluster_name: str, database_name: str, data_connection_name: str, - parameters: Union[_models.DataConnection, IO], + parameters: Union[_models.DataConnection, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.DataConnection]: """Creates or updates a data connection. @@ -1091,19 +1016,8 @@ def begin_create_or_update( :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 DataConnection 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. + either a DataConnection type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.kusto.models.DataConnection or IO[bytes] :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] @@ -1132,12 +1046,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DataConnection", pipeline_response) + deserialized = self._deserialize("DataConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1147,17 +1062,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.DataConnection].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}" - } + return LROPoller[_models.DataConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, @@ -1165,10 +1078,10 @@ def _update_initial( cluster_name: str, database_name: str, data_connection_name: str, - parameters: Union[_models.DataConnection, IO], + parameters: Union[_models.DataConnection, IO[bytes]], **kwargs: Any - ) -> _models.DataConnection: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1181,7 +1094,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DataConnection] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1191,7 +1104,7 @@ def _update_initial( else: _json = self._serialize.body(parameters, "DataConnection") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -1201,54 +1114,48 @@ def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("DataConnection", pipeline_response) - if response.status_code == 201: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) 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["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Azure-AsyncOperation"] = self._deserialize( "str", response.headers.get("Azure-AsyncOperation") ) - deserialized = self._deserialize("DataConnection", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}" - } - @overload def begin_update( self, @@ -1277,14 +1184,6 @@ def begin_update( :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] @@ -1298,7 +1197,7 @@ def begin_update( cluster_name: str, database_name: str, data_connection_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1315,18 +1214,10 @@ def begin_update( :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 + :type parameters: IO[bytes] :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] @@ -1340,7 +1231,7 @@ def begin_update( cluster_name: str, database_name: str, data_connection_name: str, - parameters: Union[_models.DataConnection, IO], + parameters: Union[_models.DataConnection, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.DataConnection]: """Updates a data connection. @@ -1355,19 +1246,8 @@ def begin_update( :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. Is either a - DataConnection 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. + DataConnection type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.kusto.models.DataConnection or IO[bytes] :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] @@ -1396,12 +1276,13 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DataConnection", pipeline_response) + deserialized = self._deserialize("DataConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1411,22 +1292,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.DataConnection].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}" - } + return LROPoller[_models.DataConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, cluster_name: str, database_name: str, data_connection_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1438,30 +1317,33 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _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, 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1473,12 +1355,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -1495,14 +1377,6 @@ def begin_delete( :type database_name: str :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. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~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: @@ -1516,7 +1390,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -1527,11 +1401,12 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -1540,14 +1415,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/dataConnections/{dataConnectionName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_database_operations.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_database_operations.py index bac876d0cf2a..88ef36743e84 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_database_operations.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_database_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +import sys +from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +19,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -41,7 +44,7 @@ def build_invite_follower_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -116,7 +119,6 @@ def invite_follower( :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: DatabaseInviteFollowerResult or the result of cls(response) :rtype: ~azure.mgmt.kusto.models.DatabaseInviteFollowerResult :raises ~azure.core.exceptions.HttpResponseError: @@ -128,7 +130,7 @@ def invite_follower( resource_group_name: str, cluster_name: str, database_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -143,11 +145,10 @@ def invite_follower( :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str :param parameters: The follower invitation request parameters. Required. - :type parameters: IO + :type parameters: IO[bytes] :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: DatabaseInviteFollowerResult or the result of cls(response) :rtype: ~azure.mgmt.kusto.models.DatabaseInviteFollowerResult :raises ~azure.core.exceptions.HttpResponseError: @@ -159,7 +160,7 @@ def invite_follower( resource_group_name: str, cluster_name: str, database_name: str, - parameters: Union[_models.DatabaseInviteFollowerRequest, IO], + parameters: Union[_models.DatabaseInviteFollowerRequest, IO[bytes]], **kwargs: Any ) -> _models.DatabaseInviteFollowerResult: """Generates an invitation token that allows attaching a follower database to this database. @@ -172,17 +173,13 @@ def invite_follower( :param database_name: The name of the database in the Kusto cluster. Required. :type database_name: str :param parameters: The follower invitation request parameters. Is either a - DatabaseInviteFollowerRequest type or a IO type. Required. - :type parameters: ~azure.mgmt.kusto.models.DatabaseInviteFollowerRequest 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 + DatabaseInviteFollowerRequest type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.kusto.models.DatabaseInviteFollowerRequest or IO[bytes] :return: DatabaseInviteFollowerResult or the result of cls(response) :rtype: ~azure.mgmt.kusto.models.DatabaseInviteFollowerResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -205,7 +202,7 @@ def invite_follower( else: _json = self._serialize.body(parameters, "DatabaseInviteFollowerRequest") - request = build_invite_follower_request( + _request = build_invite_follower_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -214,16 +211,14 @@ def invite_follower( content_type=content_type, json=_json, content=_content, - template_url=self.invite_follower.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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -233,13 +228,9 @@ def invite_follower( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DatabaseInviteFollowerResult", pipeline_response) + deserialized = self._deserialize("DatabaseInviteFollowerResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - invite_follower.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/inviteFollower" - } + return deserialized # 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 142a7dea0b98..45a18c425ca4 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,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +50,7 @@ def build_check_name_availability_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -87,7 +92,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -129,7 +134,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -174,7 +179,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -211,7 +216,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -284,7 +289,6 @@ def check_name_availability( :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: @@ -296,7 +300,7 @@ def check_name_availability( resource_group_name: str, cluster_name: str, database_name: str, - principal_assignment_name: IO, + principal_assignment_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -311,11 +315,10 @@ def check_name_availability( :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 + :type principal_assignment_name: IO[bytes] :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: @@ -327,7 +330,7 @@ def check_name_availability( resource_group_name: str, cluster_name: str, database_name: str, - principal_assignment_name: Union[_models.DatabasePrincipalAssignmentCheckNameRequest, IO], + principal_assignment_name: Union[_models.DatabasePrincipalAssignmentCheckNameRequest, IO[bytes]], **kwargs: Any ) -> _models.CheckNameResult: """Checks that the database principal assignment is valid and is not already in use. @@ -340,18 +343,14 @@ def check_name_availability( :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. Is either a - DatabasePrincipalAssignmentCheckNameRequest type or a IO type. Required. + DatabasePrincipalAssignmentCheckNameRequest type or a IO[bytes] type. Required. :type principal_assignment_name: - ~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 + ~azure.mgmt.kusto.models.DatabasePrincipalAssignmentCheckNameRequest or IO[bytes] :return: CheckNameResult or the result of cls(response) :rtype: ~azure.mgmt.kusto.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -374,7 +373,7 @@ def check_name_availability( else: _json = self._serialize.body(principal_assignment_name, "DatabasePrincipalAssignmentCheckNameRequest") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -383,16 +382,14 @@ def check_name_availability( content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -402,16 +399,12 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameResult", pipeline_response) + deserialized = self._deserialize("CheckNameResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/checkPrincipalAssignmentNameAvailability" - } + return deserialized # type: ignore @distributed_trace def get( @@ -433,12 +426,11 @@ def get( :type database_name: str :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: ~azure.mgmt.kusto.models.DatabasePrincipalAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -452,23 +444,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabasePrincipalAssignment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_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, - 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -478,16 +468,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DatabasePrincipalAssignment", pipeline_response) + deserialized = self._deserialize("DatabasePrincipalAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, @@ -495,10 +481,10 @@ def _create_or_update_initial( cluster_name: str, database_name: str, principal_assignment_name: str, - parameters: Union[_models.DatabasePrincipalAssignment, IO], + parameters: Union[_models.DatabasePrincipalAssignment, IO[bytes]], **kwargs: Any - ) -> _models.DatabasePrincipalAssignment: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -511,7 +497,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DatabasePrincipalAssignment] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -521,7 +507,7 @@ def _create_or_update_initial( else: _json = self._serialize.body(parameters, "DatabasePrincipalAssignment") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -531,40 +517,35 @@ def _create_or_update_initial( 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("DatabasePrincipalAssignment", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DatabasePrincipalAssignment", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}" - } - @overload def begin_create_or_update( self, @@ -594,14 +575,6 @@ def begin_create_or_update( :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] @@ -615,7 +588,7 @@ def begin_create_or_update( cluster_name: str, database_name: str, principal_assignment_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -633,18 +606,10 @@ def begin_create_or_update( :type principal_assignment_name: str :param parameters: The Kusto principalAssignments parameters supplied for the operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 DatabasePrincipalAssignment or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.DatabasePrincipalAssignment] @@ -658,7 +623,7 @@ def begin_create_or_update( cluster_name: str, database_name: str, principal_assignment_name: str, - parameters: Union[_models.DatabasePrincipalAssignment, IO], + parameters: Union[_models.DatabasePrincipalAssignment, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.DatabasePrincipalAssignment]: """Creates a Kusto cluster database principalAssignment. @@ -673,19 +638,8 @@ def begin_create_or_update( :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 DatabasePrincipalAssignment 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. + either a DatabasePrincipalAssignment type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.kusto.models.DatabasePrincipalAssignment or IO[bytes] :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] @@ -714,12 +668,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DatabasePrincipalAssignment", pipeline_response) + deserialized = self._deserialize("DatabasePrincipalAssignment", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -729,27 +684,25 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.DatabasePrincipalAssignment].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}" - } + return LROPoller[_models.DatabasePrincipalAssignment]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, cluster_name: str, database_name: str, principal_assignment_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -761,30 +714,33 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_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, - 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -796,12 +752,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -823,14 +779,6 @@ def begin_delete( :type database_name: str :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. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~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: @@ -844,7 +792,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -855,11 +803,12 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -868,17 +817,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def list( @@ -893,7 +838,6 @@ def list( :type cluster_name: str :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 DatabasePrincipalAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kusto.models.DatabasePrincipalAssignment] @@ -905,7 +849,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabasePrincipalAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -916,18 +860,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_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, - 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) else: # make call to next link with the client's api-version @@ -939,13 +881,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DatabasePrincipalAssignmentListResult", pipeline_response) @@ -955,11 +896,11 @@ def extract_data(pipeline_response): return None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -971,7 +912,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/principalAssignments" - } 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 a167b3699fa9..06991e734dc8 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,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +50,7 @@ def build_check_name_availability_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -87,7 +92,7 @@ def build_list_by_cluster_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -124,7 +129,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -164,7 +169,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -209,7 +214,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -248,7 +253,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -282,7 +287,7 @@ def build_list_principals_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -316,7 +321,7 @@ def build_add_principals_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -353,7 +358,7 @@ def build_remove_principals_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -425,7 +430,6 @@ def check_name_availability( :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: @@ -436,7 +440,7 @@ def check_name_availability( self, resource_group_name: str, cluster_name: str, - resource_name: IO, + resource_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -449,11 +453,10 @@ def check_name_availability( :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 + :type resource_name: IO[bytes] :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: @@ -464,7 +467,7 @@ def check_name_availability( self, resource_group_name: str, cluster_name: str, - resource_name: Union[_models.CheckNameRequest, IO], + resource_name: Union[_models.CheckNameRequest, IO[bytes]], **kwargs: Any ) -> _models.CheckNameResult: """Checks that the databases resource name is valid and is not already in use. @@ -474,18 +477,14 @@ def check_name_availability( :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. Is either a CheckNameRequest 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 + :param resource_name: The name of the resource. Is either a CheckNameRequest type or a + IO[bytes] type. Required. + :type resource_name: ~azure.mgmt.kusto.models.CheckNameRequest or IO[bytes] :return: CheckNameResult or the result of cls(response) :rtype: ~azure.mgmt.kusto.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -508,7 +507,7 @@ def check_name_availability( else: _json = self._serialize.body(resource_name, "CheckNameRequest") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, @@ -516,16 +515,14 @@ def check_name_availability( content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -535,16 +532,12 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameResult", pipeline_response) + deserialized = self._deserialize("CheckNameResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/checkNameAvailability" - } + return deserialized # type: ignore @distributed_trace def list_by_cluster( @@ -569,7 +562,6 @@ def list_by_cluster( a skiptoken parameter that specifies a starting point to use for subsequent calls. Default value is None. :type skiptoken: str - :keyword callable cls: A custom type or function that will be passed the direct response :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: @@ -580,7 +572,7 @@ def list_by_cluster( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabaseListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -591,19 +583,17 @@ def list_by_cluster( def prepare_request(next_link=None): if not next_link: - request = build_list_by_cluster_request( + _request = build_list_by_cluster_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, top=top, skiptoken=skiptoken, 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) else: # make call to next link with the client's api-version @@ -615,13 +605,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DatabaseListResult", pipeline_response) @@ -631,11 +620,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -648,10 +637,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_cluster.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases" - } - @distributed_trace def get(self, resource_group_name: str, cluster_name: str, database_name: str, **kwargs: Any) -> _models.Database: """Returns a database. @@ -663,12 +648,11 @@ def get(self, resource_group_name: str, cluster_name: str, database_name: str, * :type cluster_name: str :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: ~azure.mgmt.kusto.models.Database :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -682,22 +666,20 @@ def get(self, resource_group_name: str, cluster_name: str, database_name: str, * api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Database] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_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, - 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -707,27 +689,23 @@ def get(self, resource_group_name: str, cluster_name: str, database_name: str, * error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Database", pipeline_response) + deserialized = self._deserialize("Database", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, cluster_name: str, database_name: str, - parameters: Union[_models.Database, IO], + parameters: Union[_models.Database, IO[bytes]], caller_role: Union[str, _models.CallerRole] = "Admin", **kwargs: Any - ) -> _models.Database: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -740,7 +718,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Database] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -750,7 +728,7 @@ def _create_or_update_initial( else: _json = self._serialize.body(parameters, "Database") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -760,48 +738,41 @@ def _create_or_update_initial( 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Database", pipeline_response) - - if response.status_code == 201: - 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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}" - } - @overload def begin_create_or_update( self, @@ -832,14 +803,6 @@ def begin_create_or_update( :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: @@ -851,7 +814,7 @@ def begin_create_or_update( resource_group_name: str, cluster_name: str, database_name: str, - parameters: IO, + parameters: IO[bytes], caller_role: Union[str, _models.CallerRole] = "Admin", *, content_type: str = "application/json", @@ -867,7 +830,7 @@ def begin_create_or_update( :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 + :type parameters: IO[bytes] :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". @@ -875,14 +838,6 @@ def begin_create_or_update( :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: @@ -894,7 +849,7 @@ def begin_create_or_update( resource_group_name: str, cluster_name: str, database_name: str, - parameters: Union[_models.Database, IO], + parameters: Union[_models.Database, IO[bytes]], caller_role: Union[str, _models.CallerRole] = "Admin", **kwargs: Any ) -> LROPoller[_models.Database]: @@ -908,23 +863,12 @@ def begin_create_or_update( :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. Is either - a Database type or a IO type. Required. - :type parameters: ~azure.mgmt.kusto.models.Database or IO + a Database type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.kusto.models.Database or IO[bytes] :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 - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~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: @@ -952,12 +896,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Database", pipeline_response) + deserialized = self._deserialize("Database", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -967,28 +912,26 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Database].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}" - } + return LROPoller[_models.Database]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, resource_group_name: str, cluster_name: str, database_name: str, - parameters: Union[_models.Database, IO], + parameters: Union[_models.Database, IO[bytes]], caller_role: Union[str, _models.CallerRole] = "Admin", **kwargs: Any - ) -> _models.Database: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1001,7 +944,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Database] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1011,7 +954,7 @@ def _update_initial( else: _json = self._serialize.body(parameters, "Database") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -1021,54 +964,48 @@ def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Database", pipeline_response) - if response.status_code == 201: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) 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["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Azure-AsyncOperation"] = self._deserialize( "str", response.headers.get("Azure-AsyncOperation") ) - deserialized = self._deserialize("Database", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}" - } - @overload def begin_update( self, @@ -1099,14 +1036,6 @@ def begin_update( :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: @@ -1118,7 +1047,7 @@ def begin_update( resource_group_name: str, cluster_name: str, database_name: str, - parameters: IO, + parameters: IO[bytes], caller_role: Union[str, _models.CallerRole] = "Admin", *, content_type: str = "application/json", @@ -1134,7 +1063,7 @@ def begin_update( :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 + :type parameters: IO[bytes] :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". @@ -1142,14 +1071,6 @@ def begin_update( :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: @@ -1161,7 +1082,7 @@ def begin_update( resource_group_name: str, cluster_name: str, database_name: str, - parameters: Union[_models.Database, IO], + parameters: Union[_models.Database, IO[bytes]], caller_role: Union[str, _models.CallerRole] = "Admin", **kwargs: Any ) -> LROPoller[_models.Database]: @@ -1175,23 +1096,12 @@ def begin_update( :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. Is either a - Database type or a IO type. Required. - :type parameters: ~azure.mgmt.kusto.models.Database or IO + Database type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.kusto.models.Database or IO[bytes] :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 - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~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: @@ -1219,12 +1129,13 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Database", pipeline_response) + deserialized = self._deserialize("Database", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1234,22 +1145,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Database].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}" - } + return LROPoller[_models.Database]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, cluster_name: str, database_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1261,29 +1170,32 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_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, - 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1295,12 +1207,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -1315,14 +1227,6 @@ def begin_delete( :type cluster_name: str :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. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~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: @@ -1336,7 +1240,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -1346,11 +1250,12 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -1359,17 +1264,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def list_principals( @@ -1384,7 +1285,6 @@ def list_principals( :type cluster_name: str :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 DatabasePrincipal or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kusto.models.DatabasePrincipal] :raises ~azure.core.exceptions.HttpResponseError: @@ -1395,7 +1295,7 @@ def list_principals( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DatabasePrincipalListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1406,18 +1306,16 @@ def list_principals( def prepare_request(next_link=None): if not next_link: - request = build_list_principals_request( + _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, 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) else: # make call to next link with the client's api-version @@ -1429,13 +1327,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DatabasePrincipalListResult", pipeline_response) @@ -1445,11 +1342,11 @@ def extract_data(pipeline_response): return None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1462,10 +1359,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_principals.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/listPrincipals" - } - @overload def add_principals( self, @@ -1491,7 +1384,6 @@ def add_principals( :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: @@ -1503,7 +1395,7 @@ def add_principals( resource_group_name: str, cluster_name: str, database_name: str, - database_principals_to_add: IO, + database_principals_to_add: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1518,11 +1410,10 @@ def add_principals( :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 + :type database_principals_to_add: IO[bytes] :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: @@ -1534,7 +1425,7 @@ def add_principals( resource_group_name: str, cluster_name: str, database_name: str, - database_principals_to_add: Union[_models.DatabasePrincipalListRequest, IO], + database_principals_to_add: Union[_models.DatabasePrincipalListRequest, IO[bytes]], **kwargs: Any ) -> _models.DatabasePrincipalListResult: """Add Database principals permissions. @@ -1547,17 +1438,14 @@ def add_principals( :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. Is either a - DatabasePrincipalListRequest 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 + DatabasePrincipalListRequest type or a IO[bytes] type. Required. + :type database_principals_to_add: ~azure.mgmt.kusto.models.DatabasePrincipalListRequest or + IO[bytes] :return: DatabasePrincipalListResult or the result of cls(response) :rtype: ~azure.mgmt.kusto.models.DatabasePrincipalListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1580,7 +1468,7 @@ def add_principals( else: _json = self._serialize.body(database_principals_to_add, "DatabasePrincipalListRequest") - request = build_add_principals_request( + _request = build_add_principals_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -1589,16 +1477,14 @@ def add_principals( content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1608,16 +1494,12 @@ def add_principals( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DatabasePrincipalListResult", pipeline_response) + deserialized = self._deserialize("DatabasePrincipalListResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - add_principals.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/addPrincipals" - } + return deserialized # type: ignore @overload def remove_principals( @@ -1644,7 +1526,6 @@ def remove_principals( :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: @@ -1656,7 +1537,7 @@ def remove_principals( resource_group_name: str, cluster_name: str, database_name: str, - database_principals_to_remove: IO, + database_principals_to_remove: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1671,11 +1552,10 @@ def remove_principals( :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 + :type database_principals_to_remove: IO[bytes] :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: @@ -1687,7 +1567,7 @@ def remove_principals( resource_group_name: str, cluster_name: str, database_name: str, - database_principals_to_remove: Union[_models.DatabasePrincipalListRequest, IO], + database_principals_to_remove: Union[_models.DatabasePrincipalListRequest, IO[bytes]], **kwargs: Any ) -> _models.DatabasePrincipalListResult: """Remove Database principals permissions. @@ -1700,18 +1580,14 @@ def remove_principals( :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. Is either a - DatabasePrincipalListRequest type or a IO type. Required. + DatabasePrincipalListRequest type or a IO[bytes] 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 + IO[bytes] :return: DatabasePrincipalListResult or the result of cls(response) :rtype: ~azure.mgmt.kusto.models.DatabasePrincipalListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1734,7 +1610,7 @@ def remove_principals( else: _json = self._serialize.body(database_principals_to_remove, "DatabasePrincipalListRequest") - request = build_remove_principals_request( + _request = build_remove_principals_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -1743,16 +1619,14 @@ def remove_principals( content_type=content_type, json=_json, 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1762,13 +1636,9 @@ def remove_principals( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DatabasePrincipalListResult", pipeline_response) + deserialized = self._deserialize("DatabasePrincipalListResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - remove_principals.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/removePrincipals" - } + return deserialized # 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 07b5863c4f09..95ab52d51182 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,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +50,7 @@ def build_check_name_availability_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -79,7 +84,7 @@ def build_list_request(resource_group_name: str, cluster_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -112,7 +117,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -148,7 +153,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -187,7 +192,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -226,7 +231,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -297,7 +302,6 @@ def check_name_availability( :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: @@ -308,7 +312,7 @@ def check_name_availability( self, resource_group_name: str, cluster_name: str, - resource_name: IO, + resource_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -321,11 +325,10 @@ def check_name_availability( :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 + :type resource_name: IO[bytes] :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: @@ -336,7 +339,7 @@ def check_name_availability( self, resource_group_name: str, cluster_name: str, - resource_name: Union[_models.ManagedPrivateEndpointsCheckNameRequest, IO], + resource_name: Union[_models.ManagedPrivateEndpointsCheckNameRequest, IO[bytes]], **kwargs: Any ) -> _models.CheckNameResult: """Checks that the managed private endpoints resource name is valid and is not already in use. @@ -347,17 +350,14 @@ def check_name_availability( :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str :param resource_name: The name of the resource. Is either a - ManagedPrivateEndpointsCheckNameRequest 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 + ManagedPrivateEndpointsCheckNameRequest type or a IO[bytes] type. Required. + :type resource_name: ~azure.mgmt.kusto.models.ManagedPrivateEndpointsCheckNameRequest or + IO[bytes] :return: CheckNameResult or the result of cls(response) :rtype: ~azure.mgmt.kusto.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -380,7 +380,7 @@ def check_name_availability( else: _json = self._serialize.body(resource_name, "ManagedPrivateEndpointsCheckNameRequest") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, @@ -388,16 +388,14 @@ def check_name_availability( content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -407,16 +405,12 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameResult", pipeline_response) + deserialized = self._deserialize("CheckNameResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpointsCheckNameAvailability" - } + return deserialized # type: ignore @distributed_trace def list( @@ -429,7 +423,6 @@ def list( :type resource_group_name: str :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 ManagedPrivateEndpoint or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kusto.models.ManagedPrivateEndpoint] @@ -441,7 +434,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedPrivateEndpointListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -452,17 +445,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -474,13 +465,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ManagedPrivateEndpointListResult", pipeline_response) @@ -490,11 +480,11 @@ def extract_data(pipeline_response): return None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -507,10 +497,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints" - } - @distributed_trace def get( self, resource_group_name: str, cluster_name: str, managed_private_endpoint_name: str, **kwargs: Any @@ -524,12 +510,11 @@ def get( :type cluster_name: str :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: ~azure.mgmt.kusto.models.ManagedPrivateEndpoint :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -543,22 +528,20 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ManagedPrivateEndpoint] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_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, - 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -568,26 +551,22 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ManagedPrivateEndpoint", pipeline_response) + deserialized = self._deserialize("ManagedPrivateEndpoint", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, cluster_name: str, managed_private_endpoint_name: str, - parameters: Union[_models.ManagedPrivateEndpoint, IO], + parameters: Union[_models.ManagedPrivateEndpoint, IO[bytes]], **kwargs: Any - ) -> _models.ManagedPrivateEndpoint: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -600,7 +579,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ManagedPrivateEndpoint] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -610,7 +589,7 @@ def _create_or_update_initial( else: _json = self._serialize.body(parameters, "ManagedPrivateEndpoint") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, managed_private_endpoint_name=managed_private_endpoint_name, @@ -619,48 +598,41 @@ def _create_or_update_initial( 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("ManagedPrivateEndpoint", pipeline_response) - - if response.status_code == 201: - 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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}" - } - @overload def begin_create_or_update( self, @@ -686,14 +658,6 @@ def begin_create_or_update( :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] @@ -706,7 +670,7 @@ def begin_create_or_update( resource_group_name: str, cluster_name: str, managed_private_endpoint_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -721,18 +685,10 @@ def begin_create_or_update( :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 + :type parameters: IO[bytes] :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] @@ -745,7 +701,7 @@ def begin_create_or_update( resource_group_name: str, cluster_name: str, managed_private_endpoint_name: str, - parameters: Union[_models.ManagedPrivateEndpoint, IO], + parameters: Union[_models.ManagedPrivateEndpoint, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.ManagedPrivateEndpoint]: """Creates a managed private endpoint. @@ -758,19 +714,8 @@ def begin_create_or_update( :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. Is either a ManagedPrivateEndpoint - 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 - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.kusto.models.ManagedPrivateEndpoint or IO[bytes] :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] @@ -798,12 +743,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedPrivateEndpoint", pipeline_response) + deserialized = self._deserialize("ManagedPrivateEndpoint", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -813,27 +759,25 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.ManagedPrivateEndpoint].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}" - } + return LROPoller[_models.ManagedPrivateEndpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, resource_group_name: str, cluster_name: str, managed_private_endpoint_name: str, - parameters: Union[_models.ManagedPrivateEndpoint, IO], + parameters: Union[_models.ManagedPrivateEndpoint, IO[bytes]], **kwargs: Any - ) -> _models.ManagedPrivateEndpoint: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -846,7 +790,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ManagedPrivateEndpoint] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -856,7 +800,7 @@ def _update_initial( else: _json = self._serialize.body(parameters, "ManagedPrivateEndpoint") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, managed_private_endpoint_name=managed_private_endpoint_name, @@ -865,46 +809,42 @@ def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("ManagedPrivateEndpoint", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Azure-AsyncOperation"] = self._deserialize( "str", response.headers.get("Azure-AsyncOperation") ) - deserialized = self._deserialize("ManagedPrivateEndpoint", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}" - } - @overload def begin_update( self, @@ -930,14 +870,6 @@ def begin_update( :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] @@ -950,7 +882,7 @@ def begin_update( resource_group_name: str, cluster_name: str, managed_private_endpoint_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -965,18 +897,10 @@ def begin_update( :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 + :type parameters: IO[bytes] :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] @@ -989,7 +913,7 @@ def begin_update( resource_group_name: str, cluster_name: str, managed_private_endpoint_name: str, - parameters: Union[_models.ManagedPrivateEndpoint, IO], + parameters: Union[_models.ManagedPrivateEndpoint, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.ManagedPrivateEndpoint]: """Updates a managed private endpoint. @@ -1002,19 +926,8 @@ def begin_update( :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. Is either a ManagedPrivateEndpoint - 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 - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.kusto.models.ManagedPrivateEndpoint or IO[bytes] :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] @@ -1042,12 +955,13 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ManagedPrivateEndpoint", pipeline_response) + deserialized = self._deserialize("ManagedPrivateEndpoint", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1057,22 +971,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.ManagedPrivateEndpoint].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}" - } + return LROPoller[_models.ManagedPrivateEndpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, cluster_name: str, managed_private_endpoint_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1084,29 +996,32 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_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, - 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1118,12 +1033,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -1138,14 +1053,6 @@ def begin_delete( :type cluster_name: str :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. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~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: @@ -1159,7 +1066,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, managed_private_endpoint_name=managed_private_endpoint_name, @@ -1169,11 +1076,12 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -1182,14 +1090,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/managedPrivateEndpoints/{managedPrivateEndpointName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # 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 2dc4811cf67a..b20b7af06c80 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,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) 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.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +43,7 @@ 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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -78,7 +81,6 @@ def __init__(self, *args, **kwargs): 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 Operation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kusto.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -89,7 +91,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -100,14 +102,12 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -119,13 +119,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -135,11 +134,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -151,5 +150,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Kusto/operations"} 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 e4822a5002fc..1bd6ca72951f 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,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -37,7 +40,7 @@ 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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) # Construct URL _url = kwargs.pop( "template_url", @@ -86,12 +89,11 @@ def get( # pylint: disable=inconsistent-return-statements :type location: str :param operation_id: The ID of an ongoing async operation. 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) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -105,21 +107,19 @@ def get( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( location=location, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -135,8 +135,4 @@ def get( # pylint: disable=inconsistent-return-statements ) if cls: - return cls(pipeline_response, None, response_headers) - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/locations/{location}/operationResults/{operationId}" - } + return cls(pipeline_response, None, response_headers) # 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 d18545004c1a..ada5cc3de1b3 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,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,16 +18,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -38,7 +41,7 @@ def build_get_request(location: str, operation_id: str, subscription_id: str, ** _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -90,12 +93,11 @@ def get(self, location: str, operation_id: str, **kwargs: Any) -> _models.Operat :type location: str :param operation_id: The ID of an ongoing async operation. 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: ~azure.mgmt.kusto.models.OperationResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -109,21 +111,19 @@ def get(self, location: str, operation_id: str, **kwargs: Any) -> _models.Operat api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OperationResult] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( location=location, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -133,13 +133,9 @@ def get(self, location: str, operation_id: str, **kwargs: Any) -> _models.Operat error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("OperationResult", pipeline_response) + deserialized = self._deserialize("OperationResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/locations/{location}/operationResults/{operationId}" - } + return deserialized # type: ignore 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 570f0d1e68d5..e867f19b2f4d 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,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +48,7 @@ def build_list_request(resource_group_name: str, cluster_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -80,7 +85,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -120,7 +125,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -163,7 +168,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -223,7 +228,6 @@ def list( :type resource_group_name: str :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 PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kusto.models.PrivateEndpointConnection] @@ -235,7 +239,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -246,17 +250,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -268,13 +270,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) @@ -284,11 +285,11 @@ def extract_data(pipeline_response): return None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -301,10 +302,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateEndpointConnections" - } - @distributed_trace def get( self, resource_group_name: str, cluster_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -318,12 +315,11 @@ def get( :type cluster_name: str :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: ~azure.mgmt.kusto.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -337,22 +333,20 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, cluster_name=cluster_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -362,26 +356,22 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, cluster_name: str, private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO], + parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any - ) -> _models.PrivateEndpointConnection: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -394,7 +384,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -404,7 +394,7 @@ def _create_or_update_initial( else: _json = self._serialize.body(parameters, "PrivateEndpointConnection") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -413,40 +403,35 @@ def _create_or_update_initial( 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - @overload def begin_create_or_update( self, @@ -472,14 +457,6 @@ def begin_create_or_update( :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] @@ -492,7 +469,7 @@ def begin_create_or_update( resource_group_name: str, cluster_name: str, private_endpoint_connection_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -507,18 +484,10 @@ def begin_create_or_update( :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 + :type parameters: IO[bytes] :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] @@ -531,7 +500,7 @@ def begin_create_or_update( resource_group_name: str, cluster_name: str, private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO], + parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.PrivateEndpointConnection]: """Approve or reject a private endpoint connection with a given name. @@ -543,19 +512,8 @@ def begin_create_or_update( :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: Is either a PrivateEndpointConnection 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 - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param parameters: Is either a PrivateEndpointConnection type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.kusto.models.PrivateEndpointConnection or IO[bytes] :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] @@ -583,12 +541,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -598,22 +557,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.PrivateEndpointConnection].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return LROPoller[_models.PrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, cluster_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -625,29 +582,32 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, cluster_name=cluster_name, private_endpoint_connection_name=private_endpoint_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -659,12 +619,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -679,14 +639,6 @@ def begin_delete( :type cluster_name: str :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~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: @@ -700,7 +652,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -710,11 +662,12 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -723,14 +676,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # 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 5f0b5f7db373..051a05566cca 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,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) 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.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +43,7 @@ def build_list_request(resource_group_name: str, cluster_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -73,7 +76,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -133,7 +136,6 @@ def list( :type resource_group_name: str :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 PrivateLinkResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kusto.models.PrivateLinkResource] :raises ~azure.core.exceptions.HttpResponseError: @@ -144,7 +146,7 @@ def list( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -155,17 +157,15 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -177,13 +177,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) @@ -193,11 +192,11 @@ def extract_data(pipeline_response): return None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -210,10 +209,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateLinkResources" - } - @distributed_trace def get( self, resource_group_name: str, cluster_name: str, private_link_resource_name: str, **kwargs: Any @@ -227,12 +222,11 @@ def get( :type cluster_name: str :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: ~azure.mgmt.kusto.models.PrivateLinkResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -246,22 +240,20 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, cluster_name=cluster_name, private_link_resource_name=private_link_resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -271,13 +263,9 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateLinkResource", pipeline_response) + deserialized = self._deserialize("PrivateLinkResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/privateLinkResources/{privateLinkResourceName}" - } + return deserialized # type: ignore diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_sandbox_custom_images_operations.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_sandbox_custom_images_operations.py index b18519d4ad9e..dfc08153481a 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_sandbox_custom_images_operations.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_sandbox_custom_images_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +50,7 @@ def build_list_by_cluster_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -78,7 +83,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -114,7 +119,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -153,7 +158,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -192,7 +197,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -228,7 +233,7 @@ def build_check_name_availability_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -288,7 +293,6 @@ def list_by_cluster( :type resource_group_name: str :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 SandboxCustomImage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kusto.models.SandboxCustomImage] :raises ~azure.core.exceptions.HttpResponseError: @@ -299,7 +303,7 @@ def list_by_cluster( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SandboxCustomImagesListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -310,17 +314,15 @@ def list_by_cluster( def prepare_request(next_link=None): if not next_link: - request = build_list_by_cluster_request( + _request = build_list_by_cluster_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_cluster.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -332,13 +334,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("SandboxCustomImagesListResult", pipeline_response) @@ -348,11 +349,11 @@ def extract_data(pipeline_response): return None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -365,10 +366,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_cluster.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/sandboxCustomImages" - } - @distributed_trace def get( self, resource_group_name: str, cluster_name: str, sandbox_custom_image_name: str, **kwargs: Any @@ -382,12 +379,11 @@ def get( :type cluster_name: str :param sandbox_custom_image_name: The name of the sandbox custom image. Required. :type sandbox_custom_image_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SandboxCustomImage or the result of cls(response) :rtype: ~azure.mgmt.kusto.models.SandboxCustomImage :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -401,22 +397,20 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SandboxCustomImage] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, cluster_name=cluster_name, sandbox_custom_image_name=sandbox_custom_image_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -426,26 +420,22 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SandboxCustomImage", pipeline_response) + deserialized = self._deserialize("SandboxCustomImage", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/sandboxCustomImages/{sandboxCustomImageName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, cluster_name: str, sandbox_custom_image_name: str, - parameters: Union[_models.SandboxCustomImage, IO], + parameters: Union[_models.SandboxCustomImage, IO[bytes]], **kwargs: Any - ) -> _models.SandboxCustomImage: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -458,7 +448,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SandboxCustomImage] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -468,7 +458,7 @@ def _create_or_update_initial( else: _json = self._serialize.body(parameters, "SandboxCustomImage") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, sandbox_custom_image_name=sandbox_custom_image_name, @@ -477,40 +467,35 @@ def _create_or_update_initial( 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("SandboxCustomImage", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SandboxCustomImage", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/sandboxCustomImages/{sandboxCustomImageName}" - } - @overload def begin_create_or_update( self, @@ -536,14 +521,6 @@ def begin_create_or_update( :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 SandboxCustomImage or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.SandboxCustomImage] @@ -556,7 +533,7 @@ def begin_create_or_update( resource_group_name: str, cluster_name: str, sandbox_custom_image_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -571,18 +548,10 @@ def begin_create_or_update( :param sandbox_custom_image_name: The name of the sandbox custom image. Required. :type sandbox_custom_image_name: str :param parameters: The sandbox custom image parameters. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 SandboxCustomImage or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.SandboxCustomImage] @@ -595,7 +564,7 @@ def begin_create_or_update( resource_group_name: str, cluster_name: str, sandbox_custom_image_name: str, - parameters: Union[_models.SandboxCustomImage, IO], + parameters: Union[_models.SandboxCustomImage, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.SandboxCustomImage]: """Creates or updates a sandbox custom image. @@ -608,19 +577,8 @@ def begin_create_or_update( :param sandbox_custom_image_name: The name of the sandbox custom image. Required. :type sandbox_custom_image_name: str :param parameters: The sandbox custom image parameters. Is either a SandboxCustomImage type or - a IO type. Required. - :type parameters: ~azure.mgmt.kusto.models.SandboxCustomImage 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. + a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.kusto.models.SandboxCustomImage or IO[bytes] :return: An instance of LROPoller that returns either SandboxCustomImage or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.SandboxCustomImage] @@ -648,12 +606,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SandboxCustomImage", pipeline_response) + deserialized = self._deserialize("SandboxCustomImage", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -663,27 +622,25 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.SandboxCustomImage].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/sandboxCustomImages/{sandboxCustomImageName}" - } + return LROPoller[_models.SandboxCustomImage]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, resource_group_name: str, cluster_name: str, sandbox_custom_image_name: str, - parameters: Union[_models.SandboxCustomImage, IO], + parameters: Union[_models.SandboxCustomImage, IO[bytes]], **kwargs: Any - ) -> _models.SandboxCustomImage: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -696,7 +653,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SandboxCustomImage] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -706,7 +663,7 @@ def _update_initial( else: _json = self._serialize.body(parameters, "SandboxCustomImage") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, sandbox_custom_image_name=sandbox_custom_image_name, @@ -715,49 +672,42 @@ def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("SandboxCustomImage", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SandboxCustomImage", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Azure-AsyncOperation"] = self._deserialize( "str", response.headers.get("Azure-AsyncOperation") ) - deserialized = self._deserialize("SandboxCustomImage", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/sandboxCustomImages/{sandboxCustomImageName}" - } - @overload def begin_update( self, @@ -783,14 +733,6 @@ def begin_update( :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 SandboxCustomImage or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.SandboxCustomImage] @@ -803,7 +745,7 @@ def begin_update( resource_group_name: str, cluster_name: str, sandbox_custom_image_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -818,18 +760,10 @@ def begin_update( :param sandbox_custom_image_name: The name of the sandbox custom image. Required. :type sandbox_custom_image_name: str :param parameters: The sandbox custom image parameters. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 SandboxCustomImage or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.SandboxCustomImage] @@ -842,7 +776,7 @@ def begin_update( resource_group_name: str, cluster_name: str, sandbox_custom_image_name: str, - parameters: Union[_models.SandboxCustomImage, IO], + parameters: Union[_models.SandboxCustomImage, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.SandboxCustomImage]: """Updates a sandbox custom image. @@ -855,19 +789,8 @@ def begin_update( :param sandbox_custom_image_name: The name of the sandbox custom image. Required. :type sandbox_custom_image_name: str :param parameters: The sandbox custom image parameters. Is either a SandboxCustomImage type or - a IO type. Required. - :type parameters: ~azure.mgmt.kusto.models.SandboxCustomImage 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. + a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.kusto.models.SandboxCustomImage or IO[bytes] :return: An instance of LROPoller that returns either SandboxCustomImage or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.kusto.models.SandboxCustomImage] @@ -895,12 +818,13 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SandboxCustomImage", pipeline_response) + deserialized = self._deserialize("SandboxCustomImage", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -910,22 +834,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.SandboxCustomImage].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/sandboxCustomImages/{sandboxCustomImageName}" - } + return LROPoller[_models.SandboxCustomImage]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, cluster_name: str, sandbox_custom_image_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -937,29 +859,32 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, cluster_name=cluster_name, sandbox_custom_image_name=sandbox_custom_image_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -971,12 +896,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/sandboxCustomImages/{sandboxCustomImageName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -991,14 +916,6 @@ def begin_delete( :type cluster_name: str :param sandbox_custom_image_name: The name of the sandbox custom image. Required. :type sandbox_custom_image_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1012,7 +929,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, sandbox_custom_image_name=sandbox_custom_image_name, @@ -1022,11 +939,12 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -1035,17 +953,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/sandboxCustomImages/{sandboxCustomImageName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @overload def check_name_availability( @@ -1069,7 +983,6 @@ def check_name_availability( :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: @@ -1080,7 +993,7 @@ def check_name_availability( self, resource_group_name: str, cluster_name: str, - resource_name: IO, + resource_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1093,11 +1006,10 @@ def check_name_availability( :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 + :type resource_name: IO[bytes] :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: @@ -1108,7 +1020,7 @@ def check_name_availability( self, resource_group_name: str, cluster_name: str, - resource_name: Union[_models.SandboxCustomImagesCheckNameRequest, IO], + resource_name: Union[_models.SandboxCustomImagesCheckNameRequest, IO[bytes]], **kwargs: Any ) -> _models.CheckNameResult: """Checks that the sandbox custom image resource name is valid and is not already in use. @@ -1119,17 +1031,13 @@ def check_name_availability( :param cluster_name: The name of the Kusto cluster. Required. :type cluster_name: str :param resource_name: The name of the resource. Is either a SandboxCustomImagesCheckNameRequest - type or a IO type. Required. - :type resource_name: ~azure.mgmt.kusto.models.SandboxCustomImagesCheckNameRequest 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 + type or a IO[bytes] type. Required. + :type resource_name: ~azure.mgmt.kusto.models.SandboxCustomImagesCheckNameRequest or IO[bytes] :return: CheckNameResult or the result of cls(response) :rtype: ~azure.mgmt.kusto.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1152,7 +1060,7 @@ def check_name_availability( else: _json = self._serialize.body(resource_name, "SandboxCustomImagesCheckNameRequest") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( resource_group_name=resource_group_name, cluster_name=cluster_name, subscription_id=self._config.subscription_id, @@ -1160,16 +1068,14 @@ def check_name_availability( content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1179,13 +1085,9 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameResult", pipeline_response) + deserialized = self._deserialize("CheckNameResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/sandboxCustomImagesCheckNameAvailability" - } + return deserialized # 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 11ed06a500e4..7a75b9d2c33e 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,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +50,7 @@ def build_list_by_database_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -84,7 +89,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -124,7 +129,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -167,7 +172,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -210,7 +215,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -245,7 +250,7 @@ def build_check_name_availability_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -308,7 +313,6 @@ def list_by_database( :type cluster_name: str :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 Script or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.kusto.models.Script] :raises ~azure.core.exceptions.HttpResponseError: @@ -319,7 +323,7 @@ def list_by_database( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ScriptListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -330,18 +334,16 @@ def list_by_database( def prepare_request(next_link=None): if not next_link: - request = build_list_by_database_request( + _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, 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) else: # make call to next link with the client's api-version @@ -353,13 +355,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ScriptListResult", pipeline_response) @@ -369,11 +370,11 @@ def extract_data(pipeline_response): return None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -386,10 +387,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts" - } - @distributed_trace def get( self, resource_group_name: str, cluster_name: str, database_name: str, script_name: str, **kwargs: Any @@ -405,12 +402,11 @@ def get( :type database_name: str :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: ~azure.mgmt.kusto.models.Script :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -424,23 +420,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Script] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_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, - 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) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -450,16 +444,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Script", pipeline_response) + deserialized = self._deserialize("Script", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, @@ -467,10 +457,10 @@ def _create_or_update_initial( cluster_name: str, database_name: str, script_name: str, - parameters: Union[_models.Script, IO], + parameters: Union[_models.Script, IO[bytes]], **kwargs: Any - ) -> _models.Script: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -483,7 +473,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Script] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -493,7 +483,7 @@ def _create_or_update_initial( else: _json = self._serialize.body(parameters, "Script") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -503,48 +493,41 @@ def _create_or_update_initial( 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Script", pipeline_response) - - if response.status_code == 201: - 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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}" - } - @overload def begin_create_or_update( self, @@ -573,14 +556,6 @@ def begin_create_or_update( :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: @@ -593,7 +568,7 @@ def begin_create_or_update( cluster_name: str, database_name: str, script_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -610,18 +585,10 @@ def begin_create_or_update( :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 + :type parameters: IO[bytes] :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: @@ -634,7 +601,7 @@ def begin_create_or_update( cluster_name: str, database_name: str, script_name: str, - parameters: Union[_models.Script, IO], + parameters: Union[_models.Script, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Script]: """Creates a Kusto database script. @@ -649,19 +616,8 @@ def begin_create_or_update( :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. Is either a Script 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 - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.kusto.models.Script or IO[bytes] :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: @@ -689,12 +645,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Script", pipeline_response) + deserialized = self._deserialize("Script", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -704,17 +661,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Script].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}" - } + return LROPoller[_models.Script]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, @@ -722,10 +677,10 @@ def _update_initial( cluster_name: str, database_name: str, script_name: str, - parameters: Union[_models.Script, IO], + parameters: Union[_models.Script, IO[bytes]], **kwargs: Any - ) -> _models.Script: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -738,7 +693,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Script] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -748,7 +703,7 @@ def _update_initial( else: _json = self._serialize.body(parameters, "Script") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -758,46 +713,42 @@ def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Script", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Azure-AsyncOperation"] = self._deserialize( "str", response.headers.get("Azure-AsyncOperation") ) - deserialized = self._deserialize("Script", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}" - } - @overload def begin_update( self, @@ -826,14 +777,6 @@ def begin_update( :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: @@ -846,7 +789,7 @@ def begin_update( cluster_name: str, database_name: str, script_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -863,18 +806,10 @@ def begin_update( :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 + :type parameters: IO[bytes] :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: @@ -887,7 +822,7 @@ def begin_update( cluster_name: str, database_name: str, script_name: str, - parameters: Union[_models.Script, IO], + parameters: Union[_models.Script, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Script]: """Updates a database script. @@ -902,19 +837,8 @@ def begin_update( :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. Is either a Script - 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 - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.kusto.models.Script or IO[bytes] :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: @@ -942,12 +866,13 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Script", pipeline_response) + deserialized = self._deserialize("Script", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -957,22 +882,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Script].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}" - } + return LROPoller[_models.Script]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, cluster_name: str, database_name: str, script_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -984,30 +907,33 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_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, - 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1019,12 +945,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements "str", response.headers.get("Azure-AsyncOperation") ) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -1041,14 +967,6 @@ def begin_delete( :type database_name: str :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. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~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: @@ -1062,7 +980,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -1073,11 +991,12 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -1086,17 +1005,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scripts/{scriptName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @overload def check_name_availability( @@ -1123,7 +1038,6 @@ def check_name_availability( :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: @@ -1135,7 +1049,7 @@ def check_name_availability( resource_group_name: str, cluster_name: str, database_name: str, - script_name: IO, + script_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1150,11 +1064,10 @@ def check_name_availability( :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 + :type script_name: IO[bytes] :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: @@ -1166,7 +1079,7 @@ def check_name_availability( resource_group_name: str, cluster_name: str, database_name: str, - script_name: Union[_models.ScriptCheckNameRequest, IO], + script_name: Union[_models.ScriptCheckNameRequest, IO[bytes]], **kwargs: Any ) -> _models.CheckNameResult: """Checks that the script name is valid and is not already in use. @@ -1178,18 +1091,14 @@ def check_name_availability( :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. Is either a ScriptCheckNameRequest 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 + :param script_name: The name of the script. Is either a ScriptCheckNameRequest type or a + IO[bytes] type. Required. + :type script_name: ~azure.mgmt.kusto.models.ScriptCheckNameRequest or IO[bytes] :return: CheckNameResult or the result of cls(response) :rtype: ~azure.mgmt.kusto.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1212,7 +1121,7 @@ def check_name_availability( else: _json = self._serialize.body(script_name, "ScriptCheckNameRequest") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( resource_group_name=resource_group_name, cluster_name=cluster_name, database_name=database_name, @@ -1221,16 +1130,14 @@ def check_name_availability( content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1240,13 +1147,9 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameResult", pipeline_response) + deserialized = self._deserialize("CheckNameResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/clusters/{clusterName}/databases/{databaseName}/scriptsCheckNameAvailability" - } + return deserialized # type: ignore diff --git a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_skus_operations.py b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_skus_operations.py index 2f760d5af5f8..bf7e45afadf0 100644 --- a/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_skus_operations.py +++ b/sdk/kusto/azure-mgmt-kusto/azure/mgmt/kusto/operations/_skus_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) 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.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +43,7 @@ def build_list_request(location: str, subscription_id: str, **kwargs: Any) -> Ht _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-15")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-13")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -88,7 +91,6 @@ def list(self, location: str, **kwargs: Any) -> Iterable["_models.SkuDescription :param location: The name of Azure region. Required. :type location: str - :keyword callable cls: A custom type or function that will be passed the direct response :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: @@ -99,7 +101,7 @@ def list(self, location: str, **kwargs: Any) -> Iterable["_models.SkuDescription api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SkuDescriptionList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -110,16 +112,14 @@ def list(self, location: str, **kwargs: Any) -> Iterable["_models.SkuDescription def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( location=location, 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) else: # make call to next link with the client's api-version @@ -131,13 +131,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("SkuDescriptionList", pipeline_response) @@ -147,11 +146,11 @@ def extract_data(pipeline_response): return None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -163,5 +162,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Kusto/locations/{location}/skus"} diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_attached_database_configuration_check_name_availability.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_attached_database_configuration_check_name_availability.py index 924e8ce4b36e..7538310af2f5 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_attached_database_configuration_check_name_availability.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_attached_database_configuration_check_name_availability.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoAttachedDatabaseConfigurationCheckNameAvailability.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoAttachedDatabaseConfigurationCheckNameAvailability.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_attached_database_configurations_create_or_update.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_attached_database_configurations_create_or_update.py index a85a3dd4964e..8e277c000361 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_attached_database_configurations_create_or_update.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_attached_database_configurations_create_or_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -54,6 +55,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoAttachedDatabaseConfigurationsCreateOrUpdate.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoAttachedDatabaseConfigurationsCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_attached_database_configurations_delete.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_attached_database_configurations_delete.py index d0e5bc712136..deb8dc8fa187 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_attached_database_configurations_delete.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_attached_database_configurations_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoAttachedDatabaseConfigurationsDelete.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoAttachedDatabaseConfigurationsDelete.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_attached_database_configurations_get.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_attached_database_configurations_get.py index 80c04f052e78..432002cbeffb 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_attached_database_configurations_get.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_attached_database_configurations_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoAttachedDatabaseConfigurationsGet.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoAttachedDatabaseConfigurationsGet.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_attached_database_configurations_list_by_cluster.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_attached_database_configurations_list_by_cluster.py index 5b58d9a0cee4..2b7411fdbe0c 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_attached_database_configurations_list_by_cluster.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_attached_database_configurations_list_by_cluster.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoAttachedDatabaseConfigurationsListByCluster.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoAttachedDatabaseConfigurationsListByCluster.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_add_callout_policies.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_add_callout_policies.py new file mode 100644 index 000000000000..4593f252e690 --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_add_callout_policies.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.kusto import KustoManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-kusto +# USAGE + python kusto_cluster_add_callout_policies.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = KustoManagementClient( + credential=DefaultAzureCredential(), + subscription_id="12345678-1234-1234-1234-123456789098", + ) + + client.clusters.begin_add_callout_policies( + resource_group_name="kustorptest", + cluster_name="kustoCluster", + callout_policies={"value": [{"calloutType": "kusto", "calloutUriRegex": "*", "outboundAccess": "Allow"}]}, + ).result() + + +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoClusterAddCalloutPolicies.json +if __name__ == "__main__": + main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_add_language_extensions.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_add_language_extensions.py index 5995f7a9622f..caa67e12ac6c 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_add_language_extensions.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_add_language_extensions.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClusterAddLanguageExtensions.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoClusterAddLanguageExtensions.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_detach_follower_databases.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_detach_follower_databases.py index b18526ad48f7..24effeffa110 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_detach_follower_databases.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_detach_follower_databases.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -39,6 +40,6 @@ def main(): ).result() -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClusterDetachFollowerDatabases.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoClusterDetachFollowerDatabases.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_list_follower_databases.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_list_follower_databases.py index 7389276fe3ca..c894536980c9 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_list_follower_databases.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_list_follower_databases.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClusterListFollowerDatabases.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoClusterListFollowerDatabases.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_list_follower_databases_get.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_list_follower_databases_get.py new file mode 100644 index 000000000000..8f13c0a30535 --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_list_follower_databases_get.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.kusto import KustoManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-kusto +# USAGE + python kusto_cluster_list_follower_databases_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = KustoManagementClient( + credential=DefaultAzureCredential(), + subscription_id="12345678-1234-1234-1234-123456789098", + ) + + response = client.clusters.list_follower_databases_get( + resource_group_name="kustorptest", + cluster_name="kustoCluster", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoClusterListFollowerDatabasesGet.json +if __name__ == "__main__": + main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_list_language_extensions.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_list_language_extensions.py index 4a7c5109062a..cc182440e915 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_list_language_extensions.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_list_language_extensions.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClusterListLanguageExtensions.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoClusterListLanguageExtensions.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_migrate.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_migrate.py index e8b66601a532..9b160df8100f 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_migrate.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_migrate.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -38,6 +39,6 @@ def main(): ).result() -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClusterMigrate.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoClusterMigrate.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_principal_assignments_check_name_availability.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_principal_assignments_check_name_availability.py index 04896c13f45a..2c9bd62f6cf1 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_principal_assignments_check_name_availability.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_principal_assignments_check_name_availability.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClusterPrincipalAssignmentsCheckNameAvailability.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoClusterPrincipalAssignmentsCheckNameAvailability.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_principal_assignments_create_or_update.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_principal_assignments_create_or_update.py index 0442cc5f8c4a..dc54c7ee72ba 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_principal_assignments_create_or_update.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_principal_assignments_create_or_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -45,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClusterPrincipalAssignmentsCreateOrUpdate.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoClusterPrincipalAssignmentsCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_principal_assignments_delete.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_principal_assignments_delete.py index 954546b1e72c..0b3357bb7ca0 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_principal_assignments_delete.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_principal_assignments_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClusterPrincipalAssignmentsDelete.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoClusterPrincipalAssignmentsDelete.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_principal_assignments_get.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_principal_assignments_get.py index cdb0d9ab4ab3..f771758a281d 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_principal_assignments_get.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_principal_assignments_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClusterPrincipalAssignmentsGet.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoClusterPrincipalAssignmentsGet.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_principal_assignments_list.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_principal_assignments_list.py index 29c58de93b4e..ea1c4df2a147 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_principal_assignments_list.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_principal_assignments_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClusterPrincipalAssignmentsList.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoClusterPrincipalAssignmentsList.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_remove_callout_policy.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_remove_callout_policy.py new file mode 100644 index 000000000000..1b7292ed4fa5 --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_remove_callout_policy.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.kusto import KustoManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-kusto +# USAGE + python kusto_cluster_remove_callout_policy.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = KustoManagementClient( + credential=DefaultAzureCredential(), + subscription_id="12345678-1234-1234-1234-123456789098", + ) + + client.clusters.begin_remove_callout_policy( + resource_group_name="kustorptest", + cluster_name="kustoCluster", + callout_policy={"calloutId": "*_kusto"}, + ).result() + + +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoClusterRemoveCalloutPolicy.json +if __name__ == "__main__": + main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_remove_language_extensions.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_remove_language_extensions.py index eed52c7642ba..e047eedd9de0 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_remove_language_extensions.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_cluster_remove_language_extensions.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClusterRemoveLanguageExtensions.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoClusterRemoveLanguageExtensions.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_check_name_availability.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_check_name_availability.py index c6b484d2cf5d..9dbb7acb7510 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_check_name_availability.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_check_name_availability.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClustersCheckNameAvailability.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoClustersCheckNameAvailability.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_create_or_update.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_create_or_update.py index 8f9ecfc2de73..474faa6b6c2b 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_create_or_update.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_create_or_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -43,11 +44,7 @@ def main(): "enableStreamingIngest": True, "languageExtensions": { "value": [ - { - "languageExtensionCustomImageName": "customImage8", - "languageExtensionImageName": "Python_Custom_Image", - "languageExtensionName": "PYTHON", - }, + {"languageExtensionImageName": "Python3_10_8", "languageExtensionName": "PYTHON"}, {"languageExtensionImageName": "R", "languageExtensionName": "R"}, ] }, @@ -60,6 +57,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClustersCreateOrUpdate.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoClustersCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_delete.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_delete.py index 7ed0f14fce10..1b5f4d2b13d5 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_delete.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -35,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClustersDelete.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoClustersDelete.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_diagnose_virtual_network.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_diagnose_virtual_network.py index e48106fc63b0..77deca9022c9 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_diagnose_virtual_network.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_diagnose_virtual_network.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClustersDiagnoseVirtualNetwork.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoClustersDiagnoseVirtualNetwork.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_get.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_get.py index 523006b8c26a..03e188b47ae4 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_get.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClustersGet.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoClustersGet.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_list.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_list.py index 50a954ae31a6..73c2011ef004 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_list.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClustersList.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoClustersList.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_list_by_resource_group.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_list_by_resource_group.py index 974fba56ecad..1beeec3d121b 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_list_by_resource_group.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_list_by_resource_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClustersListByResourceGroup.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoClustersListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_list_callout_policies.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_list_callout_policies.py new file mode 100644 index 000000000000..f33654f3eae7 --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_list_callout_policies.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.kusto import KustoManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-kusto +# USAGE + python kusto_clusters_list_callout_policies.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = KustoManagementClient( + credential=DefaultAzureCredential(), + subscription_id="12345678-1234-1234-1234-123456789098", + ) + + response = client.clusters.list_callout_policies( + resource_group_name="kustorptest", + cluster_name="kustoCluster", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoClustersListCalloutPolicies.json +if __name__ == "__main__": + main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_list_resource_skus.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_list_resource_skus.py index d32438afd35b..4269bad6d4f9 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_list_resource_skus.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_list_resource_skus.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClustersListResourceSkus.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoClustersListResourceSkus.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_list_skus.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_list_skus.py index 64842393bf6b..bc787719af7e 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_list_skus.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_list_skus.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClustersListSkus.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoClustersListSkus.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_start.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_start.py index 6ad322fc7ac4..24549d184e07 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_start.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_start.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -35,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClustersStart.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoClustersStart.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_stop.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_stop.py index 6b605388e8fa..bc16ec311407 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_stop.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_stop.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -35,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClustersStop.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoClustersStop.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_update.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_update.py index 5c807eb0499a..f3b2a4741577 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_update.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_clusters_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClustersUpdate.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoClustersUpdate.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connection_event_grid_validation_async.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connection_event_grid_validation_async.py index d84e267f4073..bdfad9070b7f 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connection_event_grid_validation_async.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connection_event_grid_validation_async.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -40,7 +41,7 @@ def main(): "properties": { "blobStorageEventType": "Microsoft.Storage.BlobCreated", "consumerGroup": "$Default", - "dataFormat": "JSON", + "dataFormat": "MULTIJSON", "databaseRouting": "Single", "eventGridResourceId": "/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.Storage/storageAccounts/teststorageaccount/providers/Microsoft.EventGrid/eventSubscriptions/eventSubscriptionTest", "eventHubResourceId": "/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.EventHub/namespaces/eventhubTestns1/eventhubs/eventhubTest1", @@ -56,6 +57,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDataConnectionEventGridValidationAsync.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoDataConnectionEventGridValidationAsync.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connection_validation_async.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connection_validation_async.py index b5e4035b7529..40a545eec539 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connection_validation_async.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connection_validation_async.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -40,7 +41,7 @@ def main(): "properties": { "compression": "None", "consumerGroup": "testConsumerGroup1", - "dataFormat": "JSON", + "dataFormat": "MULTIJSON", "eventHubResourceId": "/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.EventHub/namespaces/eventhubTestns1/eventhubs/eventhubTest1", "managedIdentityResourceId": "/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.ManagedIdentity/userAssignedIdentities/managedidentityTest1", "mappingRuleName": "TestMapping", @@ -52,6 +53,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDataConnectionValidationAsync.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoDataConnectionValidationAsync.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_check_name_availability.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_check_name_availability.py index 7aac4c620886..3738b83a968c 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_check_name_availability.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_check_name_availability.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDataConnectionsCheckNameAvailability.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoDataConnectionsCheckNameAvailability.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_cosmos_db_create_or_update.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_cosmos_db_create_or_update.py index 8c45966500b8..a2521d07151a 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_cosmos_db_create_or_update.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_cosmos_db_create_or_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -51,6 +52,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDataConnectionsCosmosDbCreateOrUpdate.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoDataConnectionsCosmosDbCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_cosmos_db_get.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_cosmos_db_get.py index bb4a3a506f40..7fc46f4ccf64 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_cosmos_db_get.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_cosmos_db_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDataConnectionsCosmosDbGet.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoDataConnectionsCosmosDbGet.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_cosmos_db_update.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_cosmos_db_update.py index 72dff3bdb829..56f7c7c11b0c 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_cosmos_db_update.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_cosmos_db_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -51,6 +52,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDataConnectionsCosmosDbUpdate.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoDataConnectionsCosmosDbUpdate.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_create_or_update.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_create_or_update.py index f86e5a3b20bf..2910388711d2 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_create_or_update.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_create_or_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -47,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDataConnectionsCreateOrUpdate.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoDataConnectionsCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_delete.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_delete.py index 2e127d470e61..19904c7afe97 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_delete.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -37,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDataConnectionsDelete.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoDataConnectionsDelete.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_event_grid_create_or_update.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_event_grid_create_or_update.py index 73a2ee882def..c6a93188cdfe 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_event_grid_create_or_update.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_event_grid_create_or_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -40,7 +41,7 @@ def main(): "properties": { "blobStorageEventType": "Microsoft.Storage.BlobCreated", "consumerGroup": "$Default", - "dataFormat": "JSON", + "dataFormat": "MULTIJSON", "databaseRouting": "Single", "eventGridResourceId": "/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.Storage/storageAccounts/teststorageaccount/providers/Microsoft.EventGrid/eventSubscriptions/eventSubscriptionTest", "eventHubResourceId": "/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.EventHub/namespaces/eventhubTestns1/eventhubs/eventhubTest2", @@ -55,6 +56,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDataConnectionsEventGridCreateOrUpdate.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoDataConnectionsEventGridCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_event_grid_get.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_event_grid_get.py index 05738b586bc2..202a48942998 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_event_grid_get.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_event_grid_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDataConnectionsEventGridGet.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoDataConnectionsEventGridGet.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_event_grid_update.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_event_grid_update.py index 71c9892dede3..90b5c84592a7 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_event_grid_update.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_event_grid_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -40,7 +41,7 @@ def main(): "properties": { "blobStorageEventType": "Microsoft.Storage.BlobCreated", "consumerGroup": "$Default", - "dataFormat": "JSON", + "dataFormat": "MULTIJSON", "databaseRouting": "Single", "eventGridResourceId": "/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.Storage/storageAccounts/teststorageaccount/providers/Microsoft.EventGrid/eventSubscriptions/eventSubscriptionTest", "eventHubResourceId": "/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.EventHub/namespaces/eventhubTestns1/eventhubs/eventhubTest2", @@ -55,6 +56,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDataConnectionsEventGridUpdate.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoDataConnectionsEventGridUpdate.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_get.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_get.py index 17b25e49056a..619e6355a9f2 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_get.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDataConnectionsGet.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoDataConnectionsGet.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_list_by_database.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_list_by_database.py index 0fe10f3aad6e..a3dbf81577e6 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_list_by_database.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_list_by_database.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDataConnectionsListByDatabase.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoDataConnectionsListByDatabase.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_update.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_update.py index ba4257baf136..999c59ee7608 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_update.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_data_connections_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -47,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDataConnectionsUpdate.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoDataConnectionsUpdate.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_add_principals.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_add_principals.py index 1e0912b486fb..e52c7a27677f 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_add_principals.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_add_principals.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -65,6 +66,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabaseAddPrincipals.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoDatabaseAddPrincipals.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_invite_follower.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_invite_follower.py index cae3698829f3..bd01192eebf4 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_invite_follower.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_invite_follower.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -50,6 +51,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabaseInviteFollower.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoDatabaseInviteFollower.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_list_principals.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_list_principals.py index 6e5dc1f21529..34f5cd41a008 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_list_principals.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_list_principals.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabaseListPrincipals.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoDatabaseListPrincipals.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_principal_assignments_check_name_availability.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_principal_assignments_check_name_availability.py index 8578ac1f4494..2565e79b8cd7 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_principal_assignments_check_name_availability.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_principal_assignments_check_name_availability.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -41,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabasePrincipalAssignmentsCheckNameAvailability.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoDatabasePrincipalAssignmentsCheckNameAvailability.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_principal_assignments_create_or_update.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_principal_assignments_create_or_update.py index 129ab2150113..9044906a9bfc 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_principal_assignments_create_or_update.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_principal_assignments_create_or_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -46,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabasePrincipalAssignmentsCreateOrUpdate.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoDatabasePrincipalAssignmentsCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_principal_assignments_delete.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_principal_assignments_delete.py index bf918167e87e..12208c6256b8 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_principal_assignments_delete.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_principal_assignments_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -37,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabasePrincipalAssignmentsDelete.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoDatabasePrincipalAssignmentsDelete.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_principal_assignments_get.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_principal_assignments_get.py index cfafb7d62c48..ed4bd3889a58 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_principal_assignments_get.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_principal_assignments_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabasePrincipalAssignmentsGet.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoDatabasePrincipalAssignmentsGet.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_principal_assignments_list.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_principal_assignments_list.py index 2e23023718fb..66ae0f531020 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_principal_assignments_list.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_principal_assignments_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabasePrincipalAssignmentsList.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoDatabasePrincipalAssignmentsList.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_readonly_update.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_readonly_update.py index 01bc8658333d..38cb5b764e28 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_readonly_update.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_readonly_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabaseReadonlyUpdate.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoDatabaseReadonlyUpdate.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_remove_principals.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_remove_principals.py index 648b255598a2..be07554e1830 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_remove_principals.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_database_remove_principals.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -65,6 +66,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabaseRemovePrincipals.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoDatabaseRemovePrincipals.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_databases_check_name_availability.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_databases_check_name_availability.py index 115b5d95f010..e832c2e083ca 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_databases_check_name_availability.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_databases_check_name_availability.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabasesCheckNameAvailability.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoDatabasesCheckNameAvailability.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_databases_create_or_update.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_databases_create_or_update.py index c350065ff8f1..beb89f153d9a 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_databases_create_or_update.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_databases_create_or_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabasesCreateOrUpdate.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoDatabasesCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_databases_delete.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_databases_delete.py index ada32c3c15ae..bfddf69a88d9 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_databases_delete.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_databases_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabasesDelete.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoDatabasesDelete.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_databases_get.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_databases_get.py index 536b63e51f36..fd43122fe4b2 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_databases_get.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_databases_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabasesGet.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoDatabasesGet.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_databases_list_by_cluster.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_databases_list_by_cluster.py index 866fd9d1d19e..3242e14a6205 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_databases_list_by_cluster.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_databases_list_by_cluster.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabasesListByCluster.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoDatabasesListByCluster.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_databases_update.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_databases_update.py index 2aa1b1fcb04a..0ffedee5d364 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_databases_update.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_databases_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabasesUpdate.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoDatabasesUpdate.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_managed_private_endpoints_check_name_availability.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_managed_private_endpoints_check_name_availability.py index a8326e3d4006..392a5c9b7883 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_managed_private_endpoints_check_name_availability.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_managed_private_endpoints_check_name_availability.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoManagedPrivateEndpointsCheckNameAvailability.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoManagedPrivateEndpointsCheckNameAvailability.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_managed_private_endpoints_create_or_update.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_managed_private_endpoints_create_or_update.py index 6d494b129c2f..ca095697ac1a 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_managed_private_endpoints_create_or_update.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_managed_private_endpoints_create_or_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -44,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoManagedPrivateEndpointsCreateOrUpdate.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoManagedPrivateEndpointsCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_managed_private_endpoints_delete.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_managed_private_endpoints_delete.py index 8c25199881eb..4abb4ad53c08 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_managed_private_endpoints_delete.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_managed_private_endpoints_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoManagedPrivateEndpointsDelete.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoManagedPrivateEndpointsDelete.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_managed_private_endpoints_get.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_managed_private_endpoints_get.py index fbefb386215e..201e413ccb6d 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_managed_private_endpoints_get.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_managed_private_endpoints_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoManagedPrivateEndpointsGet.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoManagedPrivateEndpointsGet.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_managed_private_endpoints_list.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_managed_private_endpoints_list.py index 47601d78592d..46f232104ceb 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_managed_private_endpoints_list.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_managed_private_endpoints_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoManagedPrivateEndpointsList.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoManagedPrivateEndpointsList.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_managed_private_endpoints_update.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_managed_private_endpoints_update.py index 163c440e11ee..044f944873c4 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_managed_private_endpoints_update.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_managed_private_endpoints_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -44,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoManagedPrivateEndpointsUpdate.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoManagedPrivateEndpointsUpdate.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_operation_results_get.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_operation_results_get.py index 835ea034bf72..7aecc4dfb224 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_operation_results_get.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_operation_results_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoOperationResultsGet.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoOperationResultsGet.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_operation_results_operation_result_response_type_get.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_operation_results_operation_result_response_type_get.py index fc427978a632..ec39154c0e33 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_operation_results_operation_result_response_type_get.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_operation_results_operation_result_response_type_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -35,6 +36,6 @@ def main(): ) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoOperationResultsOperationResultResponseTypeGet.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoOperationResultsOperationResultResponseTypeGet.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_operations_list.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_operations_list.py index cae5027837e5..9e62a9bbed53 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_operations_list.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_operations_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoOperationsList.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoOperationsList.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_outbound_network_dependencies_list.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_outbound_network_dependencies_list.py index 9abdd6242cc9..e1bf47fb253f 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_outbound_network_dependencies_list.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_outbound_network_dependencies_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoOutboundNetworkDependenciesList.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoOutboundNetworkDependenciesList.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_private_endpoint_connections_create_or_update.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_private_endpoint_connections_create_or_update.py index b61e2733ba99..c270913bfe46 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_private_endpoint_connections_create_or_update.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_private_endpoint_connections_create_or_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -45,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoPrivateEndpointConnectionsCreateOrUpdate.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoPrivateEndpointConnectionsCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_private_endpoint_connections_delete.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_private_endpoint_connections_delete.py index 93cb8a9ca95e..aa6c024f86ed 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_private_endpoint_connections_delete.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_private_endpoint_connections_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoPrivateEndpointConnectionsDelete.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoPrivateEndpointConnectionsDelete.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_private_endpoint_connections_get.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_private_endpoint_connections_get.py index 570b7361cd2b..8ba5054f2f6b 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_private_endpoint_connections_get.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_private_endpoint_connections_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoPrivateEndpointConnectionsGet.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoPrivateEndpointConnectionsGet.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_private_endpoint_connections_list.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_private_endpoint_connections_list.py index c0d5de37d49a..a55a9c5bdfa4 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_private_endpoint_connections_list.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_private_endpoint_connections_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoPrivateEndpointConnectionsList.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoPrivateEndpointConnectionsList.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_private_link_resources_get.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_private_link_resources_get.py index 5d588a645fe9..fb5b11fca8aa 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_private_link_resources_get.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_private_link_resources_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoPrivateLinkResourcesGet.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoPrivateLinkResourcesGet.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_private_link_resources_list.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_private_link_resources_list.py index be97a5d742fe..fe1585eac53a 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_private_link_resources_list.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_private_link_resources_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoPrivateLinkResourcesList.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoPrivateLinkResourcesList.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_sandbox_custom_image_delete.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_sandbox_custom_image_delete.py index ad73614f9403..ce641c1d39e8 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_sandbox_custom_image_delete.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_sandbox_custom_image_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoSandboxCustomImageDelete.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoSandboxCustomImageDelete.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_sandbox_custom_image_update.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_sandbox_custom_image_update.py index 414cff032fb7..d12193a4a5e1 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_sandbox_custom_image_update.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_sandbox_custom_image_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -40,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoSandboxCustomImageUpdate.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoSandboxCustomImageUpdate.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_sandbox_custom_images_check_name_availability.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_sandbox_custom_images_check_name_availability.py index 9680cf208137..ba911dd8c88e 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_sandbox_custom_images_check_name_availability.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_sandbox_custom_images_check_name_availability.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoSandboxCustomImagesCheckNameAvailability.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoSandboxCustomImagesCheckNameAvailability.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_sandbox_custom_images_create_or_update.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_sandbox_custom_images_create_or_update.py index dbf7ea1d865f..c62e3704601e 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_sandbox_custom_images_create_or_update.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_sandbox_custom_images_create_or_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -40,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoSandboxCustomImagesCreateOrUpdate.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoSandboxCustomImagesCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_sandbox_custom_images_create_or_update_with_custom_base_image.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_sandbox_custom_images_create_or_update_with_custom_base_image.py new file mode 100644 index 000000000000..798f8b23d361 --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_sandbox_custom_images_create_or_update_with_custom_base_image.py @@ -0,0 +1,46 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.kusto import KustoManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-kusto +# USAGE + python kusto_sandbox_custom_images_create_or_update_with_custom_base_image.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = KustoManagementClient( + credential=DefaultAzureCredential(), + subscription_id="12345678-1234-1234-1234-123456789098", + ) + + response = client.sandbox_custom_images.begin_create_or_update( + resource_group_name="kustorptest", + cluster_name="kustoCluster", + sandbox_custom_image_name="customImage2", + parameters={ + "properties": {"baseImageName": "customImage1", "language": "Python", "requirementsFileContent": "Requests"} + }, + ).result() + print(response) + + +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoSandboxCustomImagesCreateOrUpdateWithCustomBaseImage.json +if __name__ == "__main__": + main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_sandbox_custom_images_create_or_update_with_managed_base_image.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_sandbox_custom_images_create_or_update_with_managed_base_image.py new file mode 100644 index 000000000000..d0f11cca3f4c --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_sandbox_custom_images_create_or_update_with_managed_base_image.py @@ -0,0 +1,46 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.kusto import KustoManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-kusto +# USAGE + python kusto_sandbox_custom_images_create_or_update_with_managed_base_image.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = KustoManagementClient( + credential=DefaultAzureCredential(), + subscription_id="12345678-1234-1234-1234-123456789098", + ) + + response = client.sandbox_custom_images.begin_create_or_update( + resource_group_name="kustorptest", + cluster_name="kustoCluster", + sandbox_custom_image_name="customImage2", + parameters={ + "properties": {"baseImageName": "Python3_10_8", "language": "Python", "requirementsFileContent": "Requests"} + }, + ).result() + print(response) + + +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoSandboxCustomImagesCreateOrUpdateWithManagedBaseImage.json +if __name__ == "__main__": + main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_sandbox_custom_images_get.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_sandbox_custom_images_get.py index 214c95cfb944..b7cb3027baa2 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_sandbox_custom_images_get.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_sandbox_custom_images_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoSandboxCustomImagesGet.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoSandboxCustomImagesGet.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_sandbox_custom_images_list.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_sandbox_custom_images_list.py index 6cd1e78c4a06..a4a605b402d5 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_sandbox_custom_images_list.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_sandbox_custom_images_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoSandboxCustomImagesList.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoSandboxCustomImagesList.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_scripts_check_name_availability.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_scripts_check_name_availability.py index cb5e45c21be7..2a49807e73b6 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_scripts_check_name_availability.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_scripts_check_name_availability.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoScriptsCheckNameAvailability.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoScriptsCheckNameAvailability.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_scripts_create_or_update.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_scripts_create_or_update.py index 5df5d16ae70d..dc9d190ac482 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_scripts_create_or_update.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_scripts_create_or_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -38,6 +39,8 @@ def main(): "properties": { "continueOnErrors": True, "forceUpdateTag": "2bcf3c21-ffd1-4444-b9dd-e52e00ee53fe", + "principalPermissionsAction": "RemovePermissionOnScriptCompletion", + "scriptLevel": "Database", "scriptUrl": "https://mysa.blob.core.windows.net/container/script.txt", "scriptUrlSasToken": "?sv=2019-02-02&st=2019-04-29T22%3A18%3A26Z&se=2019-04-30T02%3A23%3A26Z&sr=b&sp=rw&sip=168.1.5.60-168.1.5.70&spr=https&sig=********************************", } @@ -46,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoScriptsCreateOrUpdate.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoScriptsCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_scripts_delete.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_scripts_delete.py index 27788fa17080..1de7c1fdcd43 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_scripts_delete.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_scripts_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -37,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoScriptsDelete.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoScriptsDelete.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_scripts_get.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_scripts_get.py index b51fc729bbad..08777bd9d4b7 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_scripts_get.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_scripts_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoScriptsGet.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoScriptsGet.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_scripts_list_by_database.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_scripts_list_by_database.py index a563b18d0d88..99f07dd49af9 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_scripts_list_by_database.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_scripts_list_by_database.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoScriptsListByDatabase.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoScriptsListByDatabase.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_scripts_update.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_scripts_update.py index ffc3eee2e29c..8e69b1831897 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_scripts_update.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_scripts_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -38,6 +39,8 @@ def main(): "properties": { "continueOnErrors": True, "forceUpdateTag": "2bcf3c21-ffd1-4444-b9dd-e52e00ee53fe", + "principalPermissionsAction": "RemovePermissionOnScriptCompletion", + "scriptLevel": "Database", "scriptUrl": "https://mysa.blob.core.windows.net/container/script.txt", "scriptUrlSasToken": "?sv=2019-02-02&st=2019-04-29T22%3A18%3A26Z&se=2019-04-30T02%3A23%3A26Z&sr=b&sp=rw&sip=168.1.5.60-168.1.5.70&spr=https&sig=********************************", } @@ -46,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoScriptsUpdate.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoScriptsUpdate.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_skus.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_skus.py index 3bb9908228cc..30d6331faccb 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_skus.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_skus.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoSkus.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoSkus.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_suspended_databases_get.py b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_suspended_databases_get.py index 45240d0804d6..cfb4bfe7288e 100644 --- a/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_suspended_databases_get.py +++ b/sdk/kusto/azure-mgmt-kusto/generated_samples/kusto_suspended_databases_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.kusto import KustoManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoSuspendedDatabasesGet.json +# x-ms-original-file: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2024-04-13/examples/KustoSuspendedDatabasesGet.json if __name__ == "__main__": main() diff --git a/sdk/kusto/azure-mgmt-kusto/generated_tests/conftest.py b/sdk/kusto/azure-mgmt-kusto/generated_tests/conftest.py new file mode 100644 index 000000000000..495577054491 --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/generated_tests/conftest.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# aovid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + kustomanagement_subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + kustomanagement_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + kustomanagement_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + kustomanagement_client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=kustomanagement_subscription_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=kustomanagement_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=kustomanagement_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=kustomanagement_client_secret, value="00000000-0000-0000-0000-000000000000") + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_attached_database_configurations_operations.py b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_attached_database_configurations_operations.py new file mode 100644 index 000000000000..8c21402a4ef9 --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_attached_database_configurations_operations.py @@ -0,0 +1,106 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.kusto import KustoManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestKustoManagementAttachedDatabaseConfigurationsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(KustoManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_check_name_availability(self, resource_group): + response = self.client.attached_database_configurations.check_name_availability( + resource_group_name=resource_group.name, + cluster_name="str", + resource_name={"name": "str", "type": "Microsoft.Kusto/clusters/attachedDatabaseConfigurations"}, + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_cluster(self, resource_group): + response = self.client.attached_database_configurations.list_by_cluster( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-04-13", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.attached_database_configurations.get( + resource_group_name=resource_group.name, + cluster_name="str", + attached_database_configuration_name="str", + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.attached_database_configurations.begin_create_or_update( + resource_group_name=resource_group.name, + cluster_name="str", + attached_database_configuration_name="str", + parameters={ + "attachedDatabaseNames": ["str"], + "clusterResourceId": "str", + "databaseName": "str", + "databaseNameOverride": "str", + "databaseNamePrefix": "str", + "defaultPrincipalsModificationKind": "str", + "id": "str", + "location": "str", + "name": "str", + "provisioningState": "str", + "tableLevelSharingProperties": { + "externalTablesToExclude": ["str"], + "externalTablesToInclude": ["str"], + "functionsToExclude": ["str"], + "functionsToInclude": ["str"], + "materializedViewsToExclude": ["str"], + "materializedViewsToInclude": ["str"], + "tablesToExclude": ["str"], + "tablesToInclude": ["str"], + }, + "type": "str", + }, + api_version="2024-04-13", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.attached_database_configurations.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + attached_database_configuration_name="str", + api_version="2024-04-13", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_attached_database_configurations_operations_async.py b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_attached_database_configurations_operations_async.py new file mode 100644 index 000000000000..c2766d35a1d8 --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_attached_database_configurations_operations_async.py @@ -0,0 +1,111 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.kusto.aio import KustoManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestKustoManagementAttachedDatabaseConfigurationsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(KustoManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_check_name_availability(self, resource_group): + response = await self.client.attached_database_configurations.check_name_availability( + resource_group_name=resource_group.name, + cluster_name="str", + resource_name={"name": "str", "type": "Microsoft.Kusto/clusters/attachedDatabaseConfigurations"}, + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_cluster(self, resource_group): + response = self.client.attached_database_configurations.list_by_cluster( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-04-13", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.attached_database_configurations.get( + resource_group_name=resource_group.name, + cluster_name="str", + attached_database_configuration_name="str", + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.attached_database_configurations.begin_create_or_update( + resource_group_name=resource_group.name, + cluster_name="str", + attached_database_configuration_name="str", + parameters={ + "attachedDatabaseNames": ["str"], + "clusterResourceId": "str", + "databaseName": "str", + "databaseNameOverride": "str", + "databaseNamePrefix": "str", + "defaultPrincipalsModificationKind": "str", + "id": "str", + "location": "str", + "name": "str", + "provisioningState": "str", + "tableLevelSharingProperties": { + "externalTablesToExclude": ["str"], + "externalTablesToInclude": ["str"], + "functionsToExclude": ["str"], + "functionsToInclude": ["str"], + "materializedViewsToExclude": ["str"], + "materializedViewsToInclude": ["str"], + "tablesToExclude": ["str"], + "tablesToInclude": ["str"], + }, + "type": "str", + }, + api_version="2024-04-13", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.attached_database_configurations.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + attached_database_configuration_name="str", + api_version="2024-04-13", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_cluster_principal_assignments_operations.py b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_cluster_principal_assignments_operations.py new file mode 100644 index 000000000000..f69df97ef320 --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_cluster_principal_assignments_operations.py @@ -0,0 +1,96 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.kusto import KustoManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestKustoManagementClusterPrincipalAssignmentsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(KustoManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_check_name_availability(self, resource_group): + response = self.client.cluster_principal_assignments.check_name_availability( + resource_group_name=resource_group.name, + cluster_name="str", + principal_assignment_name={"name": "str", "type": "Microsoft.Kusto/clusters/principalAssignments"}, + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.cluster_principal_assignments.get( + resource_group_name=resource_group.name, + cluster_name="str", + principal_assignment_name="str", + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.cluster_principal_assignments.begin_create_or_update( + resource_group_name=resource_group.name, + cluster_name="str", + principal_assignment_name="str", + parameters={ + "aadObjectId": "str", + "id": "str", + "name": "str", + "principalId": "str", + "principalName": "str", + "principalType": "str", + "provisioningState": "str", + "role": "str", + "tenantId": "str", + "tenantName": "str", + "type": "str", + }, + api_version="2024-04-13", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.cluster_principal_assignments.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + principal_assignment_name="str", + api_version="2024-04-13", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.cluster_principal_assignments.list( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-04-13", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_cluster_principal_assignments_operations_async.py b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_cluster_principal_assignments_operations_async.py new file mode 100644 index 000000000000..2a1081a763dc --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_cluster_principal_assignments_operations_async.py @@ -0,0 +1,101 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.kusto.aio import KustoManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestKustoManagementClusterPrincipalAssignmentsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(KustoManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_check_name_availability(self, resource_group): + response = await self.client.cluster_principal_assignments.check_name_availability( + resource_group_name=resource_group.name, + cluster_name="str", + principal_assignment_name={"name": "str", "type": "Microsoft.Kusto/clusters/principalAssignments"}, + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.cluster_principal_assignments.get( + resource_group_name=resource_group.name, + cluster_name="str", + principal_assignment_name="str", + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.cluster_principal_assignments.begin_create_or_update( + resource_group_name=resource_group.name, + cluster_name="str", + principal_assignment_name="str", + parameters={ + "aadObjectId": "str", + "id": "str", + "name": "str", + "principalId": "str", + "principalName": "str", + "principalType": "str", + "provisioningState": "str", + "role": "str", + "tenantId": "str", + "tenantName": "str", + "type": "str", + }, + api_version="2024-04-13", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.cluster_principal_assignments.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + principal_assignment_name="str", + api_version="2024-04-13", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.cluster_principal_assignments.list( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-04-13", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_clusters_operations.py b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_clusters_operations.py new file mode 100644 index 000000000000..c6882679bad1 --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_clusters_operations.py @@ -0,0 +1,509 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.kusto import KustoManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestKustoManagementClustersOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(KustoManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.clusters.get( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.clusters.begin_create_or_update( + resource_group_name=resource_group.name, + cluster_name="str", + parameters={ + "location": "str", + "sku": {"name": "str", "tier": "str", "capacity": 0}, + "acceptedAudiences": [{"value": "str"}], + "allowedFqdnList": ["str"], + "allowedIpRangeList": ["str"], + "calloutPolicies": [ + {"calloutId": "str", "calloutType": "str", "calloutUriRegex": "str", "outboundAccess": "str"} + ], + "dataIngestionUri": "str", + "enableAutoStop": True, + "enableDiskEncryption": False, + "enableDoubleEncryption": False, + "enablePurge": False, + "enableStreamingIngest": False, + "engineType": "V3", + "etag": "str", + "id": "str", + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "keyVaultProperties": { + "keyName": "str", + "keyVaultUri": "str", + "keyVersion": "str", + "userIdentity": "str", + }, + "languageExtensions": { + "value": [ + { + "languageExtensionCustomImageName": "str", + "languageExtensionImageName": "str", + "languageExtensionName": "str", + } + ] + }, + "migrationCluster": {"dataIngestionUri": "str", "id": "str", "role": "str", "uri": "str"}, + "name": "str", + "optimizedAutoscale": {"isEnabled": bool, "maximum": 0, "minimum": 0, "version": 0}, + "privateEndpointConnections": [ + { + "groupId": "str", + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + } + ], + "provisioningState": "str", + "publicIPType": "IPv4", + "publicNetworkAccess": "Enabled", + "restrictOutboundNetworkAccess": "Disabled", + "state": "str", + "stateReason": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "trustedExternalTenants": [{"value": "str"}], + "type": "str", + "uri": "str", + "virtualClusterGraduationProperties": "str", + "virtualNetworkConfiguration": { + "dataManagementPublicIpId": "str", + "enginePublicIpId": "str", + "subnetId": "str", + "state": "Enabled", + }, + "zoneStatus": "str", + "zones": ["str"], + }, + api_version="2024-04-13", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.clusters.begin_update( + resource_group_name=resource_group.name, + cluster_name="str", + parameters={ + "acceptedAudiences": [{"value": "str"}], + "allowedFqdnList": ["str"], + "allowedIpRangeList": ["str"], + "calloutPolicies": [ + {"calloutId": "str", "calloutType": "str", "calloutUriRegex": "str", "outboundAccess": "str"} + ], + "dataIngestionUri": "str", + "enableAutoStop": True, + "enableDiskEncryption": False, + "enableDoubleEncryption": False, + "enablePurge": False, + "enableStreamingIngest": False, + "engineType": "V3", + "id": "str", + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "keyVaultProperties": { + "keyName": "str", + "keyVaultUri": "str", + "keyVersion": "str", + "userIdentity": "str", + }, + "languageExtensions": { + "value": [ + { + "languageExtensionCustomImageName": "str", + "languageExtensionImageName": "str", + "languageExtensionName": "str", + } + ] + }, + "location": "str", + "migrationCluster": {"dataIngestionUri": "str", "id": "str", "role": "str", "uri": "str"}, + "name": "str", + "optimizedAutoscale": {"isEnabled": bool, "maximum": 0, "minimum": 0, "version": 0}, + "privateEndpointConnections": [ + { + "groupId": "str", + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + } + ], + "provisioningState": "str", + "publicIPType": "IPv4", + "publicNetworkAccess": "Enabled", + "restrictOutboundNetworkAccess": "Disabled", + "sku": {"name": "str", "tier": "str", "capacity": 0}, + "state": "str", + "stateReason": "str", + "tags": {"str": "str"}, + "trustedExternalTenants": [{"value": "str"}], + "type": "str", + "uri": "str", + "virtualClusterGraduationProperties": "str", + "virtualNetworkConfiguration": { + "dataManagementPublicIpId": "str", + "enginePublicIpId": "str", + "subnetId": "str", + "state": "Enabled", + }, + "zoneStatus": "str", + "zones": ["str"], + }, + api_version="2024-04-13", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.clusters.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-04-13", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_stop(self, resource_group): + response = self.client.clusters.begin_stop( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-04-13", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_start(self, resource_group): + response = self.client.clusters.begin_start( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-04-13", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_migrate(self, resource_group): + response = self.client.clusters.begin_migrate( + resource_group_name=resource_group.name, + cluster_name="str", + cluster_migrate_request={"clusterResourceId": "str"}, + api_version="2024-04-13", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_follower_databases_get(self, resource_group): + response = self.client.clusters.list_follower_databases_get( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-04-13", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_follower_databases(self, resource_group): + response = self.client.clusters.list_follower_databases( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-04-13", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_detach_follower_databases(self, resource_group): + response = self.client.clusters.begin_detach_follower_databases( + resource_group_name=resource_group.name, + cluster_name="str", + follower_database_to_remove={ + "attachedDatabaseConfigurationName": "str", + "clusterResourceId": "str", + "databaseName": "str", + "databaseShareOrigin": "str", + "tableLevelSharingProperties": { + "externalTablesToExclude": ["str"], + "externalTablesToInclude": ["str"], + "functionsToExclude": ["str"], + "functionsToInclude": ["str"], + "materializedViewsToExclude": ["str"], + "materializedViewsToInclude": ["str"], + "tablesToExclude": ["str"], + "tablesToInclude": ["str"], + }, + }, + api_version="2024-04-13", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_diagnose_virtual_network(self, resource_group): + response = self.client.clusters.begin_diagnose_virtual_network( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-04-13", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_resource_group(self, resource_group): + response = self.client.clusters.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-04-13", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.clusters.list( + api_version="2024-04-13", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_skus(self, resource_group): + response = self.client.clusters.list_skus( + api_version="2024-04-13", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_check_name_availability(self, resource_group): + response = self.client.clusters.check_name_availability( + location="str", + cluster_name={"name": "str", "type": "Microsoft.Kusto/clusters"}, + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_skus_by_resource(self, resource_group): + response = self.client.clusters.list_skus_by_resource( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-04-13", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_outbound_network_dependencies_endpoints(self, resource_group): + response = self.client.clusters.list_outbound_network_dependencies_endpoints( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-04-13", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_add_callout_policies(self, resource_group): + response = self.client.clusters.begin_add_callout_policies( + resource_group_name=resource_group.name, + cluster_name="str", + callout_policies={ + "nextLink": "str", + "value": [ + {"calloutId": "str", "calloutType": "str", "calloutUriRegex": "str", "outboundAccess": "str"} + ], + }, + api_version="2024-04-13", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_remove_callout_policy(self, resource_group): + response = self.client.clusters.begin_remove_callout_policy( + resource_group_name=resource_group.name, + cluster_name="str", + callout_policy={"calloutId": "str"}, + api_version="2024-04-13", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_callout_policies(self, resource_group): + response = self.client.clusters.list_callout_policies( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-04-13", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_language_extensions(self, resource_group): + response = self.client.clusters.list_language_extensions( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-04-13", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_add_language_extensions(self, resource_group): + response = self.client.clusters.begin_add_language_extensions( + resource_group_name=resource_group.name, + cluster_name="str", + language_extensions_to_add={ + "value": [ + { + "languageExtensionCustomImageName": "str", + "languageExtensionImageName": "str", + "languageExtensionName": "str", + } + ] + }, + api_version="2024-04-13", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_remove_language_extensions(self, resource_group): + response = self.client.clusters.begin_remove_language_extensions( + resource_group_name=resource_group.name, + cluster_name="str", + language_extensions_to_remove={ + "value": [ + { + "languageExtensionCustomImageName": "str", + "languageExtensionImageName": "str", + "languageExtensionName": "str", + } + ] + }, + api_version="2024-04-13", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_clusters_operations_async.py b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_clusters_operations_async.py new file mode 100644 index 000000000000..56e767e54967 --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_clusters_operations_async.py @@ -0,0 +1,534 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.kusto.aio import KustoManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestKustoManagementClustersOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(KustoManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.clusters.get( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.clusters.begin_create_or_update( + resource_group_name=resource_group.name, + cluster_name="str", + parameters={ + "location": "str", + "sku": {"name": "str", "tier": "str", "capacity": 0}, + "acceptedAudiences": [{"value": "str"}], + "allowedFqdnList": ["str"], + "allowedIpRangeList": ["str"], + "calloutPolicies": [ + {"calloutId": "str", "calloutType": "str", "calloutUriRegex": "str", "outboundAccess": "str"} + ], + "dataIngestionUri": "str", + "enableAutoStop": True, + "enableDiskEncryption": False, + "enableDoubleEncryption": False, + "enablePurge": False, + "enableStreamingIngest": False, + "engineType": "V3", + "etag": "str", + "id": "str", + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "keyVaultProperties": { + "keyName": "str", + "keyVaultUri": "str", + "keyVersion": "str", + "userIdentity": "str", + }, + "languageExtensions": { + "value": [ + { + "languageExtensionCustomImageName": "str", + "languageExtensionImageName": "str", + "languageExtensionName": "str", + } + ] + }, + "migrationCluster": {"dataIngestionUri": "str", "id": "str", "role": "str", "uri": "str"}, + "name": "str", + "optimizedAutoscale": {"isEnabled": bool, "maximum": 0, "minimum": 0, "version": 0}, + "privateEndpointConnections": [ + { + "groupId": "str", + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + } + ], + "provisioningState": "str", + "publicIPType": "IPv4", + "publicNetworkAccess": "Enabled", + "restrictOutboundNetworkAccess": "Disabled", + "state": "str", + "stateReason": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "trustedExternalTenants": [{"value": "str"}], + "type": "str", + "uri": "str", + "virtualClusterGraduationProperties": "str", + "virtualNetworkConfiguration": { + "dataManagementPublicIpId": "str", + "enginePublicIpId": "str", + "subnetId": "str", + "state": "Enabled", + }, + "zoneStatus": "str", + "zones": ["str"], + }, + api_version="2024-04-13", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.clusters.begin_update( + resource_group_name=resource_group.name, + cluster_name="str", + parameters={ + "acceptedAudiences": [{"value": "str"}], + "allowedFqdnList": ["str"], + "allowedIpRangeList": ["str"], + "calloutPolicies": [ + {"calloutId": "str", "calloutType": "str", "calloutUriRegex": "str", "outboundAccess": "str"} + ], + "dataIngestionUri": "str", + "enableAutoStop": True, + "enableDiskEncryption": False, + "enableDoubleEncryption": False, + "enablePurge": False, + "enableStreamingIngest": False, + "engineType": "V3", + "id": "str", + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "keyVaultProperties": { + "keyName": "str", + "keyVaultUri": "str", + "keyVersion": "str", + "userIdentity": "str", + }, + "languageExtensions": { + "value": [ + { + "languageExtensionCustomImageName": "str", + "languageExtensionImageName": "str", + "languageExtensionName": "str", + } + ] + }, + "location": "str", + "migrationCluster": {"dataIngestionUri": "str", "id": "str", "role": "str", "uri": "str"}, + "name": "str", + "optimizedAutoscale": {"isEnabled": bool, "maximum": 0, "minimum": 0, "version": 0}, + "privateEndpointConnections": [ + { + "groupId": "str", + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + } + ], + "provisioningState": "str", + "publicIPType": "IPv4", + "publicNetworkAccess": "Enabled", + "restrictOutboundNetworkAccess": "Disabled", + "sku": {"name": "str", "tier": "str", "capacity": 0}, + "state": "str", + "stateReason": "str", + "tags": {"str": "str"}, + "trustedExternalTenants": [{"value": "str"}], + "type": "str", + "uri": "str", + "virtualClusterGraduationProperties": "str", + "virtualNetworkConfiguration": { + "dataManagementPublicIpId": "str", + "enginePublicIpId": "str", + "subnetId": "str", + "state": "Enabled", + }, + "zoneStatus": "str", + "zones": ["str"], + }, + api_version="2024-04-13", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.clusters.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-04-13", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_stop(self, resource_group): + response = await ( + await self.client.clusters.begin_stop( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-04-13", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_start(self, resource_group): + response = await ( + await self.client.clusters.begin_start( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-04-13", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_migrate(self, resource_group): + response = await ( + await self.client.clusters.begin_migrate( + resource_group_name=resource_group.name, + cluster_name="str", + cluster_migrate_request={"clusterResourceId": "str"}, + api_version="2024-04-13", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_follower_databases_get(self, resource_group): + response = self.client.clusters.list_follower_databases_get( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-04-13", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_follower_databases(self, resource_group): + response = self.client.clusters.list_follower_databases( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-04-13", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_detach_follower_databases(self, resource_group): + response = await ( + await self.client.clusters.begin_detach_follower_databases( + resource_group_name=resource_group.name, + cluster_name="str", + follower_database_to_remove={ + "attachedDatabaseConfigurationName": "str", + "clusterResourceId": "str", + "databaseName": "str", + "databaseShareOrigin": "str", + "tableLevelSharingProperties": { + "externalTablesToExclude": ["str"], + "externalTablesToInclude": ["str"], + "functionsToExclude": ["str"], + "functionsToInclude": ["str"], + "materializedViewsToExclude": ["str"], + "materializedViewsToInclude": ["str"], + "tablesToExclude": ["str"], + "tablesToInclude": ["str"], + }, + }, + api_version="2024-04-13", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_diagnose_virtual_network(self, resource_group): + response = await ( + await self.client.clusters.begin_diagnose_virtual_network( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-04-13", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_resource_group(self, resource_group): + response = self.client.clusters.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-04-13", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.clusters.list( + api_version="2024-04-13", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_skus(self, resource_group): + response = self.client.clusters.list_skus( + api_version="2024-04-13", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_check_name_availability(self, resource_group): + response = await self.client.clusters.check_name_availability( + location="str", + cluster_name={"name": "str", "type": "Microsoft.Kusto/clusters"}, + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_skus_by_resource(self, resource_group): + response = self.client.clusters.list_skus_by_resource( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-04-13", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_outbound_network_dependencies_endpoints(self, resource_group): + response = self.client.clusters.list_outbound_network_dependencies_endpoints( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-04-13", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_add_callout_policies(self, resource_group): + response = await ( + await self.client.clusters.begin_add_callout_policies( + resource_group_name=resource_group.name, + cluster_name="str", + callout_policies={ + "nextLink": "str", + "value": [ + {"calloutId": "str", "calloutType": "str", "calloutUriRegex": "str", "outboundAccess": "str"} + ], + }, + api_version="2024-04-13", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_remove_callout_policy(self, resource_group): + response = await ( + await self.client.clusters.begin_remove_callout_policy( + resource_group_name=resource_group.name, + cluster_name="str", + callout_policy={"calloutId": "str"}, + api_version="2024-04-13", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_callout_policies(self, resource_group): + response = self.client.clusters.list_callout_policies( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-04-13", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_language_extensions(self, resource_group): + response = self.client.clusters.list_language_extensions( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-04-13", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_add_language_extensions(self, resource_group): + response = await ( + await self.client.clusters.begin_add_language_extensions( + resource_group_name=resource_group.name, + cluster_name="str", + language_extensions_to_add={ + "value": [ + { + "languageExtensionCustomImageName": "str", + "languageExtensionImageName": "str", + "languageExtensionName": "str", + } + ] + }, + api_version="2024-04-13", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_remove_language_extensions(self, resource_group): + response = await ( + await self.client.clusters.begin_remove_language_extensions( + resource_group_name=resource_group.name, + cluster_name="str", + language_extensions_to_remove={ + "value": [ + { + "languageExtensionCustomImageName": "str", + "languageExtensionImageName": "str", + "languageExtensionName": "str", + } + ] + }, + api_version="2024-04-13", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_data_connections_operations.py b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_data_connections_operations.py new file mode 100644 index 000000000000..45973d0d1cd0 --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_data_connections_operations.py @@ -0,0 +1,148 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.kusto import KustoManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestKustoManagementDataConnectionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(KustoManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_database(self, resource_group): + response = self.client.data_connections.list_by_database( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + api_version="2024-04-13", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_data_connection_validation(self, resource_group): + response = self.client.data_connections.begin_data_connection_validation( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + parameters={"dataConnectionName": "str", "properties": "data_connection"}, + api_version="2024-04-13", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_check_name_availability(self, resource_group): + response = self.client.data_connections.check_name_availability( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + data_connection_name={"name": "str", "type": "Microsoft.Kusto/clusters/databases/dataConnections"}, + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.data_connections.get( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + data_connection_name="str", + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.data_connections.begin_create_or_update( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + data_connection_name="str", + parameters={ + "kind": "CosmosDb", + "cosmosDbAccountResourceId": "str", + "cosmosDbContainer": "str", + "cosmosDbDatabase": "str", + "id": "str", + "location": "str", + "managedIdentityObjectId": "str", + "managedIdentityResourceId": "str", + "mappingRuleName": "str", + "name": "str", + "provisioningState": "str", + "retrievalStartDate": "2020-02-20 00:00:00", + "tableName": "str", + "type": "str", + }, + api_version="2024-04-13", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.data_connections.begin_update( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + data_connection_name="str", + parameters={ + "kind": "CosmosDb", + "cosmosDbAccountResourceId": "str", + "cosmosDbContainer": "str", + "cosmosDbDatabase": "str", + "id": "str", + "location": "str", + "managedIdentityObjectId": "str", + "managedIdentityResourceId": "str", + "mappingRuleName": "str", + "name": "str", + "provisioningState": "str", + "retrievalStartDate": "2020-02-20 00:00:00", + "tableName": "str", + "type": "str", + }, + api_version="2024-04-13", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.data_connections.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + data_connection_name="str", + api_version="2024-04-13", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_data_connections_operations_async.py b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_data_connections_operations_async.py new file mode 100644 index 000000000000..33303f4f1a12 --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_data_connections_operations_async.py @@ -0,0 +1,157 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.kusto.aio import KustoManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestKustoManagementDataConnectionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(KustoManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_database(self, resource_group): + response = self.client.data_connections.list_by_database( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + api_version="2024-04-13", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_data_connection_validation(self, resource_group): + response = await ( + await self.client.data_connections.begin_data_connection_validation( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + parameters={"dataConnectionName": "str", "properties": "data_connection"}, + api_version="2024-04-13", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_check_name_availability(self, resource_group): + response = await self.client.data_connections.check_name_availability( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + data_connection_name={"name": "str", "type": "Microsoft.Kusto/clusters/databases/dataConnections"}, + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.data_connections.get( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + data_connection_name="str", + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.data_connections.begin_create_or_update( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + data_connection_name="str", + parameters={ + "kind": "CosmosDb", + "cosmosDbAccountResourceId": "str", + "cosmosDbContainer": "str", + "cosmosDbDatabase": "str", + "id": "str", + "location": "str", + "managedIdentityObjectId": "str", + "managedIdentityResourceId": "str", + "mappingRuleName": "str", + "name": "str", + "provisioningState": "str", + "retrievalStartDate": "2020-02-20 00:00:00", + "tableName": "str", + "type": "str", + }, + api_version="2024-04-13", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.data_connections.begin_update( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + data_connection_name="str", + parameters={ + "kind": "CosmosDb", + "cosmosDbAccountResourceId": "str", + "cosmosDbContainer": "str", + "cosmosDbDatabase": "str", + "id": "str", + "location": "str", + "managedIdentityObjectId": "str", + "managedIdentityResourceId": "str", + "mappingRuleName": "str", + "name": "str", + "provisioningState": "str", + "retrievalStartDate": "2020-02-20 00:00:00", + "tableName": "str", + "type": "str", + }, + api_version="2024-04-13", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.data_connections.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + data_connection_name="str", + api_version="2024-04-13", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_database_operations.py b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_database_operations.py new file mode 100644 index 000000000000..459e4ed70312 --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_database_operations.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.kusto import KustoManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestKustoManagementDatabaseOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(KustoManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_invite_follower(self, resource_group): + response = self.client.database.invite_follower( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + parameters={ + "inviteeEmail": "str", + "tableLevelSharingProperties": { + "externalTablesToExclude": ["str"], + "externalTablesToInclude": ["str"], + "functionsToExclude": ["str"], + "functionsToInclude": ["str"], + "materializedViewsToExclude": ["str"], + "materializedViewsToInclude": ["str"], + "tablesToExclude": ["str"], + "tablesToInclude": ["str"], + }, + }, + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_database_operations_async.py b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_database_operations_async.py new file mode 100644 index 000000000000..25cccec45e9d --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_database_operations_async.py @@ -0,0 +1,46 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.kusto.aio import KustoManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestKustoManagementDatabaseOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(KustoManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_invite_follower(self, resource_group): + response = await self.client.database.invite_follower( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + parameters={ + "inviteeEmail": "str", + "tableLevelSharingProperties": { + "externalTablesToExclude": ["str"], + "externalTablesToInclude": ["str"], + "functionsToExclude": ["str"], + "functionsToInclude": ["str"], + "materializedViewsToExclude": ["str"], + "materializedViewsToInclude": ["str"], + "tablesToExclude": ["str"], + "tablesToInclude": ["str"], + }, + }, + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_database_principal_assignments_operations.py b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_database_principal_assignments_operations.py new file mode 100644 index 000000000000..5d101a419a63 --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_database_principal_assignments_operations.py @@ -0,0 +1,104 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.kusto import KustoManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestKustoManagementDatabasePrincipalAssignmentsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(KustoManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_check_name_availability(self, resource_group): + response = self.client.database_principal_assignments.check_name_availability( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + principal_assignment_name={ + "name": "str", + "type": "Microsoft.Kusto/clusters/databases/principalAssignments", + }, + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.database_principal_assignments.get( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + principal_assignment_name="str", + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.database_principal_assignments.begin_create_or_update( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + principal_assignment_name="str", + parameters={ + "aadObjectId": "str", + "id": "str", + "name": "str", + "principalId": "str", + "principalName": "str", + "principalType": "str", + "provisioningState": "str", + "role": "str", + "tenantId": "str", + "tenantName": "str", + "type": "str", + }, + api_version="2024-04-13", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.database_principal_assignments.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + principal_assignment_name="str", + api_version="2024-04-13", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.database_principal_assignments.list( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + api_version="2024-04-13", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_database_principal_assignments_operations_async.py b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_database_principal_assignments_operations_async.py new file mode 100644 index 000000000000..eb5d7bec0658 --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_database_principal_assignments_operations_async.py @@ -0,0 +1,109 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.kusto.aio import KustoManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestKustoManagementDatabasePrincipalAssignmentsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(KustoManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_check_name_availability(self, resource_group): + response = await self.client.database_principal_assignments.check_name_availability( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + principal_assignment_name={ + "name": "str", + "type": "Microsoft.Kusto/clusters/databases/principalAssignments", + }, + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.database_principal_assignments.get( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + principal_assignment_name="str", + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.database_principal_assignments.begin_create_or_update( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + principal_assignment_name="str", + parameters={ + "aadObjectId": "str", + "id": "str", + "name": "str", + "principalId": "str", + "principalName": "str", + "principalType": "str", + "provisioningState": "str", + "role": "str", + "tenantId": "str", + "tenantName": "str", + "type": "str", + }, + api_version="2024-04-13", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.database_principal_assignments.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + principal_assignment_name="str", + api_version="2024-04-13", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.database_principal_assignments.list( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + api_version="2024-04-13", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_databases_operations.py b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_databases_operations.py new file mode 100644 index 000000000000..e3fa7498b5d5 --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_databases_operations.py @@ -0,0 +1,215 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.kusto import KustoManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestKustoManagementDatabasesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(KustoManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_check_name_availability(self, resource_group): + response = self.client.databases.check_name_availability( + resource_group_name=resource_group.name, + cluster_name="str", + resource_name={"name": "str", "type": "str"}, + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_cluster(self, resource_group): + response = self.client.databases.list_by_cluster( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-04-13", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.databases.get( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.databases.begin_create_or_update( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + parameters={ + "kind": "ReadOnlyFollowing", + "attachedDatabaseConfigurationName": "str", + "databaseShareOrigin": "str", + "hotCachePeriod": "1 day, 0:00:00", + "id": "str", + "leaderClusterResourceId": "str", + "location": "str", + "name": "str", + "originalDatabaseName": "str", + "principalsModificationKind": "str", + "provisioningState": "str", + "softDeletePeriod": "1 day, 0:00:00", + "statistics": {"size": 0.0}, + "suspensionDetails": {"suspensionStartDate": "2020-02-20 00:00:00"}, + "tableLevelSharingProperties": { + "externalTablesToExclude": ["str"], + "externalTablesToInclude": ["str"], + "functionsToExclude": ["str"], + "functionsToInclude": ["str"], + "materializedViewsToExclude": ["str"], + "materializedViewsToInclude": ["str"], + "tablesToExclude": ["str"], + "tablesToInclude": ["str"], + }, + "type": "str", + }, + api_version="2024-04-13", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.databases.begin_update( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + parameters={ + "kind": "ReadOnlyFollowing", + "attachedDatabaseConfigurationName": "str", + "databaseShareOrigin": "str", + "hotCachePeriod": "1 day, 0:00:00", + "id": "str", + "leaderClusterResourceId": "str", + "location": "str", + "name": "str", + "originalDatabaseName": "str", + "principalsModificationKind": "str", + "provisioningState": "str", + "softDeletePeriod": "1 day, 0:00:00", + "statistics": {"size": 0.0}, + "suspensionDetails": {"suspensionStartDate": "2020-02-20 00:00:00"}, + "tableLevelSharingProperties": { + "externalTablesToExclude": ["str"], + "externalTablesToInclude": ["str"], + "functionsToExclude": ["str"], + "functionsToInclude": ["str"], + "materializedViewsToExclude": ["str"], + "materializedViewsToInclude": ["str"], + "tablesToExclude": ["str"], + "tablesToInclude": ["str"], + }, + "type": "str", + }, + api_version="2024-04-13", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.databases.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + api_version="2024-04-13", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_principals(self, resource_group): + response = self.client.databases.list_principals( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + api_version="2024-04-13", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_add_principals(self, resource_group): + response = self.client.databases.add_principals( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + database_principals_to_add={ + "value": [ + { + "name": "str", + "role": "str", + "type": "str", + "appId": "str", + "email": "str", + "fqn": "str", + "tenantName": "str", + } + ] + }, + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_remove_principals(self, resource_group): + response = self.client.databases.remove_principals( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + database_principals_to_remove={ + "value": [ + { + "name": "str", + "role": "str", + "type": "str", + "appId": "str", + "email": "str", + "fqn": "str", + "tenantName": "str", + } + ] + }, + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_databases_operations_async.py b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_databases_operations_async.py new file mode 100644 index 000000000000..410cc7a0aa8c --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_databases_operations_async.py @@ -0,0 +1,222 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.kusto.aio import KustoManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestKustoManagementDatabasesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(KustoManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_check_name_availability(self, resource_group): + response = await self.client.databases.check_name_availability( + resource_group_name=resource_group.name, + cluster_name="str", + resource_name={"name": "str", "type": "str"}, + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_cluster(self, resource_group): + response = self.client.databases.list_by_cluster( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-04-13", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.databases.get( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.databases.begin_create_or_update( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + parameters={ + "kind": "ReadOnlyFollowing", + "attachedDatabaseConfigurationName": "str", + "databaseShareOrigin": "str", + "hotCachePeriod": "1 day, 0:00:00", + "id": "str", + "leaderClusterResourceId": "str", + "location": "str", + "name": "str", + "originalDatabaseName": "str", + "principalsModificationKind": "str", + "provisioningState": "str", + "softDeletePeriod": "1 day, 0:00:00", + "statistics": {"size": 0.0}, + "suspensionDetails": {"suspensionStartDate": "2020-02-20 00:00:00"}, + "tableLevelSharingProperties": { + "externalTablesToExclude": ["str"], + "externalTablesToInclude": ["str"], + "functionsToExclude": ["str"], + "functionsToInclude": ["str"], + "materializedViewsToExclude": ["str"], + "materializedViewsToInclude": ["str"], + "tablesToExclude": ["str"], + "tablesToInclude": ["str"], + }, + "type": "str", + }, + api_version="2024-04-13", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.databases.begin_update( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + parameters={ + "kind": "ReadOnlyFollowing", + "attachedDatabaseConfigurationName": "str", + "databaseShareOrigin": "str", + "hotCachePeriod": "1 day, 0:00:00", + "id": "str", + "leaderClusterResourceId": "str", + "location": "str", + "name": "str", + "originalDatabaseName": "str", + "principalsModificationKind": "str", + "provisioningState": "str", + "softDeletePeriod": "1 day, 0:00:00", + "statistics": {"size": 0.0}, + "suspensionDetails": {"suspensionStartDate": "2020-02-20 00:00:00"}, + "tableLevelSharingProperties": { + "externalTablesToExclude": ["str"], + "externalTablesToInclude": ["str"], + "functionsToExclude": ["str"], + "functionsToInclude": ["str"], + "materializedViewsToExclude": ["str"], + "materializedViewsToInclude": ["str"], + "tablesToExclude": ["str"], + "tablesToInclude": ["str"], + }, + "type": "str", + }, + api_version="2024-04-13", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.databases.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + api_version="2024-04-13", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_principals(self, resource_group): + response = self.client.databases.list_principals( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + api_version="2024-04-13", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_add_principals(self, resource_group): + response = await self.client.databases.add_principals( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + database_principals_to_add={ + "value": [ + { + "name": "str", + "role": "str", + "type": "str", + "appId": "str", + "email": "str", + "fqn": "str", + "tenantName": "str", + } + ] + }, + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_remove_principals(self, resource_group): + response = await self.client.databases.remove_principals( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + database_principals_to_remove={ + "value": [ + { + "name": "str", + "role": "str", + "type": "str", + "appId": "str", + "email": "str", + "fqn": "str", + "tenantName": "str", + } + ] + }, + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_managed_private_endpoints_operations.py b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_managed_private_endpoints_operations.py new file mode 100644 index 000000000000..3822124f1041 --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_managed_private_endpoints_operations.py @@ -0,0 +1,132 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.kusto import KustoManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestKustoManagementManagedPrivateEndpointsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(KustoManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_check_name_availability(self, resource_group): + response = self.client.managed_private_endpoints.check_name_availability( + resource_group_name=resource_group.name, + cluster_name="str", + resource_name={"name": "str", "type": "Microsoft.Kusto/clusters/managedPrivateEndpoints"}, + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.managed_private_endpoints.list( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-04-13", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.managed_private_endpoints.get( + resource_group_name=resource_group.name, + cluster_name="str", + managed_private_endpoint_name="str", + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.managed_private_endpoints.begin_create_or_update( + resource_group_name=resource_group.name, + cluster_name="str", + managed_private_endpoint_name="str", + parameters={ + "groupId": "str", + "id": "str", + "name": "str", + "privateLinkResourceId": "str", + "privateLinkResourceRegion": "str", + "provisioningState": "str", + "requestMessage": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-04-13", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.managed_private_endpoints.begin_update( + resource_group_name=resource_group.name, + cluster_name="str", + managed_private_endpoint_name="str", + parameters={ + "groupId": "str", + "id": "str", + "name": "str", + "privateLinkResourceId": "str", + "privateLinkResourceRegion": "str", + "provisioningState": "str", + "requestMessage": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-04-13", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.managed_private_endpoints.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + managed_private_endpoint_name="str", + api_version="2024-04-13", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_managed_private_endpoints_operations_async.py b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_managed_private_endpoints_operations_async.py new file mode 100644 index 000000000000..d76a88c3e4f7 --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_managed_private_endpoints_operations_async.py @@ -0,0 +1,139 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.kusto.aio import KustoManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestKustoManagementManagedPrivateEndpointsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(KustoManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_check_name_availability(self, resource_group): + response = await self.client.managed_private_endpoints.check_name_availability( + resource_group_name=resource_group.name, + cluster_name="str", + resource_name={"name": "str", "type": "Microsoft.Kusto/clusters/managedPrivateEndpoints"}, + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.managed_private_endpoints.list( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-04-13", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.managed_private_endpoints.get( + resource_group_name=resource_group.name, + cluster_name="str", + managed_private_endpoint_name="str", + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.managed_private_endpoints.begin_create_or_update( + resource_group_name=resource_group.name, + cluster_name="str", + managed_private_endpoint_name="str", + parameters={ + "groupId": "str", + "id": "str", + "name": "str", + "privateLinkResourceId": "str", + "privateLinkResourceRegion": "str", + "provisioningState": "str", + "requestMessage": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-04-13", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.managed_private_endpoints.begin_update( + resource_group_name=resource_group.name, + cluster_name="str", + managed_private_endpoint_name="str", + parameters={ + "groupId": "str", + "id": "str", + "name": "str", + "privateLinkResourceId": "str", + "privateLinkResourceRegion": "str", + "provisioningState": "str", + "requestMessage": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-04-13", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.managed_private_endpoints.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + managed_private_endpoint_name="str", + api_version="2024-04-13", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_operations.py b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_operations.py new file mode 100644 index 000000000000..bf4191553356 --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_operations.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.kusto import KustoManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestKustoManagementOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(KustoManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.operations.list( + api_version="2024-04-13", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_operations_async.py b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_operations_async.py new file mode 100644 index 000000000000..59da2dcf7194 --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_operations_async.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.kusto.aio import KustoManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestKustoManagementOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(KustoManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.operations.list( + api_version="2024-04-13", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_operations_results_location_operations.py b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_operations_results_location_operations.py new file mode 100644 index 000000000000..c65f4479a28e --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_operations_results_location_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.kusto import KustoManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestKustoManagementOperationsResultsLocationOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(KustoManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.operations_results_location.get( + location="str", + operation_id="str", + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_operations_results_location_operations_async.py b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_operations_results_location_operations_async.py new file mode 100644 index 000000000000..19e27ef683f0 --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_operations_results_location_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.kusto.aio import KustoManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestKustoManagementOperationsResultsLocationOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(KustoManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.operations_results_location.get( + location="str", + operation_id="str", + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_operations_results_operations.py b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_operations_results_operations.py new file mode 100644 index 000000000000..f2e75903866b --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_operations_results_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.kusto import KustoManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestKustoManagementOperationsResultsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(KustoManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.operations_results.get( + location="str", + operation_id="str", + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_operations_results_operations_async.py b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_operations_results_operations_async.py new file mode 100644 index 000000000000..83cfb3431754 --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_operations_results_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.kusto.aio import KustoManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestKustoManagementOperationsResultsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(KustoManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.operations_results.get( + location="str", + operation_id="str", + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_private_endpoint_connections_operations.py b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..36e74f499155 --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_private_endpoint_connections_operations.py @@ -0,0 +1,87 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.kusto import KustoManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestKustoManagementPrivateEndpointConnectionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(KustoManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.private_endpoint_connections.list( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-04-13", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.private_endpoint_connections.get( + resource_group_name=resource_group.name, + cluster_name="str", + private_endpoint_connection_name="str", + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.private_endpoint_connections.begin_create_or_update( + resource_group_name=resource_group.name, + cluster_name="str", + private_endpoint_connection_name="str", + parameters={ + "groupId": "str", + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": {"actionsRequired": "str", "description": "str", "status": "str"}, + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-04-13", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.private_endpoint_connections.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + private_endpoint_connection_name="str", + api_version="2024-04-13", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_private_endpoint_connections_operations_async.py b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_private_endpoint_connections_operations_async.py new file mode 100644 index 000000000000..db174034f1cb --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_private_endpoint_connections_operations_async.py @@ -0,0 +1,96 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.kusto.aio import KustoManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestKustoManagementPrivateEndpointConnectionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(KustoManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.private_endpoint_connections.list( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-04-13", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.private_endpoint_connections.get( + resource_group_name=resource_group.name, + cluster_name="str", + private_endpoint_connection_name="str", + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.private_endpoint_connections.begin_create_or_update( + resource_group_name=resource_group.name, + cluster_name="str", + private_endpoint_connection_name="str", + parameters={ + "groupId": "str", + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-04-13", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.private_endpoint_connections.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + private_endpoint_connection_name="str", + api_version="2024-04-13", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_private_link_resources_operations.py b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_private_link_resources_operations.py new file mode 100644 index 000000000000..005445af075e --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_private_link_resources_operations.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.kusto import KustoManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestKustoManagementPrivateLinkResourcesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(KustoManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.private_link_resources.list( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-04-13", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.private_link_resources.get( + resource_group_name=resource_group.name, + cluster_name="str", + private_link_resource_name="str", + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_private_link_resources_operations_async.py b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_private_link_resources_operations_async.py new file mode 100644 index 000000000000..2a90b8c6cc2d --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_private_link_resources_operations_async.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.kusto.aio import KustoManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestKustoManagementPrivateLinkResourcesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(KustoManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.private_link_resources.list( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-04-13", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.private_link_resources.get( + resource_group_name=resource_group.name, + cluster_name="str", + private_link_resource_name="str", + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_sandbox_custom_images_operations.py b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_sandbox_custom_images_operations.py new file mode 100644 index 000000000000..21fd96ea2703 --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_sandbox_custom_images_operations.py @@ -0,0 +1,116 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.kusto import KustoManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestKustoManagementSandboxCustomImagesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(KustoManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_cluster(self, resource_group): + response = self.client.sandbox_custom_images.list_by_cluster( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-04-13", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.sandbox_custom_images.get( + resource_group_name=resource_group.name, + cluster_name="str", + sandbox_custom_image_name="str", + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.sandbox_custom_images.begin_create_or_update( + resource_group_name=resource_group.name, + cluster_name="str", + sandbox_custom_image_name="str", + parameters={ + "baseImageName": "str", + "id": "str", + "language": "str", + "languageVersion": "str", + "name": "str", + "provisioningState": "str", + "requirementsFileContent": "str", + "type": "str", + }, + api_version="2024-04-13", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.sandbox_custom_images.begin_update( + resource_group_name=resource_group.name, + cluster_name="str", + sandbox_custom_image_name="str", + parameters={ + "baseImageName": "str", + "id": "str", + "language": "str", + "languageVersion": "str", + "name": "str", + "provisioningState": "str", + "requirementsFileContent": "str", + "type": "str", + }, + api_version="2024-04-13", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.sandbox_custom_images.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + sandbox_custom_image_name="str", + api_version="2024-04-13", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_check_name_availability(self, resource_group): + response = self.client.sandbox_custom_images.check_name_availability( + resource_group_name=resource_group.name, + cluster_name="str", + resource_name={"name": "str", "type": "Microsoft.Kusto/clusters/sandboxCustomImages"}, + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_sandbox_custom_images_operations_async.py b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_sandbox_custom_images_operations_async.py new file mode 100644 index 000000000000..7f68d87648dc --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_sandbox_custom_images_operations_async.py @@ -0,0 +1,123 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.kusto.aio import KustoManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestKustoManagementSandboxCustomImagesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(KustoManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_cluster(self, resource_group): + response = self.client.sandbox_custom_images.list_by_cluster( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-04-13", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.sandbox_custom_images.get( + resource_group_name=resource_group.name, + cluster_name="str", + sandbox_custom_image_name="str", + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.sandbox_custom_images.begin_create_or_update( + resource_group_name=resource_group.name, + cluster_name="str", + sandbox_custom_image_name="str", + parameters={ + "baseImageName": "str", + "id": "str", + "language": "str", + "languageVersion": "str", + "name": "str", + "provisioningState": "str", + "requirementsFileContent": "str", + "type": "str", + }, + api_version="2024-04-13", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.sandbox_custom_images.begin_update( + resource_group_name=resource_group.name, + cluster_name="str", + sandbox_custom_image_name="str", + parameters={ + "baseImageName": "str", + "id": "str", + "language": "str", + "languageVersion": "str", + "name": "str", + "provisioningState": "str", + "requirementsFileContent": "str", + "type": "str", + }, + api_version="2024-04-13", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.sandbox_custom_images.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + sandbox_custom_image_name="str", + api_version="2024-04-13", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_check_name_availability(self, resource_group): + response = await self.client.sandbox_custom_images.check_name_availability( + resource_group_name=resource_group.name, + cluster_name="str", + resource_name={"name": "str", "type": "Microsoft.Kusto/clusters/sandboxCustomImages"}, + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_scripts_operations.py b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_scripts_operations.py new file mode 100644 index 000000000000..c335cee93106 --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_scripts_operations.py @@ -0,0 +1,144 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.kusto import KustoManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestKustoManagementScriptsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(KustoManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_database(self, resource_group): + response = self.client.scripts.list_by_database( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + api_version="2024-04-13", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.scripts.get( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + script_name="str", + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.scripts.begin_create_or_update( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + script_name="str", + parameters={ + "continueOnErrors": False, + "forceUpdateTag": "str", + "id": "str", + "name": "str", + "principalPermissionsAction": "str", + "provisioningState": "str", + "scriptContent": "str", + "scriptLevel": "str", + "scriptUrl": "str", + "scriptUrlSasToken": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-04-13", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.scripts.begin_update( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + script_name="str", + parameters={ + "continueOnErrors": False, + "forceUpdateTag": "str", + "id": "str", + "name": "str", + "principalPermissionsAction": "str", + "provisioningState": "str", + "scriptContent": "str", + "scriptLevel": "str", + "scriptUrl": "str", + "scriptUrlSasToken": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-04-13", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.scripts.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + script_name="str", + api_version="2024-04-13", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_check_name_availability(self, resource_group): + response = self.client.scripts.check_name_availability( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + script_name={"name": "str", "type": "Microsoft.Kusto/clusters/databases/scripts"}, + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_scripts_operations_async.py b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_scripts_operations_async.py new file mode 100644 index 000000000000..b2b6f35a0be7 --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_scripts_operations_async.py @@ -0,0 +1,151 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.kusto.aio import KustoManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestKustoManagementScriptsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(KustoManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_database(self, resource_group): + response = self.client.scripts.list_by_database( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + api_version="2024-04-13", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.scripts.get( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + script_name="str", + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.scripts.begin_create_or_update( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + script_name="str", + parameters={ + "continueOnErrors": False, + "forceUpdateTag": "str", + "id": "str", + "name": "str", + "principalPermissionsAction": "str", + "provisioningState": "str", + "scriptContent": "str", + "scriptLevel": "str", + "scriptUrl": "str", + "scriptUrlSasToken": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-04-13", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.scripts.begin_update( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + script_name="str", + parameters={ + "continueOnErrors": False, + "forceUpdateTag": "str", + "id": "str", + "name": "str", + "principalPermissionsAction": "str", + "provisioningState": "str", + "scriptContent": "str", + "scriptLevel": "str", + "scriptUrl": "str", + "scriptUrlSasToken": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-04-13", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.scripts.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + script_name="str", + api_version="2024-04-13", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_check_name_availability(self, resource_group): + response = await self.client.scripts.check_name_availability( + resource_group_name=resource_group.name, + cluster_name="str", + database_name="str", + script_name={"name": "str", "type": "Microsoft.Kusto/clusters/databases/scripts"}, + api_version="2024-04-13", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_skus_operations.py b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_skus_operations.py new file mode 100644 index 000000000000..21b0bb2e7f44 --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_skus_operations.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.kusto import KustoManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestKustoManagementSkusOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(KustoManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.skus.list( + location="str", + api_version="2024-04-13", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_skus_operations_async.py b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_skus_operations_async.py new file mode 100644 index 000000000000..d7554e1d1688 --- /dev/null +++ b/sdk/kusto/azure-mgmt-kusto/generated_tests/test_kusto_management_skus_operations_async.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.kusto.aio import KustoManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestKustoManagementSkusOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(KustoManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.skus.list( + location="str", + api_version="2024-04-13", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/kusto/azure-mgmt-kusto/setup.py b/sdk/kusto/azure-mgmt-kusto/setup.py index f97ac536a7e2..8cb66a3f57c9 100644 --- a/sdk/kusto/azure-mgmt-kusto/setup.py +++ b/sdk/kusto/azure-mgmt-kusto/setup.py @@ -53,11 +53,11 @@ "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "License :: OSI Approved :: MIT License", ], zip_safe=False, @@ -74,10 +74,10 @@ "pytyped": ["py.typed"], }, install_requires=[ - "isodate<1.0.0,>=0.6.1", - "azure-common~=1.1", - "azure-mgmt-core>=1.3.2,<2.0.0", - "typing-extensions>=4.3.0; python_version<'3.8.0'", + "isodate>=0.6.1", + "typing-extensions>=4.6.0", + "azure-common>=1.1", + "azure-mgmt-core>=1.3.2", ], - python_requires=">=3.7", + python_requires=">=3.8", )