diff --git a/sdk/synapse/azure-mgmt-synapse/README.md b/sdk/synapse/azure-mgmt-synapse/README.md index 51c0c1e22d29..bed2207d3453 100644 --- a/sdk/synapse/azure-mgmt-synapse/README.md +++ b/sdk/synapse/azure-mgmt-synapse/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure Synapse 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 @@ -45,8 +45,9 @@ client = SynapseManagementClient(credential=DefaultAzureCredential(), subscripti ## Examples - -Code samples for this package can be found at [Synapse Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com and [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples) +Code samples for this package can be found at: +- [Search Synapse Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com +- [Azure Python Mgmt SDK Samples Repo](https://aka.ms/azsdk/python/mgmt/samples) ## Troubleshooting @@ -58,6 +59,3 @@ Code samples for this package can be found at [Synapse Management](https://docs. If you encounter any bugs or have suggestions, please file an issue in the [Issues](https://github.com/Azure/azure-sdk-for-python/issues) section of the project. - - - diff --git a/sdk/synapse/azure-mgmt-synapse/_meta.json b/sdk/synapse/azure-mgmt-synapse/_meta.json index 84a228919657..dd3cf272b5a6 100644 --- a/sdk/synapse/azure-mgmt-synapse/_meta.json +++ b/sdk/synapse/azure-mgmt-synapse/_meta.json @@ -1,11 +1,11 @@ { - "commit": "0e20dd2e4e2a40e83840c30cce2efc4847fd9cb9", + "commit": "0a84f4aba30ba4050bf73302c3a5a521997c889d", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.2", + "autorest": "3.10.2", "use": [ - "@autorest/python@6.2.16", - "@autorest/modelerfour@4.24.3" + "@autorest/python@6.27.4", + "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/synapse/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.2.16 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", + "autorest_command": "autorest specification/synapse/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.27.4 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", "readme": "specification/synapse/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/__init__.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/__init__.py index afa8395596e8..dd517151b012 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/__init__.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._synapse_management_client import SynapseManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._synapse_management_client import SynapseManagementClient # type: ignore from ._version import VERSION __version__ = VERSION try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -21,6 +27,6 @@ __all__ = [ "SynapseManagementClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/_configuration.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/_configuration.py index e2206488fc6e..201d2835a77a 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/_configuration.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/_configuration.py @@ -8,18 +8,16 @@ 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 from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class SynapseManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class SynapseManagementClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for SynapseManagementClient. Note that all parameters used to create this instance are saved as instance @@ -32,7 +30,6 @@ class SynapseManagementClientConfiguration(Configuration): # pylint: disable=to """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(SynapseManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -42,6 +39,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.subscription_id = subscription_id self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-synapse/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -50,9 +48,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/synapse/azure-mgmt-synapse/azure/mgmt/synapse/_patch.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/_patch.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/_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/synapse/azure-mgmt-synapse/azure/mgmt/synapse/_serialization.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/_serialization.py index f17c068e833e..b24ab2885450 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/_serialization.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/_serialization.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -24,7 +25,6 @@ # # -------------------------------------------------------------------------- -# pylint: skip-file # pyright: reportUnnecessaryTypeIgnoreComment=false from base64 import b64decode, b64encode @@ -52,7 +52,6 @@ MutableMapping, Type, List, - Mapping, ) try: @@ -63,8 +62,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") @@ -91,6 +90,8 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: :param data: Input, could be bytes or stream (will be decoded with UTF8) or text :type data: str or bytes or IO :param str content_type: The content type. + :return: The deserialized data. + :rtype: object """ if hasattr(data, "read"): # Assume a stream @@ -112,7 +113,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: try: return json.loads(data_as_str) except ValueError as err: - raise DeserializationError("JSON is invalid: {}".format(err), err) + raise DeserializationError("JSON is invalid: {}".format(err), err) from err elif "xml" in (content_type or []): try: @@ -124,7 +125,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 +144,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 @@ -153,6 +156,11 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], Use bytes and headers to NOT use any requests/aiohttp or whatever specific implementation. Headers will tested for "content-type" + + :param bytes body_bytes: The body of the response. + :param dict headers: The headers of the response. + :returns: The deserialized data. + :rtype: object """ # Try to use content-type from headers if available content_type = None @@ -170,13 +178,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: @@ -189,15 +190,30 @@ class UTC(datetime.tzinfo): """Time Zone info for handling UTC""" def utcoffset(self, dt): - """UTF offset for UTC is 0.""" + """UTF offset for UTC is 0. + + :param datetime.datetime dt: The datetime + :returns: The offset + :rtype: datetime.timedelta + """ return datetime.timedelta(0) def tzname(self, dt): - """Timestamp representation.""" + """Timestamp representation. + + :param datetime.datetime dt: The datetime + :returns: The timestamp representation + :rtype: str + """ return "Z" def dst(self, dt): - """No daylight saving for UTC.""" + """No daylight saving for UTC. + + :param datetime.datetime dt: The datetime + :returns: The daylight saving time + :rtype: datetime.timedelta + """ return datetime.timedelta(hours=1) @@ -211,7 +227,7 @@ class _FixedOffset(datetime.tzinfo): # type: ignore :param datetime.timedelta offset: offset in timedelta format """ - def __init__(self, offset): + def __init__(self, offset) -> None: self.__offset = offset def utcoffset(self, dt): @@ -240,24 +256,26 @@ def __getinitargs__(self): _FLATTEN = re.compile(r"(? None: - self.additional_properties: Dict[str, Any] = {} - for k in kwargs: + self.additional_properties: Optional[Dict[str, Any]] = {} + for k in kwargs: # pylint: disable=consider-using-dict-items 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__) elif k in self._validation and self._validation[k].get("readonly", False): @@ -305,13 +330,23 @@ def __init__(self, **kwargs: Any) -> None: setattr(self, k, kwargs[k]) def __eq__(self, other: Any) -> bool: - """Compare objects by comparing all attributes.""" + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are equal + :rtype: bool + """ if isinstance(other, self.__class__): return self.__dict__ == other.__dict__ return False def __ne__(self, other: Any) -> bool: - """Compare objects by comparing all attributes.""" + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are not equal + :rtype: bool + """ return not self.__eq__(other) def __str__(self) -> str: @@ -331,7 +366,11 @@ def is_xml_model(cls) -> bool: @classmethod def _create_xml_node(cls): - """Create XML node.""" + """Create XML node. + + :returns: The XML node + :rtype: xml.etree.ElementTree.Element + """ try: xml_map = cls._xml_map # type: ignore except AttributeError: @@ -340,7 +379,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 +390,9 @@ 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( # type: ignore # pylint: disable=protected-access + self, keep_readonly=keep_readonly, **kwargs + ) def as_dict( self, @@ -385,12 +426,15 @@ def my_key_transformer(key, attr_desc, value): If you want XML serialization, you can pass the kwargs is_xml=True. + :param bool keep_readonly: If you want to serialize the readonly attributes :param function key_transformer: A key transformer function. :returns: A dict JSON compatible object :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs + ) @classmethod def _infer_class_models(cls): @@ -400,7 +444,7 @@ def _infer_class_models(cls): client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} if cls.__name__ not in client_models: raise ValueError("Not Autorest generated code") - except Exception: + except Exception: # pylint: disable=broad-exception-caught # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. client_models = {cls.__name__: cls} return client_models @@ -413,9 +457,10 @@ def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = N :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model :raises: DeserializationError if something went wrong + :rtype: ModelType """ 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( @@ -431,9 +476,11 @@ def from_dict( and last_rest_key_case_insensitive_extractor) :param dict data: A dict using RestAPI structure + :param function key_extractors: A key extractor function. :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model :raises: DeserializationError if something went wrong + :rtype: ModelType """ deserializer = Deserializer(cls._infer_class_models()) deserializer.key_extractors = ( # type: ignore @@ -445,7 +492,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): @@ -453,21 +500,25 @@ def _flatten_subtype(cls, key, objects): return {} result = dict(cls._subtype_map[key]) for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) + result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access return result @classmethod def _classify(cls, response, objects): """Check the class _subtype_map for any child classes. We want to ignore any inherited _subtype_maps. - Remove the polymorphic key from the initial data. + + :param dict response: The initial data + :param dict objects: The class objects + :returns: The class to be used + :rtype: class """ for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): subtype_value = None if not isinstance(response, ET.Element): rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.pop(rest_api_response_key, None) or response.pop(subtype_key, None) + subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) else: subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) if subtype_value: @@ -506,11 +557,13 @@ def _decode_attribute_map_key(key): inside the received data. :param str key: A key string from the generated code + :returns: The decoded key + :rtype: str """ return key.replace("\\.", ".") -class Serializer(object): +class Serializer: # pylint: disable=too-many-public-methods """Request object model serializer.""" basic_types = {str: "str", int: "int", bool: "bool", float: "float"} @@ -545,7 +598,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) -> None: self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -561,17 +614,20 @@ 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 - def _serialize(self, target_obj, data_type=None, **kwargs): + def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals + self, target_obj, data_type=None, **kwargs + ): """Serialize data into a string according to type. - :param target_obj: The data to be serialized. + :param object target_obj: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str, dict :raises: SerializationError if serialization fails. + :returns: The serialized data. """ key_transformer = kwargs.get("key_transformer", self.key_transformer) keep_readonly = kwargs.get("keep_readonly", False) @@ -597,12 +653,14 @@ def _serialize(self, target_obj, data_type=None, **kwargs): serialized = {} if is_xml_model_serialization: - serialized = target_obj._create_xml_node() + serialized = target_obj._create_xml_node() # pylint: disable=protected-access try: - attributes = target_obj._attribute_map + attributes = target_obj._attribute_map # pylint: disable=protected-access for attr, attr_desc in attributes.items(): attr_name = attr - if not keep_readonly and target_obj._validation.get(attr_name, {}).get("readonly", False): + if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access + attr_name, {} + ).get("readonly", False): continue if attr_name == "additional_properties" and attr_desc["key"] == "": @@ -629,7 +687,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): if xml_desc.get("attr", False): if xml_ns: ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) serialized.set(xml_name, new_attr) # type: ignore continue if xml_desc.get("text", False): @@ -638,7 +696,8 @@ def _serialize(self, target_obj, data_type=None, **kwargs): if isinstance(new_attr, list): serialized.extend(new_attr) # type: ignore elif isinstance(new_attr, ET.Element): - # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. + # If the down XML has no XML/Name, + # we MUST replace the tag with the local tag. But keeping the namespaces. if "name" not in getattr(orig_attr, "_xml_map", {}): splitted_tag = new_attr.tag.split("}") if len(splitted_tag) == 2: # Namespace @@ -649,7 +708,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 @@ -662,23 +721,24 @@ def _serialize(self, target_obj, data_type=None, **kwargs): _serialized.update(_new_attr) # type: ignore _new_attr = _new_attr[k] # type: ignore _serialized = _serialized[k] - except ValueError: - continue + except ValueError as err: + if isinstance(err, SerializationError): + raise except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise_with_traceback(SerializationError, msg, err) - else: - return serialized + raise SerializationError(msg) from err + return serialized def body(self, data, data_type, **kwargs): """Serialize data intended for a request body. - :param data: The data to be serialized. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: dict :raises: SerializationError if serialization fails. :raises: ValueError if data is None + :returns: The serialized request body """ # Just in case this is a dict @@ -707,18 +767,20 @@ def body(self, data, data_type, **kwargs): attribute_key_case_insensitive_extractor, last_rest_key_case_insensitive_extractor, ] - data = deserializer._deserialize(data_type, data) + data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access 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) def url(self, name, data, data_type, **kwargs): """Serialize data intended for a URL path. - :param data: The data to be serialized. + :param str name: The name of the URL path parameter. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str + :returns: The serialized URL path :raises: TypeError if serialization fails. :raises: ValueError if data is None """ @@ -729,30 +791,30 @@ 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: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return output + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return output def query(self, name, data, data_type, **kwargs): """Serialize data intended for a URL query. - :param data: The data to be serialized. + :param str name: The name of the query parameter. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. - :rtype: str + :rtype: str, list :raises: TypeError if serialization fails. :raises: ValueError if data is None + :returns: The serialized query parameter """ try: # Treat the list aside, since we don't want to encode the div separator if data_type.startswith("["): internal_data_type = data_type[1:-1] - data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] - if not kwargs.get("skip_quote", False): - data = [quote(str(d), safe="") for d in data] - return str(self.serialize_iter(data, internal_data_type, **kwargs)) + do_quote = not kwargs.get("skip_quote", False) + 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) @@ -762,19 +824,20 @@ def query(self, name, data, data_type, **kwargs): output = str(output) else: output = quote(str(output), safe="") - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return str(output) + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) def header(self, name, data, data_type, **kwargs): """Serialize data intended for a request header. - :param data: The data to be serialized. + :param str name: The name of the header. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str :raises: TypeError if serialization fails. :raises: ValueError if data is None + :returns: The serialized header """ try: if data_type in ["[str]"]: @@ -783,32 +846,31 @@ def header(self, name, data, data_type, **kwargs): output = self.serialize_data(data, data_type, **kwargs) if data_type == "bool": output = json.dumps(output) - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return str(output) + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) def serialize_data(self, data, data_type, **kwargs): """Serialize generic data according to supplied data type. - :param data: The data to be serialized. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. - :param bool required: Whether it's essential that the data not be - empty or None :raises: AttributeError if required data is None. :raises: ValueError if data is None :raises: SerializationError if serialization fails. + :returns: The serialized data. + :rtype: str, int, float, bool, dict, list """ if data is None: 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) - elif data_type in self.serialize_type: + if data_type in self.serialize_type: return self.serialize_type[data_type](data, **kwargs) # If dependencies is empty, try with current data class @@ -823,12 +885,11 @@ 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) - else: - return self._serialize(data, **kwargs) + raise SerializationError(msg.format(data, data_type)) from err + return self._serialize(data, **kwargs) @classmethod - def _get_custom_serializers(cls, data_type, **kwargs): + def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) if custom_serializer: return custom_serializer @@ -844,23 +905,26 @@ def serialize_basic(cls, data, data_type, **kwargs): - basic_types_serializers dict[str, callable] : If set, use the callable as serializer - is_xml bool : If set, use xml_basic_types_serializers - :param data: Object to be serialized. + :param obj data: Object to be serialized. :param str data_type: Type of object in the iterable. + :rtype: str, int, float, bool + :return: serialized object """ custom_serializer = cls._get_custom_serializers(data_type, **kwargs) if custom_serializer: return custom_serializer(data) if data_type == "str": return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec + return eval(data_type)(data) # nosec # pylint: disable=eval-used @classmethod def serialize_unicode(cls, data): """Special handling for serializing unicode strings in Py2. Encode to UTF-8 if unicode, otherwise handle as a str. - :param data: Object to be serialized. + :param str data: Object to be serialized. :rtype: str + :return: serialized object """ try: # If I received an enum, return its value return data.value @@ -874,8 +938,7 @@ def serialize_unicode(cls, data): return data except NameError: return str(data) - else: - return str(data) + return str(data) def serialize_iter(self, data, iter_type, div=None, **kwargs): """Serialize iterable. @@ -885,13 +948,13 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): serialization_ctxt['type'] should be same as data_type. - is_xml bool : If set, serialize as XML - :param list attr: Object to be serialized. + :param list data: Object to be serialized. :param str iter_type: Type of object in the iterable. - :param bool required: Whether the objects in the iterable must - not be None or empty. :param str div: If set, this str will be used to combine the elements in the iterable into a combined string. Default is 'None'. + Defaults to False. :rtype: list, str + :return: serialized iterable """ if isinstance(data, str): raise SerializationError("Refuse str type as a valid iter type.") @@ -903,9 +966,14 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): for d in data: try: serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized.append(None) + if kwargs.get("do_quote", False): + serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] + if div: serialized = ["" if s is None else str(s) for s in serialized] serialized = div.join(serialized) @@ -941,16 +1009,17 @@ def serialize_dict(self, attr, dict_type, **kwargs): :param dict attr: Object to be serialized. :param str dict_type: Type of object in the dictionary. - :param bool required: Whether the objects in the dictionary must - not be None or empty. :rtype: dict + :return: serialized dictionary """ serialization_ctxt = kwargs.get("serialization_ctxt", {}) serialized = {} for key, value in attr.items(): try: serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized[self.serialize_unicode(key)] = None if "xml" in serialization_ctxt: @@ -965,7 +1034,7 @@ def serialize_dict(self, attr, dict_type, **kwargs): return serialized - def serialize_object(self, attr, **kwargs): + def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements """Serialize a generic object. This will be handled as a dictionary. If object passed in is not a basic type (str, int, float, dict, list) it will simply be @@ -973,6 +1042,7 @@ def serialize_object(self, attr, **kwargs): :param dict attr: Object to be serialized. :rtype: dict or str + :return: serialized object """ if attr is None: return None @@ -983,7 +1053,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) @@ -997,7 +1067,7 @@ def serialize_object(self, attr, **kwargs): return self.serialize_decimal(attr) # If it's a model or I know this dependency, serialize as a Model - elif obj_type in self.dependencies.values() or isinstance(attr, Model): + if obj_type in self.dependencies.values() or isinstance(attr, Model): return self._serialize(attr) if obj_type == dict: @@ -1028,56 +1098,61 @@ def serialize_enum(attr, enum_obj=None): try: enum_obj(result) # type: ignore return result - except ValueError: + except ValueError as exc: for enum_value in enum_obj: # type: ignore if enum_value.value.lower() == str(attr).lower(): return enum_value.value error = "{!r} is not valid value for enum {!r}" - raise SerializationError(error.format(attr, enum_obj)) + raise SerializationError(error.format(attr, enum_obj)) from exc @staticmethod - def serialize_bytearray(attr, **kwargs): + def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument """Serialize bytearray into base-64 string. - :param attr: Object to be serialized. + :param str attr: Object to be serialized. :rtype: str + :return: serialized base64 """ return b64encode(attr).decode() @staticmethod - def serialize_base64(attr, **kwargs): + def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument """Serialize str into base-64 string. - :param attr: Object to be serialized. + :param str attr: Object to be serialized. :rtype: str + :return: serialized base64 """ encoded = b64encode(attr).decode("ascii") return encoded.strip("=").replace("+", "-").replace("/", "_") @staticmethod - def serialize_decimal(attr, **kwargs): + def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument """Serialize Decimal object to float. - :param attr: Object to be serialized. + :param decimal attr: Object to be serialized. :rtype: float + :return: serialized decimal """ return float(attr) @staticmethod - def serialize_long(attr, **kwargs): + def serialize_long(attr, **kwargs): # pylint: disable=unused-argument """Serialize long (Py2) or int (Py3). - :param attr: Object to be serialized. + :param int attr: Object to be serialized. :rtype: int/long + :return: serialized long """ return _long_type(attr) @staticmethod - def serialize_date(attr, **kwargs): + def serialize_date(attr, **kwargs): # pylint: disable=unused-argument """Serialize Date object into ISO-8601 formatted string. :param Date attr: Object to be serialized. :rtype: str + :return: serialized date """ if isinstance(attr, str): attr = isodate.parse_date(attr) @@ -1085,11 +1160,12 @@ def serialize_date(attr, **kwargs): return t @staticmethod - def serialize_time(attr, **kwargs): + def serialize_time(attr, **kwargs): # pylint: disable=unused-argument """Serialize Time object into ISO-8601 formatted string. :param datetime.time attr: Object to be serialized. :rtype: str + :return: serialized time """ if isinstance(attr, str): attr = isodate.parse_time(attr) @@ -1099,30 +1175,32 @@ def serialize_time(attr, **kwargs): return t @staticmethod - def serialize_duration(attr, **kwargs): + def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument """Serialize TimeDelta object into ISO-8601 formatted string. :param TimeDelta attr: Object to be serialized. :rtype: str + :return: serialized duration """ if isinstance(attr, str): attr = isodate.parse_duration(attr) return isodate.duration_isoformat(attr) @staticmethod - def serialize_rfc(attr, **kwargs): + def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument """Serialize Datetime object into RFC-1123 formatted string. :param Datetime attr: Object to be serialized. :rtype: str :raises: TypeError if format invalid. + :return: serialized rfc """ try: if not attr.tzinfo: _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") utc = attr.utctimetuple() - except AttributeError: - raise TypeError("RFC1123 object must be valid Datetime object.") + except AttributeError as exc: + raise TypeError("RFC1123 object must be valid Datetime object.") from exc return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( Serializer.days[utc.tm_wday], @@ -1135,12 +1213,13 @@ def serialize_rfc(attr, **kwargs): ) @staticmethod - def serialize_iso(attr, **kwargs): + def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument """Serialize Datetime object into ISO-8601 formatted string. :param Datetime attr: Object to be serialized. :rtype: str :raises: SerializationError if format invalid. + :return: serialized iso """ if isinstance(attr, str): attr = isodate.parse_datetime(attr) @@ -1160,19 +1239,20 @@ 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): + def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument """Serialize Datetime object into IntTime format. This is represented as seconds. :param Datetime attr: Object to be serialized. :rtype: int :raises: SerializationError if format invalid + :return: serialied unix """ if isinstance(attr, int): return attr @@ -1180,11 +1260,11 @@ def serialize_unix(attr, **kwargs): if not attr.tzinfo: _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") return int(calendar.timegm(attr.utctimetuple())) - except AttributeError: - raise TypeError("Unix time object must be valid Datetime object.") + except AttributeError as exc: + raise TypeError("Unix time object must be valid Datetime object.") from exc -def rest_key_extractor(attr, attr_desc, data): +def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument key = attr_desc["key"] working_data = data @@ -1199,14 +1279,15 @@ 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:]) return working_data.get(key) -def rest_key_case_insensitive_extractor(attr, attr_desc, data): +def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements + attr, attr_desc, data +): key = attr_desc["key"] working_data = data @@ -1220,7 +1301,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:]) @@ -1228,17 +1308,29 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data): return attribute_key_case_insensitive_extractor(key, None, working_data) -def last_rest_key_extractor(attr, attr_desc, data): - """Extract the attribute in "data" based on the last part of the JSON path key.""" +def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + """Extract the attribute in "data" based on the last part of the JSON path key. + + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute + """ key = attr_desc["key"] dict_keys = _FLATTEN.split(key) return attribute_key_extractor(dict_keys[-1], None, data) -def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument """Extract the attribute in "data" based on the last part of the JSON path key. This is the case insensitive version of "last_rest_key_extractor" + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute """ key = attr_desc["key"] dict_keys = _FLATTEN.split(key) @@ -1271,11 +1363,11 @@ def _extract_name_from_internal_type(internal_type): xml_name = internal_type_xml_map.get("name", internal_type.__name__) xml_ns = internal_type_xml_map.get("ns", None) if xml_ns: - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) return xml_name -def xml_key_extractor(attr, attr_desc, data): +def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements if isinstance(data, dict): return None @@ -1295,7 +1387,7 @@ def xml_key_extractor(attr, attr_desc, data): # Integrate namespace if necessary xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) if xml_ns: - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) # If it's an attribute, that's simple if xml_desc.get("attr", False): @@ -1327,22 +1419,21 @@ def xml_key_extractor(attr, attr_desc, data): if is_iter_type: if is_wrapped: return None # is_wrapped no node, we want None - else: - return [] # not wrapped, assume empty list + return [] # not wrapped, assume empty list return None # Assume it's not there, maybe an optional node. # If is_iter_type and not wrapped, return all found children if is_iter_type: if not is_wrapped: return children - else: # Iter and wrapped, should have found one node only (the wrap one) - if len(children) != 1: - raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( - xml_name - ) + # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + xml_name ) - return list(children[0]) # Might be empty list and that's ok. + ) + return list(children[0]) # Might be empty list and that's ok. # Here it's not a itertype, we should have found one element only or empty if len(children) > 1: @@ -1350,7 +1441,7 @@ def xml_key_extractor(attr, attr_desc, data): return children[0] -class Deserializer(object): +class Deserializer: """Response object model deserializer. :param dict classes: Class type dictionary for deserializing complex types. @@ -1359,9 +1450,9 @@ class Deserializer(object): basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") + valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\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) -> None: self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1381,7 +1472,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 @@ -1399,11 +1490,12 @@ def __call__(self, target_obj, response_data, content_type=None): :param str content_type: Swagger "produces" if available. :raises: DeserializationError if deserialization fails. :return: Deserialized object. + :rtype: object """ data = self._unpack_content(response_data, content_type) return self._deserialize(target_obj, data) - def _deserialize(self, target_obj, data): + def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements """Call the deserializer on a model. Data needs to be already deserialized as JSON or XML ElementTree @@ -1412,12 +1504,13 @@ def _deserialize(self, target_obj, data): :param object data: Object to deserialize. :raises: DeserializationError if deserialization fails. :return: Deserialized object. + :rtype: object """ # This is already a model, go recursive just in case if hasattr(data, "_attribute_map"): constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] try: - for attr, mapconfig in data._attribute_map.items(): + for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access if attr in constants: continue value = getattr(data, attr) @@ -1434,15 +1527,15 @@ 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): + if 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 + attributes = response._attribute_map # type: ignore # pylint: disable=protected-access d_attrs = {} for attr, attr_desc in attributes.items(): # Check empty string. If it's not empty, someone has a real "additionalProperties"... @@ -1471,10 +1564,9 @@ 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) - else: - additional_properties = self._build_additional_properties(attributes, data) - return self._instantiate_model(response, d_attrs, additional_properties) + raise DeserializationError(msg) from err + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) def _build_additional_properties(self, attribute_map, data): if not self.additional_properties_detection: @@ -1501,18 +1593,20 @@ def _classify_target(self, target, data): :param str target: The target object type to deserialize to. :param str/dict data: The response data to deserialize. + :return: The classified target object and its class name. + :rtype: tuple """ 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 # pylint: disable=protected-access except AttributeError: pass # Target is not a Model, no classify return target, target.__class__.__name__ # type: ignore @@ -1527,10 +1621,12 @@ def failsafe_deserialize(self, target_obj, data, content_type=None): :param str target_obj: The target object type to deserialize to. :param str/dict data: The response data to deserialize. :param str content_type: Swagger "produces" if available. + :return: Deserialized object. + :rtype: object """ try: return self(target_obj, data, content_type=content_type) - except: + except: # pylint: disable=bare-except _LOGGER.debug( "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True ) @@ -1548,10 +1644,12 @@ def _unpack_content(raw_data, content_type=None): If raw_data is something else, bypass all logic and return it directly. - :param raw_data: Data to be processed. - :param content_type: How to parse if raw_data is a string/bytes. + :param obj raw_data: Data to be processed. + :param str content_type: How to parse if raw_data is a string/bytes. :raises JSONDecodeError: If JSON is requested and parsing is impossible. :raises UnicodeDecodeError: If bytes is not UTF8 + :rtype: object + :return: Unpacked content. """ # Assume this is enough to detect a Pipeline Response without importing it context = getattr(raw_data, "context", {}) @@ -1568,31 +1666,42 @@ 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 def _instantiate_model(self, response, attrs, additional_properties=None): """Instantiate a response model passing in deserialized args. - :param response: The response model class. - :param d_attrs: The deserialized response attributes. + :param Response response: The response model class. + :param dict attrs: The deserialized response attributes. + :param dict additional_properties: Additional properties to be set. + :rtype: Response + :return: The instantiated response model. """ if callable(response): subtype = getattr(response, "_subtype_map", {}) try: - readonly = [k for k, v in response._validation.items() if v.get("readonly")] - const = [k for k, v in response._validation.items() if v.get("constant")] + readonly = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("readonly") + ] + const = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("constant") + ] kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} response_obj = response(**kwargs) for attr in readonly: setattr(response_obj, attr, attrs.get(attr)) if additional_properties: - response_obj.additional_properties = additional_properties + response_obj.additional_properties = additional_properties # type: ignore return response_obj except TypeError as err: msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore - raise DeserializationError(msg + str(err)) + raise DeserializationError(msg + str(err)) from err else: try: for attr, value in attrs.items(): @@ -1601,15 +1710,16 @@ def _instantiate_model(self, response, attrs, additional_properties=None): except Exception as exp: msg = "Unable to populate response model. " msg += "Type: {}, Error: {}".format(type(response), exp) - raise DeserializationError(msg) + raise DeserializationError(msg) from exp - def deserialize_data(self, data, data_type): + def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements """Process data for deserialization according to data type. :param str data: The response string to be deserialized. :param str data_type: The type to deserialize to. :raises: DeserializationError if deserialization fails. :return: Deserialized object. + :rtype: object """ if data is None: return data @@ -1623,7 +1733,11 @@ def deserialize_data(self, data, data_type): if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): return data - is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment + "object", + "[]", + r"{}", + ] if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: return None data_val = self.deserialize_type[data_type](data) @@ -1642,15 +1756,15 @@ 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) - else: - return self._deserialize(obj_type, data) + raise DeserializationError(msg) from err + return self._deserialize(obj_type, data) def deserialize_iter(self, attr, iter_type): """Deserialize an iterable. :param list attr: Iterable to be deserialized. :param str iter_type: The type of object in the iterable. + :return: Deserialized iterable. :rtype: list """ if attr is None: @@ -1667,6 +1781,7 @@ def deserialize_dict(self, attr, dict_type): :param dict/list attr: Dictionary to be deserialized. Also accepts a list of key, value pairs. :param str dict_type: The object type of the items in the dictionary. + :return: Deserialized dictionary. :rtype: dict """ if isinstance(attr, list): @@ -1677,11 +1792,12 @@ def deserialize_dict(self, attr, dict_type): attr = {el.tag: el.text for el in attr} return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} - def deserialize_object(self, attr, **kwargs): + def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements """Deserialize a generic object. This will be handled as a dictionary. :param dict attr: Dictionary to be deserialized. + :return: Deserialized object. :rtype: dict :raises: TypeError if non-builtin datatype encountered. """ @@ -1690,7 +1806,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: @@ -1716,11 +1832,10 @@ def deserialize_object(self, attr, **kwargs): pass return deserialized - else: - error = "Cannot deserialize generic object with type: " - raise TypeError(error + str(obj_type)) + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) - def deserialize_basic(self, attr, data_type): + def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements """Deserialize basic builtin data type from string. Will attempt to convert to str, int, float and bool. This function will also accept '1', '0', 'true' and 'false' as @@ -1728,6 +1843,7 @@ def deserialize_basic(self, attr, data_type): :param str attr: response string to be deserialized. :param str data_type: deserialization data type. + :return: Deserialized basic type. :rtype: str, int, float or bool :raises: TypeError if string format is not valid. """ @@ -1739,24 +1855,23 @@ def deserialize_basic(self, attr, data_type): if data_type == "str": # None or '', node is empty string. return "" - else: - # None or '', node with a strong type is None. - # Don't try to model "empty bool" or "empty int" - return None + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None if data_type == "bool": if attr in [True, False, 1, 0]: return bool(attr) - elif isinstance(attr, basestring): + if isinstance(attr, str): if attr.lower() in ["true", "1"]: return True - elif attr.lower() in ["false", "0"]: + if attr.lower() in ["false", "0"]: return False raise TypeError("Invalid boolean value: {}".format(attr)) if data_type == "str": return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec + return eval(data_type)(attr) # nosec # pylint: disable=eval-used @staticmethod def deserialize_unicode(data): @@ -1764,6 +1879,7 @@ def deserialize_unicode(data): as a string. :param str data: response string to be deserialized. + :return: Deserialized string. :rtype: str or unicode """ # We might be here because we have an enum modeled as string, @@ -1777,8 +1893,7 @@ def deserialize_unicode(data): return data except NameError: return str(data) - else: - return str(data) + return str(data) @staticmethod def deserialize_enum(data, enum_obj): @@ -1790,6 +1905,7 @@ def deserialize_enum(data, enum_obj): :param str data: Response string to be deserialized. If this value is None or invalid it will be returned as-is. :param Enum enum_obj: Enum object to deserialize to. + :return: Deserialized enum object. :rtype: Enum """ if isinstance(data, enum_obj) or data is None: @@ -1798,12 +1914,11 @@ 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: + except IndexError as exc: error = "{!r} is not a valid index for enum {!r}" - raise DeserializationError(error.format(data, enum_obj)) + raise DeserializationError(error.format(data, enum_obj)) from exc try: return enum_obj(str(data)) except ValueError: @@ -1819,6 +1934,7 @@ def deserialize_bytearray(attr): """Deserialize string into bytearray. :param str attr: response string to be deserialized. + :return: Deserialized bytearray :rtype: bytearray :raises: TypeError if string format invalid. """ @@ -1831,6 +1947,7 @@ def deserialize_base64(attr): """Deserialize base64 encoded string into string. :param str attr: response string to be deserialized. + :return: Deserialized base64 string :rtype: bytearray :raises: TypeError if string format invalid. """ @@ -1846,22 +1963,24 @@ def deserialize_decimal(attr): """Deserialize string into Decimal object. :param str attr: response string to be deserialized. - :rtype: Decimal + :return: Deserialized decimal :raises: DeserializationError if string format invalid. + :rtype: decimal """ 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): """Deserialize string into long (Py2) or int (Py3). :param str attr: response string to be deserialized. + :return: Deserialized int :rtype: long or int :raises: ValueError if string format invalid. """ @@ -1874,6 +1993,7 @@ def deserialize_duration(attr): """Deserialize ISO-8601 formatted string into TimeDelta object. :param str attr: response string to be deserialized. + :return: Deserialized duration :rtype: TimeDelta :raises: DeserializationError if string format invalid. """ @@ -1883,15 +2003,15 @@ 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) - else: - return duration + raise DeserializationError(msg) from err + return duration @staticmethod def deserialize_date(attr): """Deserialize ISO-8601 formatted string into Date object. :param str attr: response string to be deserialized. + :return: Deserialized date :rtype: Date :raises: DeserializationError if string format invalid. """ @@ -1900,13 +2020,14 @@ 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): """Deserialize ISO-8601 formatted string into time object. :param str attr: response string to be deserialized. + :return: Deserialized time :rtype: datetime.time :raises: DeserializationError if string format invalid. """ @@ -1921,6 +2042,7 @@ def deserialize_rfc(attr): """Deserialize RFC-1123 formatted string into Datetime object. :param str attr: response string to be deserialized. + :return: Deserialized RFC datetime :rtype: Datetime :raises: DeserializationError if string format invalid. """ @@ -1935,15 +2057,15 @@ 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) - else: - return date_obj + raise DeserializationError(msg) from err + return date_obj @staticmethod def deserialize_iso(attr): """Deserialize ISO-8601 formatted string into Datetime object. :param str attr: response string to be deserialized. + :return: Deserialized ISO datetime :rtype: Datetime :raises: DeserializationError if string format invalid. """ @@ -1972,9 +2094,8 @@ 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) - else: - return date_obj + raise DeserializationError(msg) from err + return date_obj @staticmethod def deserialize_unix(attr): @@ -1982,15 +2103,16 @@ def deserialize_unix(attr): This is represented as seconds. :param int attr: Object to be serialized. + :return: Deserialized datetime :rtype: Datetime :raises: DeserializationError if format invalid """ 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) - else: - return date_obj + raise DeserializationError(msg) from err + return date_obj diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/_synapse_management_client.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/_synapse_management_client.py index 7efbeace92af..71dc025f1040 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/_synapse_management_client.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/_synapse_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 SynapseManagementClientConfiguration @@ -94,7 +97,6 @@ ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -339,7 +341,25 @@ def __init__( self._config = SynapseManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client = 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) @@ -557,7 +577,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 @@ -577,14 +597,14 @@ 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) -> "SynapseManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self - def __exit__(self, *exc_details) -> None: + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/_vendor.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/_vendor.py deleted file mode 100644 index bd0df84f5319..000000000000 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/_vendor.py +++ /dev/null @@ -1,30 +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 typing import List, cast - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/_version.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/_version.py index 58df7fbbdd42..e5754a47ce68 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/_version.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.1.0b7" +VERSION = "1.0.0b1" diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/__init__.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/__init__.py index 198cb01d3f15..04fdea97f4fa 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/__init__.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/__init__.py @@ -5,12 +5,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._synapse_management_client import SynapseManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._synapse_management_client import SynapseManagementClient # type: ignore try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -18,6 +24,6 @@ __all__ = [ "SynapseManagementClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/_configuration.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/_configuration.py index 9a0dcc6811dd..6bd8ba247f2d 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/_configuration.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/_configuration.py @@ -8,18 +8,16 @@ 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 from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class SynapseManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class SynapseManagementClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for SynapseManagementClient. Note that all parameters used to create this instance are saved as instance @@ -32,7 +30,6 @@ class SynapseManagementClientConfiguration(Configuration): # pylint: disable=to """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(SynapseManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -42,6 +39,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.subscription_id = subscription_id self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-synapse/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -50,9 +48,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/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/_patch.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/_patch.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/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/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/_synapse_management_client.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/_synapse_management_client.py index 86f595a83a8e..c6e582cdb9bf 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/_synapse_management_client.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/_synapse_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 @@ -94,7 +97,6 @@ ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -343,7 +345,25 @@ def __init__( self._config = SynapseManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client = 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) @@ -561,7 +581,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 @@ -581,14 +603,14 @@ 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) -> "SynapseManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/__init__.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/__init__.py index b1719c4e0458..582500f84839 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/__init__.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/__init__.py @@ -5,105 +5,91 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._azure_ad_only_authentications_operations import AzureADOnlyAuthenticationsOperations -from ._operations import Operations -from ._ip_firewall_rules_operations import IpFirewallRulesOperations -from ._keys_operations import KeysOperations -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations -from ._private_link_resources_operations import PrivateLinkResourcesOperations -from ._private_link_hub_private_link_resources_operations import PrivateLinkHubPrivateLinkResourcesOperations -from ._private_link_hubs_operations import PrivateLinkHubsOperations -from ._private_endpoint_connections_private_link_hub_operations import ( - PrivateEndpointConnectionsPrivateLinkHubOperations, -) -from ._sql_pools_operations import SqlPoolsOperations -from ._sql_pool_metadata_sync_configs_operations import SqlPoolMetadataSyncConfigsOperations -from ._sql_pool_operation_results_operations import SqlPoolOperationResultsOperations -from ._sql_pool_geo_backup_policies_operations import SqlPoolGeoBackupPoliciesOperations -from ._sql_pool_data_warehouse_user_activities_operations import SqlPoolDataWarehouseUserActivitiesOperations -from ._sql_pool_restore_points_operations import SqlPoolRestorePointsOperations -from ._sql_pool_replication_links_operations import SqlPoolReplicationLinksOperations -from ._sql_pool_maintenance_windows_operations import SqlPoolMaintenanceWindowsOperations -from ._sql_pool_maintenance_window_options_operations import SqlPoolMaintenanceWindowOptionsOperations -from ._sql_pool_transparent_data_encryptions_operations import SqlPoolTransparentDataEncryptionsOperations -from ._sql_pool_blob_auditing_policies_operations import SqlPoolBlobAuditingPoliciesOperations -from ._sql_pool_operations_operations import SqlPoolOperationsOperations -from ._sql_pool_usages_operations import SqlPoolUsagesOperations -from ._sql_pool_sensitivity_labels_operations import SqlPoolSensitivityLabelsOperations -from ._sql_pool_recommended_sensitivity_labels_operations import SqlPoolRecommendedSensitivityLabelsOperations -from ._sql_pool_schemas_operations import SqlPoolSchemasOperations -from ._sql_pool_tables_operations import SqlPoolTablesOperations -from ._sql_pool_table_columns_operations import SqlPoolTableColumnsOperations -from ._sql_pool_connection_policies_operations import SqlPoolConnectionPoliciesOperations -from ._sql_pool_vulnerability_assessments_operations import SqlPoolVulnerabilityAssessmentsOperations -from ._sql_pool_vulnerability_assessment_scans_operations import SqlPoolVulnerabilityAssessmentScansOperations -from ._sql_pool_security_alert_policies_operations import SqlPoolSecurityAlertPoliciesOperations -from ._sql_pool_vulnerability_assessment_rule_baselines_operations import ( - SqlPoolVulnerabilityAssessmentRuleBaselinesOperations, -) -from ._extended_sql_pool_blob_auditing_policies_operations import ExtendedSqlPoolBlobAuditingPoliciesOperations -from ._data_masking_policies_operations import DataMaskingPoliciesOperations -from ._data_masking_rules_operations import DataMaskingRulesOperations -from ._sql_pool_columns_operations import SqlPoolColumnsOperations -from ._sql_pool_workload_group_operations import SqlPoolWorkloadGroupOperations -from ._sql_pool_workload_classifier_operations import SqlPoolWorkloadClassifierOperations -from ._workspace_managed_sql_server_blob_auditing_policies_operations import ( - WorkspaceManagedSqlServerBlobAuditingPoliciesOperations, -) -from ._workspace_managed_sql_server_extended_blob_auditing_policies_operations import ( - WorkspaceManagedSqlServerExtendedBlobAuditingPoliciesOperations, -) -from ._workspace_managed_sql_server_security_alert_policy_operations import ( - WorkspaceManagedSqlServerSecurityAlertPolicyOperations, -) -from ._workspace_managed_sql_server_vulnerability_assessments_operations import ( - WorkspaceManagedSqlServerVulnerabilityAssessmentsOperations, -) -from ._workspace_managed_sql_server_encryption_protector_operations import ( - WorkspaceManagedSqlServerEncryptionProtectorOperations, -) -from ._workspace_managed_sql_server_usages_operations import WorkspaceManagedSqlServerUsagesOperations -from ._workspace_managed_sql_server_recoverable_sql_pools_operations import ( - WorkspaceManagedSqlServerRecoverableSqlPoolsOperations, -) -from ._workspace_managed_sql_server_dedicated_sql_minimal_tls_settings_operations import ( - WorkspaceManagedSqlServerDedicatedSQLMinimalTlsSettingsOperations, -) -from ._workspaces_operations import WorkspacesOperations -from ._workspace_aad_admins_operations import WorkspaceAadAdminsOperations -from ._workspace_sql_aad_admins_operations import WorkspaceSqlAadAdminsOperations -from ._workspace_managed_identity_sql_control_settings_operations import ( - WorkspaceManagedIdentitySqlControlSettingsOperations, -) -from ._restorable_dropped_sql_pools_operations import RestorableDroppedSqlPoolsOperations -from ._big_data_pools_operations import BigDataPoolsOperations -from ._library_operations import LibraryOperations -from ._libraries_operations import LibrariesOperations -from ._integration_runtimes_operations import IntegrationRuntimesOperations -from ._integration_runtime_node_ip_address_operations import IntegrationRuntimeNodeIpAddressOperations -from ._integration_runtime_object_metadata_operations import IntegrationRuntimeObjectMetadataOperations -from ._integration_runtime_nodes_operations import IntegrationRuntimeNodesOperations -from ._integration_runtime_credentials_operations import IntegrationRuntimeCredentialsOperations -from ._integration_runtime_connection_infos_operations import IntegrationRuntimeConnectionInfosOperations -from ._integration_runtime_auth_keys_operations import IntegrationRuntimeAuthKeysOperations -from ._integration_runtime_monitoring_data_operations import IntegrationRuntimeMonitoringDataOperations -from ._integration_runtime_status_operations import IntegrationRuntimeStatusOperations -from ._get_operations import GetOperations -from ._spark_configuration_operations import SparkConfigurationOperations -from ._spark_configurations_operations import SparkConfigurationsOperations -from ._kusto_operations_operations import KustoOperationsOperations -from ._kusto_pools_operations import KustoPoolsOperations -from ._kusto_pool_child_resource_operations import KustoPoolChildResourceOperations -from ._kusto_pool_attached_database_configurations_operations import KustoPoolAttachedDatabaseConfigurationsOperations -from ._kusto_pool_databases_operations import KustoPoolDatabasesOperations -from ._kusto_pool_data_connections_operations import KustoPoolDataConnectionsOperations -from ._kusto_pool_principal_assignments_operations import KustoPoolPrincipalAssignmentsOperations -from ._kusto_pool_database_principal_assignments_operations import KustoPoolDatabasePrincipalAssignmentsOperations -from ._kusto_pool_private_link_resources_operations import KustoPoolPrivateLinkResourcesOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._azure_ad_only_authentications_operations import AzureADOnlyAuthenticationsOperations # type: ignore +from ._operations import Operations # type: ignore +from ._ip_firewall_rules_operations import IpFirewallRulesOperations # type: ignore +from ._keys_operations import KeysOperations # type: ignore +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore +from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore +from ._private_link_hub_private_link_resources_operations import PrivateLinkHubPrivateLinkResourcesOperations # type: ignore +from ._private_link_hubs_operations import PrivateLinkHubsOperations # type: ignore +from ._private_endpoint_connections_private_link_hub_operations import PrivateEndpointConnectionsPrivateLinkHubOperations # type: ignore +from ._sql_pools_operations import SqlPoolsOperations # type: ignore +from ._sql_pool_metadata_sync_configs_operations import SqlPoolMetadataSyncConfigsOperations # type: ignore +from ._sql_pool_operation_results_operations import SqlPoolOperationResultsOperations # type: ignore +from ._sql_pool_geo_backup_policies_operations import SqlPoolGeoBackupPoliciesOperations # type: ignore +from ._sql_pool_data_warehouse_user_activities_operations import SqlPoolDataWarehouseUserActivitiesOperations # type: ignore +from ._sql_pool_restore_points_operations import SqlPoolRestorePointsOperations # type: ignore +from ._sql_pool_replication_links_operations import SqlPoolReplicationLinksOperations # type: ignore +from ._sql_pool_maintenance_windows_operations import SqlPoolMaintenanceWindowsOperations # type: ignore +from ._sql_pool_maintenance_window_options_operations import SqlPoolMaintenanceWindowOptionsOperations # type: ignore +from ._sql_pool_transparent_data_encryptions_operations import SqlPoolTransparentDataEncryptionsOperations # type: ignore +from ._sql_pool_blob_auditing_policies_operations import SqlPoolBlobAuditingPoliciesOperations # type: ignore +from ._sql_pool_operations_operations import SqlPoolOperationsOperations # type: ignore +from ._sql_pool_usages_operations import SqlPoolUsagesOperations # type: ignore +from ._sql_pool_sensitivity_labels_operations import SqlPoolSensitivityLabelsOperations # type: ignore +from ._sql_pool_recommended_sensitivity_labels_operations import SqlPoolRecommendedSensitivityLabelsOperations # type: ignore +from ._sql_pool_schemas_operations import SqlPoolSchemasOperations # type: ignore +from ._sql_pool_tables_operations import SqlPoolTablesOperations # type: ignore +from ._sql_pool_table_columns_operations import SqlPoolTableColumnsOperations # type: ignore +from ._sql_pool_connection_policies_operations import SqlPoolConnectionPoliciesOperations # type: ignore +from ._sql_pool_vulnerability_assessments_operations import SqlPoolVulnerabilityAssessmentsOperations # type: ignore +from ._sql_pool_vulnerability_assessment_scans_operations import SqlPoolVulnerabilityAssessmentScansOperations # type: ignore +from ._sql_pool_security_alert_policies_operations import SqlPoolSecurityAlertPoliciesOperations # type: ignore +from ._sql_pool_vulnerability_assessment_rule_baselines_operations import SqlPoolVulnerabilityAssessmentRuleBaselinesOperations # type: ignore +from ._extended_sql_pool_blob_auditing_policies_operations import ExtendedSqlPoolBlobAuditingPoliciesOperations # type: ignore +from ._data_masking_policies_operations import DataMaskingPoliciesOperations # type: ignore +from ._data_masking_rules_operations import DataMaskingRulesOperations # type: ignore +from ._sql_pool_columns_operations import SqlPoolColumnsOperations # type: ignore +from ._sql_pool_workload_group_operations import SqlPoolWorkloadGroupOperations # type: ignore +from ._sql_pool_workload_classifier_operations import SqlPoolWorkloadClassifierOperations # type: ignore +from ._workspace_managed_sql_server_blob_auditing_policies_operations import WorkspaceManagedSqlServerBlobAuditingPoliciesOperations # type: ignore +from ._workspace_managed_sql_server_extended_blob_auditing_policies_operations import WorkspaceManagedSqlServerExtendedBlobAuditingPoliciesOperations # type: ignore +from ._workspace_managed_sql_server_security_alert_policy_operations import WorkspaceManagedSqlServerSecurityAlertPolicyOperations # type: ignore +from ._workspace_managed_sql_server_vulnerability_assessments_operations import WorkspaceManagedSqlServerVulnerabilityAssessmentsOperations # type: ignore +from ._workspace_managed_sql_server_encryption_protector_operations import WorkspaceManagedSqlServerEncryptionProtectorOperations # type: ignore +from ._workspace_managed_sql_server_usages_operations import WorkspaceManagedSqlServerUsagesOperations # type: ignore +from ._workspace_managed_sql_server_recoverable_sql_pools_operations import WorkspaceManagedSqlServerRecoverableSqlPoolsOperations # type: ignore +from ._workspace_managed_sql_server_dedicated_sql_minimal_tls_settings_operations import WorkspaceManagedSqlServerDedicatedSQLMinimalTlsSettingsOperations # type: ignore +from ._workspaces_operations import WorkspacesOperations # type: ignore +from ._workspace_aad_admins_operations import WorkspaceAadAdminsOperations # type: ignore +from ._workspace_sql_aad_admins_operations import WorkspaceSqlAadAdminsOperations # type: ignore +from ._workspace_managed_identity_sql_control_settings_operations import WorkspaceManagedIdentitySqlControlSettingsOperations # type: ignore +from ._restorable_dropped_sql_pools_operations import RestorableDroppedSqlPoolsOperations # type: ignore +from ._big_data_pools_operations import BigDataPoolsOperations # type: ignore +from ._library_operations import LibraryOperations # type: ignore +from ._libraries_operations import LibrariesOperations # type: ignore +from ._integration_runtimes_operations import IntegrationRuntimesOperations # type: ignore +from ._integration_runtime_node_ip_address_operations import IntegrationRuntimeNodeIpAddressOperations # type: ignore +from ._integration_runtime_object_metadata_operations import IntegrationRuntimeObjectMetadataOperations # type: ignore +from ._integration_runtime_nodes_operations import IntegrationRuntimeNodesOperations # type: ignore +from ._integration_runtime_credentials_operations import IntegrationRuntimeCredentialsOperations # type: ignore +from ._integration_runtime_connection_infos_operations import IntegrationRuntimeConnectionInfosOperations # type: ignore +from ._integration_runtime_auth_keys_operations import IntegrationRuntimeAuthKeysOperations # type: ignore +from ._integration_runtime_monitoring_data_operations import IntegrationRuntimeMonitoringDataOperations # type: ignore +from ._integration_runtime_status_operations import IntegrationRuntimeStatusOperations # type: ignore +from ._get_operations import GetOperations # type: ignore +from ._spark_configuration_operations import SparkConfigurationOperations # type: ignore +from ._spark_configurations_operations import SparkConfigurationsOperations # type: ignore +from ._kusto_operations_operations import KustoOperationsOperations # type: ignore +from ._kusto_pools_operations import KustoPoolsOperations # type: ignore +from ._kusto_pool_child_resource_operations import KustoPoolChildResourceOperations # type: ignore +from ._kusto_pool_attached_database_configurations_operations import KustoPoolAttachedDatabaseConfigurationsOperations # type: ignore +from ._kusto_pool_databases_operations import KustoPoolDatabasesOperations # type: ignore +from ._kusto_pool_data_connections_operations import KustoPoolDataConnectionsOperations # type: ignore +from ._kusto_pool_principal_assignments_operations import KustoPoolPrincipalAssignmentsOperations # type: ignore +from ._kusto_pool_database_principal_assignments_operations import KustoPoolDatabasePrincipalAssignmentsOperations # type: ignore +from ._kusto_pool_private_link_resources_operations import KustoPoolPrivateLinkResourcesOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -183,5 +169,5 @@ "KustoPoolDatabasePrincipalAssignmentsOperations", "KustoPoolPrivateLinkResourcesOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_azure_ad_only_authentications_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_azure_ad_only_authentications_operations.py index fa151307b739..bc6e09c5c572 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_azure_ad_only_authentications_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_azure_ad_only_authentications_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -16,12 +16,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 @@ -29,17 +30,16 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._azure_ad_only_authentications_operations import ( build_create_request, build_get_request, build_list_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -83,12 +83,11 @@ async def get( :param azure_ad_only_authentication_name: name of the property. "default" Required. :type azure_ad_only_authentication_name: str or ~azure.mgmt.synapse.models.AzureADOnlyAuthenticationName - :keyword callable cls: A custom type or function that will be passed the direct response :return: AzureADOnlyAuthentication or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.AzureADOnlyAuthentication :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -99,24 +98,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.AzureADOnlyAuthentication] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, azure_ad_only_authentication_name=azure_ad_only_authentication_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -126,26 +124,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("AzureADOnlyAuthentication", pipeline_response) + deserialized = self._deserialize("AzureADOnlyAuthentication", 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.Synapse/workspaces/{workspaceName}/azureADOnlyAuthentications/{azureADOnlyAuthenticationName}" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, workspace_name: str, azure_ad_only_authentication_name: Union[str, _models.AzureADOnlyAuthenticationName], - azure_ad_only_authentication_info: Union[_models.AzureADOnlyAuthentication, IO], + azure_ad_only_authentication_info: Union[_models.AzureADOnlyAuthentication, IO[bytes]], **kwargs: Any - ) -> Optional[_models.AzureADOnlyAuthentication]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -156,19 +150,19 @@ async def _create_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.AzureADOnlyAuthentication]] = 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(azure_ad_only_authentication_info, (IO, bytes)): + if isinstance(azure_ad_only_authentication_info, (IOBase, bytes)): _content = azure_ad_only_authentication_info else: _json = self._serialize.body(azure_ad_only_authentication_info, "AzureADOnlyAuthentication") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, workspace_name=workspace_name, azure_ad_only_authentication_name=azure_ad_only_authentication_name, @@ -177,39 +171,34 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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=False, **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) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("AzureADOnlyAuthentication", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AzureADOnlyAuthentication", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/azureADOnlyAuthentications/{azureADOnlyAuthenticationName}" - } + return deserialized # type: ignore @overload async def begin_create( @@ -239,14 +228,6 @@ async def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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 AzureADOnlyAuthentication or the result of cls(response) :rtype: @@ -260,7 +241,7 @@ async def begin_create( resource_group_name: str, workspace_name: str, azure_ad_only_authentication_name: Union[str, _models.AzureADOnlyAuthenticationName], - azure_ad_only_authentication_info: IO, + azure_ad_only_authentication_info: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -278,18 +259,10 @@ async def begin_create( :type azure_ad_only_authentication_name: str or ~azure.mgmt.synapse.models.AzureADOnlyAuthenticationName :param azure_ad_only_authentication_info: Azure Active Directory Property. Required. - :type azure_ad_only_authentication_info: IO + :type azure_ad_only_authentication_info: 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 AzureADOnlyAuthentication or the result of cls(response) :rtype: @@ -303,7 +276,7 @@ async def begin_create( resource_group_name: str, workspace_name: str, azure_ad_only_authentication_name: Union[str, _models.AzureADOnlyAuthenticationName], - azure_ad_only_authentication_info: Union[_models.AzureADOnlyAuthentication, IO], + azure_ad_only_authentication_info: Union[_models.AzureADOnlyAuthentication, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.AzureADOnlyAuthentication]: """Create or Update Azure Active Directory only authentication property. @@ -318,21 +291,10 @@ async def begin_create( :param azure_ad_only_authentication_name: name of the property. "default" Required. :type azure_ad_only_authentication_name: str or ~azure.mgmt.synapse.models.AzureADOnlyAuthenticationName - :param azure_ad_only_authentication_info: Azure Active Directory Property. Is either a model - type or a IO type. Required. + :param azure_ad_only_authentication_info: Azure Active Directory Property. Is either a + AzureADOnlyAuthentication type or a IO[bytes] type. Required. :type azure_ad_only_authentication_info: ~azure.mgmt.synapse.models.AzureADOnlyAuthentication - 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 IO[bytes] :return: An instance of AsyncLROPoller that returns either AzureADOnlyAuthentication or the result of cls(response) :rtype: @@ -342,7 +304,7 @@ async def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AzureADOnlyAuthentication] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -361,12 +323,13 @@ async def begin_create( 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("AzureADOnlyAuthentication", pipeline_response) + deserialized = self._deserialize("AzureADOnlyAuthentication", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -378,17 +341,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.AzureADOnlyAuthentication].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/azureADOnlyAuthentications/{azureADOnlyAuthenticationName}" - } + return AsyncLROPoller[_models.AzureADOnlyAuthentication]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list( @@ -403,7 +364,6 @@ def list( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AzureADOnlyAuthentication or the result of cls(response) :rtype: @@ -413,10 +373,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.AzureADOnlyAuthenticationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -427,24 +387,21 @@ 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, workspace_name=workspace_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AzureADOnlyAuthenticationListResult", pipeline_response) @@ -454,10 +411,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -469,7 +427,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.Synapse/workspaces/{workspaceName}/azureADOnlyAuthentications" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_big_data_pools_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_big_data_pools_operations.py index 90a7df61d866..10d801fee344 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_big_data_pools_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_big_data_pools_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -16,12 +16,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 @@ -29,7 +30,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._big_data_pools_operations import ( build_create_or_update_request, build_delete_request, @@ -38,10 +38,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -80,12 +80,11 @@ async def get( :type workspace_name: str :param big_data_pool_name: Big Data pool name. Required. :type big_data_pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BigDataPoolResourceInfo or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.BigDataPoolResourceInfo :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -96,26 +95,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.BigDataPoolResourceInfo] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, big_data_pool_name=big_data_pool_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -125,16 +121,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("BigDataPoolResourceInfo", pipeline_response) + deserialized = self._deserialize("BigDataPoolResourceInfo", 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.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}" - } + return deserialized # type: ignore @overload async def update( @@ -163,7 +155,6 @@ async def 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 :return: BigDataPoolResourceInfo or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.BigDataPoolResourceInfo :raises ~azure.core.exceptions.HttpResponseError: @@ -175,7 +166,7 @@ async def update( resource_group_name: str, workspace_name: str, big_data_pool_name: str, - big_data_pool_patch_info: IO, + big_data_pool_patch_info: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -192,11 +183,10 @@ async def update( :param big_data_pool_name: Big Data pool name. Required. :type big_data_pool_name: str :param big_data_pool_patch_info: The updated Big Data pool properties. Required. - :type big_data_pool_patch_info: IO + :type big_data_pool_patch_info: 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: BigDataPoolResourceInfo or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.BigDataPoolResourceInfo :raises ~azure.core.exceptions.HttpResponseError: @@ -208,7 +198,7 @@ async def update( resource_group_name: str, workspace_name: str, big_data_pool_name: str, - big_data_pool_patch_info: Union[_models.BigDataPoolPatchInfo, IO], + big_data_pool_patch_info: Union[_models.BigDataPoolPatchInfo, IO[bytes]], **kwargs: Any ) -> _models.BigDataPoolResourceInfo: """Update a Big Data pool. @@ -222,18 +212,14 @@ async def update( :type workspace_name: str :param big_data_pool_name: Big Data pool name. Required. :type big_data_pool_name: str - :param big_data_pool_patch_info: The updated Big Data pool properties. Is either a model type - or a IO type. Required. - :type big_data_pool_patch_info: ~azure.mgmt.synapse.models.BigDataPoolPatchInfo 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 big_data_pool_patch_info: The updated Big Data pool properties. Is either a + BigDataPoolPatchInfo type or a IO[bytes] type. Required. + :type big_data_pool_patch_info: ~azure.mgmt.synapse.models.BigDataPoolPatchInfo or IO[bytes] :return: BigDataPoolResourceInfo or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.BigDataPoolResourceInfo :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -244,21 +230,19 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.BigDataPoolResourceInfo] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(big_data_pool_patch_info, (IO, bytes)): + if isinstance(big_data_pool_patch_info, (IOBase, bytes)): _content = big_data_pool_patch_info else: _json = self._serialize.body(big_data_pool_patch_info, "BigDataPoolPatchInfo") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, big_data_pool_name=big_data_pool_name, @@ -267,15 +251,14 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -285,27 +268,23 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("BigDataPoolResourceInfo", pipeline_response) + deserialized = self._deserialize("BigDataPoolResourceInfo", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, workspace_name: str, big_data_pool_name: str, - big_data_pool_info: Union[_models.BigDataPoolResourceInfo, IO], + big_data_pool_info: Union[_models.BigDataPoolResourceInfo, IO[bytes]], force: bool = False, **kwargs: Any - ) -> _models.BigDataPoolResourceInfo: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -316,21 +295,19 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.BigDataPoolResourceInfo] = 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(big_data_pool_info, (IO, bytes)): + if isinstance(big_data_pool_info, (IOBase, bytes)): _content = big_data_pool_info else: _json = self._serialize.body(big_data_pool_info, "BigDataPoolResourceInfo") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, big_data_pool_name=big_data_pool_name, @@ -340,39 +317,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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) - if response.status_code == 200: - deserialized = self._deserialize("BigDataPoolResourceInfo", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("BigDataPoolResourceInfo", 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.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}" - } - @overload async def begin_create_or_update( self, @@ -403,14 +376,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 BigDataPoolResourceInfo or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.BigDataPoolResourceInfo] @@ -423,7 +388,7 @@ async def begin_create_or_update( resource_group_name: str, workspace_name: str, big_data_pool_name: str, - big_data_pool_info: IO, + big_data_pool_info: IO[bytes], force: bool = False, *, content_type: str = "application/json", @@ -441,20 +406,12 @@ async def begin_create_or_update( :param big_data_pool_name: Big Data pool name. Required. :type big_data_pool_name: str :param big_data_pool_info: The Big Data pool to create. Required. - :type big_data_pool_info: IO + :type big_data_pool_info: IO[bytes] :param force: Whether to stop any running jobs in the Big Data pool. Default value is False. :type force: bool :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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 BigDataPoolResourceInfo or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.BigDataPoolResourceInfo] @@ -467,7 +424,7 @@ async def begin_create_or_update( resource_group_name: str, workspace_name: str, big_data_pool_name: str, - big_data_pool_info: Union[_models.BigDataPoolResourceInfo, IO], + big_data_pool_info: Union[_models.BigDataPoolResourceInfo, IO[bytes]], force: bool = False, **kwargs: Any ) -> AsyncLROPoller[_models.BigDataPoolResourceInfo]: @@ -482,22 +439,11 @@ async def begin_create_or_update( :type workspace_name: str :param big_data_pool_name: Big Data pool name. Required. :type big_data_pool_name: str - :param big_data_pool_info: The Big Data pool to create. Is either a model type or a IO type. - Required. - :type big_data_pool_info: ~azure.mgmt.synapse.models.BigDataPoolResourceInfo or IO + :param big_data_pool_info: The Big Data pool to create. Is either a BigDataPoolResourceInfo + type or a IO[bytes] type. Required. + :type big_data_pool_info: ~azure.mgmt.synapse.models.BigDataPoolResourceInfo or IO[bytes] :param force: Whether to stop any running jobs in the Big Data pool. Default value is False. :type force: bool - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 BigDataPoolResourceInfo or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.BigDataPoolResourceInfo] @@ -506,9 +452,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.BigDataPoolResourceInfo] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -528,12 +472,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("BigDataPoolResourceInfo", pipeline_response) + deserialized = self._deserialize("BigDataPoolResourceInfo", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -546,22 +491,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.BigDataPoolResourceInfo].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.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}" - } + return AsyncLROPoller[_models.BigDataPoolResourceInfo]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _delete_initial( self, resource_group_name: str, workspace_name: str, big_data_pool_name: str, **kwargs: Any - ) -> Optional[_models.BigDataPoolResourceInfo]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -572,50 +515,43 @@ async def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) - cls: ClsType[Optional[_models.BigDataPoolResourceInfo]] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_name, big_data_pool_name=big_data_pool_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("BigDataPoolResourceInfo", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("BigDataPoolResourceInfo", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -632,14 +568,6 @@ async def begin_delete( :type workspace_name: str :param big_data_pool_name: Big Data pool name. Required. :type big_data_pool_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 BigDataPoolResourceInfo or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.BigDataPoolResourceInfo] @@ -648,9 +576,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.BigDataPoolResourceInfo] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -666,12 +592,13 @@ 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): - deserialized = self._deserialize("BigDataPoolResourceInfo", pipeline_response) + deserialized = self._deserialize("BigDataPoolResourceInfo", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -684,17 +611,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.BigDataPoolResourceInfo].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.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}" - } + return AsyncLROPoller[_models.BigDataPoolResourceInfo]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list_by_workspace( @@ -709,7 +634,6 @@ def list_by_workspace( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BigDataPoolResourceInfo or the result of cls(response) :rtype: @@ -719,12 +643,10 @@ def list_by_workspace( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.BigDataPoolResourceInfoListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -735,24 +657,21 @@ def list_by_workspace( def prepare_request(next_link=None): if not next_link: - request = build_list_by_workspace_request( + _request = build_list_by_workspace_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_workspace.metadata["url"], 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("BigDataPoolResourceInfoListResult", pipeline_response) @@ -762,10 +681,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -777,7 +697,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_workspace.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_data_masking_policies_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_data_masking_policies_operations.py index 874aaf80a1cd..c103dee2a6d6 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_data_masking_policies_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_data_masking_policies_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,20 +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._data_masking_policies_operations import build_create_or_update_request, build_get_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -80,11 +78,6 @@ async def 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 data_masking_policy_name: The name of the data masking policy for which the masking - rule applies. Default value is "Default". Note that overriding this default value may result in - unsupported behavior. - :paramtype data_masking_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DataMaskingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.DataMaskingPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -96,7 +89,7 @@ async def create_or_update( resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -111,15 +104,10 @@ async def create_or_update( :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str :param parameters: Parameters for creating or updating a data masking policy. 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 data_masking_policy_name: The name of the data masking policy for which the masking - rule applies. Default value is "Default". Note that overriding this default value may result in - unsupported behavior. - :paramtype data_masking_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DataMaskingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.DataMaskingPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -131,7 +119,7 @@ async def create_or_update( resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: Union[_models.DataMaskingPolicy, IO], + parameters: Union[_models.DataMaskingPolicy, IO[bytes]], **kwargs: Any ) -> _models.DataMaskingPolicy: """Creates or updates a Sql pool data masking policy. @@ -143,22 +131,14 @@ async def create_or_update( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param parameters: Parameters for creating or updating a data masking policy. Is either a model - type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.models.DataMaskingPolicy or IO - :keyword data_masking_policy_name: The name of the data masking policy for which the masking - rule applies. Default value is "Default". Note that overriding this default value may result in - unsupported behavior. - :paramtype data_masking_policy_name: 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 + :param parameters: Parameters for creating or updating a data masking policy. Is either a + DataMaskingPolicy type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.DataMaskingPolicy or IO[bytes] :return: DataMaskingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.DataMaskingPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -169,7 +149,7 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) data_masking_policy_name: Literal["Default"] = kwargs.pop("data_masking_policy_name", "Default") content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DataMaskingPolicy] = kwargs.pop("cls", None) @@ -177,12 +157,12 @@ async def create_or_update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DataMaskingPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -192,15 +172,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -210,16 +189,12 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DataMaskingPolicy", pipeline_response) + deserialized = self._deserialize("DataMaskingPolicy", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataMaskingPolicies/{dataMaskingPolicyName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -234,16 +209,11 @@ async def get( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword data_masking_policy_name: The name of the data masking policy for which the masking - rule applies. Default value is "Default". Note that overriding this default value may result in - unsupported behavior. - :paramtype data_masking_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DataMaskingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.DataMaskingPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -254,26 +224,25 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) data_masking_policy_name: Literal["Default"] = kwargs.pop("data_masking_policy_name", "Default") cls: ClsType[_models.DataMaskingPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, subscription_id=self._config.subscription_id, api_version=api_version, data_masking_policy_name=data_masking_policy_name, - 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -283,13 +252,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("DataMaskingPolicy", pipeline_response) + deserialized = self._deserialize("DataMaskingPolicy", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataMaskingPolicies/{dataMaskingPolicyName}" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_data_masking_rules_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_data_masking_rules_operations.py index bf8901e2b25d..6772db4565a2 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_data_masking_rules_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_data_masking_rules_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,25 +19,23 @@ 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._data_masking_rules_operations import ( build_create_or_update_request, build_get_request, build_list_by_sql_pool_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -90,11 +88,6 @@ async def 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 data_masking_policy_name: The name of the data masking policy for which the masking - rule applies. Default value is "Default". Note that overriding this default value may result in - unsupported behavior. - :paramtype data_masking_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DataMaskingRule or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.DataMaskingRule :raises ~azure.core.exceptions.HttpResponseError: @@ -107,7 +100,7 @@ async def create_or_update( workspace_name: str, sql_pool_name: str, data_masking_rule_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -125,15 +118,10 @@ async def create_or_update( :type data_masking_rule_name: str :param parameters: The required parameters for creating or updating a data masking rule. 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 data_masking_policy_name: The name of the data masking policy for which the masking - rule applies. Default value is "Default". Note that overriding this default value may result in - unsupported behavior. - :paramtype data_masking_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DataMaskingRule or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.DataMaskingRule :raises ~azure.core.exceptions.HttpResponseError: @@ -146,7 +134,7 @@ async def create_or_update( workspace_name: str, sql_pool_name: str, data_masking_rule_name: str, - parameters: Union[_models.DataMaskingRule, IO], + parameters: Union[_models.DataMaskingRule, IO[bytes]], **kwargs: Any ) -> _models.DataMaskingRule: """Creates or updates a Sql pool data masking rule. @@ -161,21 +149,13 @@ async def create_or_update( :param data_masking_rule_name: The name of the data masking rule. Required. :type data_masking_rule_name: str :param parameters: The required parameters for creating or updating a data masking rule. Is - either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.models.DataMaskingRule or IO - :keyword data_masking_policy_name: The name of the data masking policy for which the masking - rule applies. Default value is "Default". Note that overriding this default value may result in - unsupported behavior. - :paramtype data_masking_policy_name: 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 + either a DataMaskingRule type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.DataMaskingRule or IO[bytes] :return: DataMaskingRule or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.DataMaskingRule :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -186,7 +166,7 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) data_masking_policy_name: Literal["Default"] = kwargs.pop("data_masking_policy_name", "Default") content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DataMaskingRule] = kwargs.pop("cls", None) @@ -194,12 +174,12 @@ async def create_or_update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DataMaskingRule") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -210,15 +190,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -228,21 +207,13 @@ async def create_or_update( 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("DataMaskingRule", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DataMaskingRule", pipeline_response) + deserialized = self._deserialize("DataMaskingRule", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules/{dataMaskingRuleName}" - } - @distributed_trace_async async def get( self, @@ -263,16 +234,11 @@ async def get( :type sql_pool_name: str :param data_masking_rule_name: The name of the data masking rule. Required. :type data_masking_rule_name: str - :keyword data_masking_policy_name: The name of the data masking policy for which the masking - rule applies. Default value is "Default". Note that overriding this default value may result in - unsupported behavior. - :paramtype data_masking_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DataMaskingRule or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.DataMaskingRule :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -283,11 +249,11 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) data_masking_policy_name: Literal["Default"] = kwargs.pop("data_masking_policy_name", "Default") cls: ClsType[_models.DataMaskingRule] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -295,15 +261,14 @@ async def get( subscription_id=self._config.subscription_id, api_version=api_version, data_masking_policy_name=data_masking_policy_name, - 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -313,16 +278,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("DataMaskingRule", pipeline_response) + deserialized = self._deserialize("DataMaskingRule", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules/{dataMaskingRuleName}" - } + return deserialized # type: ignore @distributed_trace def list_by_sql_pool( @@ -337,11 +298,6 @@ def list_by_sql_pool( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword data_masking_policy_name: The name of the data masking policy for which the masking - rule applies. Default value is "Default". Note that overriding this default value may result in - unsupported behavior. - :paramtype data_masking_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DataMaskingRule or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.DataMaskingRule] :raises ~azure.core.exceptions.HttpResponseError: @@ -349,11 +305,11 @@ def list_by_sql_pool( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) data_masking_policy_name: Literal["Default"] = kwargs.pop("data_masking_policy_name", "Default") cls: ClsType[_models.DataMaskingRuleListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -364,26 +320,23 @@ def list_by_sql_pool( def prepare_request(next_link=None): if not next_link: - request = build_list_by_sql_pool_request( + _request = build_list_by_sql_pool_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, subscription_id=self._config.subscription_id, api_version=api_version, data_masking_policy_name=data_masking_policy_name, - template_url=self.list_by_sql_pool.metadata["url"], 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DataMaskingRuleListResult", pipeline_response) @@ -393,10 +346,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -408,7 +362,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_sql_pool.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_extended_sql_pool_blob_auditing_policies_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_extended_sql_pool_blob_auditing_policies_operations.py index a4042e554541..f5533233b9a1 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_extended_sql_pool_blob_auditing_policies_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_extended_sql_pool_blob_auditing_policies_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,30 +19,28 @@ 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._extended_sql_pool_blob_auditing_policies_operations import ( build_create_or_update_request, build_get_request, build_list_by_sql_pool_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ExtendedSqlPoolBlobAuditingPoliciesOperations: +class ExtendedSqlPoolBlobAuditingPoliciesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -74,15 +72,11 @@ async def get( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword blob_auditing_policy_name: The name of the blob auditing policy. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype blob_auditing_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ExtendedSqlPoolBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ExtendedSqlPoolBlobAuditingPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -93,26 +87,25 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") cls: ClsType[_models.ExtendedSqlPoolBlobAuditingPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, subscription_id=self._config.subscription_id, api_version=api_version, blob_auditing_policy_name=blob_auditing_policy_name, - 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -121,16 +114,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ExtendedSqlPoolBlobAuditingPolicy", pipeline_response) + deserialized = self._deserialize("ExtendedSqlPoolBlobAuditingPolicy", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/extendedAuditingSettings/{blobAuditingPolicyName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -157,10 +146,6 @@ async def 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 blob_auditing_policy_name: The name of the blob auditing policy. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype blob_auditing_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ExtendedSqlPoolBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ExtendedSqlPoolBlobAuditingPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -172,7 +157,7 @@ async def create_or_update( resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -187,14 +172,10 @@ async def create_or_update( :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str :param parameters: The extended Sql pool blob auditing policy. 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 blob_auditing_policy_name: The name of the blob auditing policy. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype blob_auditing_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ExtendedSqlPoolBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ExtendedSqlPoolBlobAuditingPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -206,7 +187,7 @@ async def create_or_update( resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: Union[_models.ExtendedSqlPoolBlobAuditingPolicy, IO], + parameters: Union[_models.ExtendedSqlPoolBlobAuditingPolicy, IO[bytes]], **kwargs: Any ) -> _models.ExtendedSqlPoolBlobAuditingPolicy: """Creates or updates an extended Sql pool's blob auditing policy. @@ -218,21 +199,14 @@ async def create_or_update( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param parameters: The extended Sql pool blob auditing policy. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.synapse.models.ExtendedSqlPoolBlobAuditingPolicy or IO - :keyword blob_auditing_policy_name: The name of the blob auditing policy. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype blob_auditing_policy_name: 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 + :param parameters: The extended Sql pool blob auditing policy. Is either a + ExtendedSqlPoolBlobAuditingPolicy type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.ExtendedSqlPoolBlobAuditingPolicy or IO[bytes] :return: ExtendedSqlPoolBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ExtendedSqlPoolBlobAuditingPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -243,7 +217,7 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ExtendedSqlPoolBlobAuditingPolicy] = kwargs.pop("cls", None) @@ -251,12 +225,12 @@ async def create_or_update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ExtendedSqlPoolBlobAuditingPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -266,15 +240,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -283,21 +256,13 @@ async def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ExtendedSqlPoolBlobAuditingPolicy", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ExtendedSqlPoolBlobAuditingPolicy", pipeline_response) + deserialized = self._deserialize("ExtendedSqlPoolBlobAuditingPolicy", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/extendedAuditingSettings/{blobAuditingPolicyName}" - } - @distributed_trace def list_by_sql_pool( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any @@ -311,7 +276,6 @@ def list_by_sql_pool( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ExtendedSqlPoolBlobAuditingPolicy or the result of cls(response) :rtype: @@ -321,10 +285,10 @@ def list_by_sql_pool( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.ExtendedSqlPoolBlobAuditingPolicyListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -335,25 +299,22 @@ def list_by_sql_pool( def prepare_request(next_link=None): if not next_link: - request = build_list_by_sql_pool_request( + _request = build_list_by_sql_pool_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_sql_pool.metadata["url"], 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ExtendedSqlPoolBlobAuditingPolicyListResult", pipeline_response) @@ -363,10 +324,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -377,7 +339,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_sql_pool.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/extendedAuditingSettings" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_get_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_get_operations.py index 96984567c02a..7afaf674d0fd 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_get_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_get_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -18,24 +17,22 @@ 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._get_operations import ( build_integration_runtime_enable_interactivequery_request, build_integration_runtime_start_request, build_integration_runtime_stop_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -81,12 +78,11 @@ async def integration_runtime_start( :type integration_runtime_name: str :param integration_runtime_operation_id: Integration runtime Operation Id. Required. :type integration_runtime_operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: IntegrationRuntimeOperationStatus or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeOperationStatus :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,27 +93,24 @@ async def integration_runtime_start( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.IntegrationRuntimeOperationStatus] = kwargs.pop("cls", None) - request = build_integration_runtime_start_request( + _request = build_integration_runtime_start_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, integration_runtime_operation_id=integration_runtime_operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.integration_runtime_start.metadata["url"], 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -127,16 +120,12 @@ async def integration_runtime_start( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("IntegrationRuntimeOperationStatus", pipeline_response) + deserialized = self._deserialize("IntegrationRuntimeOperationStatus", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - integration_runtime_start.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/start/operationstatuses/{integrationRuntimeOperationId}" - } + return deserialized # type: ignore @distributed_trace_async async def integration_runtime_stop( @@ -160,12 +149,11 @@ async def integration_runtime_stop( :type integration_runtime_name: str :param integration_runtime_operation_id: Integration runtime Operation Id. Required. :type integration_runtime_operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: IntegrationRuntimeStopOperationStatus or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeStopOperationStatus :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -176,27 +164,24 @@ async def integration_runtime_stop( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.IntegrationRuntimeStopOperationStatus] = kwargs.pop("cls", None) - request = build_integration_runtime_stop_request( + _request = build_integration_runtime_stop_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, integration_runtime_operation_id=integration_runtime_operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.integration_runtime_stop.metadata["url"], 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -206,19 +191,15 @@ async def integration_runtime_stop( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("IntegrationRuntimeStopOperationStatus", pipeline_response) + deserialized = self._deserialize("IntegrationRuntimeStopOperationStatus", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - integration_runtime_stop.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/stop/operationstatuses/{integrationRuntimeOperationId}" - } + return deserialized # type: ignore @distributed_trace_async - async def integration_runtime_enable_interactivequery( + async def integration_runtime_enable_interactivequery( # pylint: disable=name-too-long self, resource_group_name: str, workspace_name: str, @@ -239,12 +220,11 @@ async def integration_runtime_enable_interactivequery( :type integration_runtime_name: str :param integration_runtime_operation_id: Integration runtime Operation Id. Required. :type integration_runtime_operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: IntegrationRuntimeEnableinteractivequery or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeEnableinteractivequery :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -255,27 +235,24 @@ async def integration_runtime_enable_interactivequery( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.IntegrationRuntimeEnableinteractivequery] = kwargs.pop("cls", None) - request = build_integration_runtime_enable_interactivequery_request( + _request = build_integration_runtime_enable_interactivequery_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, integration_runtime_operation_id=integration_runtime_operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.integration_runtime_enable_interactivequery.metadata["url"], 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -285,13 +262,9 @@ async def integration_runtime_enable_interactivequery( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("IntegrationRuntimeEnableinteractivequery", pipeline_response) + deserialized = self._deserialize("IntegrationRuntimeEnableinteractivequery", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - integration_runtime_enable_interactivequery.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/enableinteractivequery/operationstatuses/{integrationRuntimeOperationId}" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_integration_runtime_auth_keys_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_integration_runtime_auth_keys_operations.py index 99fc4a85023f..eddf9d079f0d 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_integration_runtime_auth_keys_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_integration_runtime_auth_keys_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload @@ -18,20 +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._integration_runtime_auth_keys_operations import build_list_request, build_regenerate_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -84,7 +82,6 @@ async def regenerate( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. 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: IntegrationRuntimeAuthKeys or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeAuthKeys :raises ~azure.core.exceptions.HttpResponseError: @@ -96,7 +93,7 @@ async def regenerate( resource_group_name: str, workspace_name: str, integration_runtime_name: str, - regenerate_key_parameters: IO, + regenerate_key_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -114,11 +111,10 @@ async def regenerate( :type integration_runtime_name: str :param regenerate_key_parameters: The parameters for regenerating integration runtime authentication key. Required. - :type regenerate_key_parameters: IO + :type regenerate_key_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: IntegrationRuntimeAuthKeys or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeAuthKeys :raises ~azure.core.exceptions.HttpResponseError: @@ -130,7 +126,7 @@ async def regenerate( resource_group_name: str, workspace_name: str, integration_runtime_name: str, - regenerate_key_parameters: Union[_models.IntegrationRuntimeRegenerateKeyParameters, IO], + regenerate_key_parameters: Union[_models.IntegrationRuntimeRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.IntegrationRuntimeAuthKeys: """Regenerate integration runtime authentication key. @@ -145,18 +141,15 @@ async def regenerate( :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str :param regenerate_key_parameters: The parameters for regenerating integration runtime - authentication key. Is either a model type or a IO type. Required. + authentication key. Is either a IntegrationRuntimeRegenerateKeyParameters type or a IO[bytes] + type. Required. :type regenerate_key_parameters: - ~azure.mgmt.synapse.models.IntegrationRuntimeRegenerateKeyParameters 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.synapse.models.IntegrationRuntimeRegenerateKeyParameters or IO[bytes] :return: IntegrationRuntimeAuthKeys or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeAuthKeys :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -167,21 +160,19 @@ async def regenerate( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IntegrationRuntimeAuthKeys] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(regenerate_key_parameters, (IO, bytes)): + if isinstance(regenerate_key_parameters, (IOBase, bytes)): _content = regenerate_key_parameters else: _json = self._serialize.body(regenerate_key_parameters, "IntegrationRuntimeRegenerateKeyParameters") - request = build_regenerate_request( + _request = build_regenerate_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, @@ -190,15 +181,14 @@ async def regenerate( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate.metadata["url"], 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -208,16 +198,12 @@ async def regenerate( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("IntegrationRuntimeAuthKeys", pipeline_response) + deserialized = self._deserialize("IntegrationRuntimeAuthKeys", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - regenerate.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/regenerateAuthKey" - } + return deserialized # type: ignore @distributed_trace_async async def list( @@ -234,12 +220,11 @@ async def list( :type workspace_name: str :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: IntegrationRuntimeAuthKeys or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeAuthKeys :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -250,26 +235,23 @@ async def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.IntegrationRuntimeAuthKeys] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_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) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -279,13 +261,9 @@ async def list( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("IntegrationRuntimeAuthKeys", pipeline_response) + deserialized = self._deserialize("IntegrationRuntimeAuthKeys", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/listAuthKeys" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_integration_runtime_connection_infos_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_integration_runtime_connection_infos_operations.py index bb554e4612ad..049ac68d5c90 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_integration_runtime_connection_infos_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_integration_runtime_connection_infos_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -18,25 +17,23 @@ 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._integration_runtime_connection_infos_operations import build_get_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class IntegrationRuntimeConnectionInfosOperations: +class IntegrationRuntimeConnectionInfosOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -70,12 +67,11 @@ async def get( :type workspace_name: str :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: IntegrationRuntimeConnectionInfo or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeConnectionInfo :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -86,26 +82,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.IntegrationRuntimeConnectionInfo] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -115,13 +108,9 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("IntegrationRuntimeConnectionInfo", pipeline_response) + deserialized = self._deserialize("IntegrationRuntimeConnectionInfo", 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.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/getConnectionInfo" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_integration_runtime_credentials_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_integration_runtime_credentials_operations.py index 71bc45e63b71..fb6d14c14649 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_integration_runtime_credentials_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_integration_runtime_credentials_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -18,20 +17,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._integration_runtime_credentials_operations import build_sync_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,7 +53,7 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def sync( # pylint: disable=inconsistent-return-statements + async def sync( self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any ) -> None: """Sync integration runtime credentials. @@ -73,12 +70,11 @@ async def sync( # pylint: disable=inconsistent-return-statements :type workspace_name: str :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -89,26 +85,23 @@ async def sync( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_sync_request( + _request = build_sync_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.sync.metadata["url"], 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -119,8 +112,4 @@ async def sync( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - sync.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/syncCredentials" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_integration_runtime_monitoring_data_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_integration_runtime_monitoring_data_operations.py index de012f3c57f0..a2e6eddd4bdc 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_integration_runtime_monitoring_data_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_integration_runtime_monitoring_data_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -18,25 +17,23 @@ 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._integration_runtime_monitoring_data_operations import build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class IntegrationRuntimeMonitoringDataOperations: +class IntegrationRuntimeMonitoringDataOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -70,12 +67,11 @@ async def list( :type workspace_name: str :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: IntegrationRuntimeMonitoringData or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeMonitoringData :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -86,26 +82,23 @@ async def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.IntegrationRuntimeMonitoringData] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_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) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -115,13 +108,9 @@ async def list( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("IntegrationRuntimeMonitoringData", pipeline_response) + deserialized = self._deserialize("IntegrationRuntimeMonitoringData", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/monitoringData" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_integration_runtime_node_ip_address_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_integration_runtime_node_ip_address_operations.py index 6969cf0a6730..0f900ec4c9f4 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_integration_runtime_node_ip_address_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_integration_runtime_node_ip_address_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -18,25 +17,23 @@ 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._integration_runtime_node_ip_address_operations import build_get_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class IntegrationRuntimeNodeIpAddressOperations: +class IntegrationRuntimeNodeIpAddressOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -77,12 +74,11 @@ async def get( :type integration_runtime_name: str :param node_name: Integration runtime node name. Required. :type node_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: IntegrationRuntimeNodeIpAddress or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeNodeIpAddress :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -93,27 +89,24 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.IntegrationRuntimeNodeIpAddress] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, node_name=node_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -123,13 +116,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("IntegrationRuntimeNodeIpAddress", pipeline_response) + deserialized = self._deserialize("IntegrationRuntimeNodeIpAddress", 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.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/nodes/{nodeName}/ipAddress" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_integration_runtime_nodes_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_integration_runtime_nodes_operations.py index 1f0536f0b52d..659f82e735b2 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_integration_runtime_nodes_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_integration_runtime_nodes_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload @@ -18,24 +18,22 @@ 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._integration_runtime_nodes_operations import ( build_delete_request, build_get_request, build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -81,12 +79,11 @@ async def get( :type integration_runtime_name: str :param node_name: Integration runtime node name. Required. :type node_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SelfHostedIntegrationRuntimeNode or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SelfHostedIntegrationRuntimeNode :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,27 +94,24 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.SelfHostedIntegrationRuntimeNode] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, node_name=node_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -127,16 +121,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("SelfHostedIntegrationRuntimeNode", pipeline_response) + deserialized = self._deserialize("SelfHostedIntegrationRuntimeNode", 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.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/nodes/{nodeName}" - } + return deserialized # type: ignore @overload async def update( @@ -170,7 +160,6 @@ async def 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 :return: SelfHostedIntegrationRuntimeNode or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SelfHostedIntegrationRuntimeNode :raises ~azure.core.exceptions.HttpResponseError: @@ -183,7 +172,7 @@ async def update( workspace_name: str, integration_runtime_name: str, node_name: str, - update_integration_runtime_node_request: IO, + update_integration_runtime_node_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -203,11 +192,10 @@ async def update( :type node_name: str :param update_integration_runtime_node_request: The parameters for updating an integration runtime node. Required. - :type update_integration_runtime_node_request: IO + :type update_integration_runtime_node_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 :return: SelfHostedIntegrationRuntimeNode or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SelfHostedIntegrationRuntimeNode :raises ~azure.core.exceptions.HttpResponseError: @@ -220,7 +208,7 @@ async def update( workspace_name: str, integration_runtime_name: str, node_name: str, - update_integration_runtime_node_request: Union[_models.UpdateIntegrationRuntimeNodeRequest, IO], + update_integration_runtime_node_request: Union[_models.UpdateIntegrationRuntimeNodeRequest, IO[bytes]], **kwargs: Any ) -> _models.SelfHostedIntegrationRuntimeNode: """Create integration runtime node. @@ -237,18 +225,15 @@ async def update( :param node_name: Integration runtime node name. Required. :type node_name: str :param update_integration_runtime_node_request: The parameters for updating an integration - runtime node. Is either a model type or a IO type. Required. + runtime node. Is either a UpdateIntegrationRuntimeNodeRequest type or a IO[bytes] type. + Required. :type update_integration_runtime_node_request: - ~azure.mgmt.synapse.models.UpdateIntegrationRuntimeNodeRequest 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.synapse.models.UpdateIntegrationRuntimeNodeRequest or IO[bytes] :return: SelfHostedIntegrationRuntimeNode or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SelfHostedIntegrationRuntimeNode :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -259,21 +244,19 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SelfHostedIntegrationRuntimeNode] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(update_integration_runtime_node_request, (IO, bytes)): + if isinstance(update_integration_runtime_node_request, (IOBase, bytes)): _content = update_integration_runtime_node_request else: _json = self._serialize.body(update_integration_runtime_node_request, "UpdateIntegrationRuntimeNodeRequest") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, @@ -283,15 +266,14 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -301,19 +283,15 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SelfHostedIntegrationRuntimeNode", pipeline_response) + deserialized = self._deserialize("SelfHostedIntegrationRuntimeNode", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/nodes/{nodeName}" - } + return deserialized # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements + async def delete( self, resource_group_name: str, workspace_name: str, @@ -334,12 +312,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :type integration_runtime_name: str :param node_name: Integration runtime node name. Required. :type node_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -350,27 +327,24 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, node_name=node_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -381,8 +355,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/nodes/{nodeName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_integration_runtime_object_metadata_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_integration_runtime_object_metadata_operations.py index f42a69fbcad7..2b542b3d3049 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_integration_runtime_object_metadata_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_integration_runtime_object_metadata_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,30 +15,30 @@ 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_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._integration_runtime_object_metadata_operations import build_list_request, build_refresh_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class IntegrationRuntimeObjectMetadataOperations: +class IntegrationRuntimeObjectMetadataOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -85,7 +85,6 @@ async def list( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. 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: SsisObjectMetadataListResponse or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SsisObjectMetadataListResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -97,7 +96,7 @@ async def list( resource_group_name: str, workspace_name: str, integration_runtime_name: str, - get_metadata_request: Optional[IO] = None, + get_metadata_request: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -115,11 +114,10 @@ async def list( :type integration_runtime_name: str :param get_metadata_request: The parameters for getting a SSIS object metadata. Default value is None. - :type get_metadata_request: IO + :type get_metadata_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 :return: SsisObjectMetadataListResponse or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SsisObjectMetadataListResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -131,7 +129,7 @@ async def list( resource_group_name: str, workspace_name: str, integration_runtime_name: str, - get_metadata_request: Optional[Union[_models.GetSsisObjectMetadataRequest, IO]] = None, + get_metadata_request: Optional[Union[_models.GetSsisObjectMetadataRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.SsisObjectMetadataListResponse: """Get integration runtime object metadata. @@ -146,17 +144,14 @@ async def list( :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str :param get_metadata_request: The parameters for getting a SSIS object metadata. Is either a - model type or a IO type. Default value is None. - :type get_metadata_request: ~azure.mgmt.synapse.models.GetSsisObjectMetadataRequest 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 + GetSsisObjectMetadataRequest type or a IO[bytes] type. Default value is None. + :type get_metadata_request: ~azure.mgmt.synapse.models.GetSsisObjectMetadataRequest or + IO[bytes] :return: SsisObjectMetadataListResponse or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SsisObjectMetadataListResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -167,16 +162,14 @@ async def list( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SsisObjectMetadataListResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(get_metadata_request, (IO, bytes)): + if isinstance(get_metadata_request, (IOBase, bytes)): _content = get_metadata_request else: if get_metadata_request is not None: @@ -184,7 +177,7 @@ async def list( else: _json = None - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, @@ -193,15 +186,14 @@ async def list( content_type=content_type, json=_json, content=_content, - 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) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -211,21 +203,17 @@ async def list( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SsisObjectMetadataListResponse", pipeline_response) + deserialized = self._deserialize("SsisObjectMetadataListResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/getObjectMetadata" - } + return deserialized # type: ignore async def _refresh_initial( self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any - ) -> Optional[_models.SsisObjectMetadataStatusResponse]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -236,47 +224,43 @@ async def _refresh_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) - cls: ClsType[Optional[_models.SsisObjectMetadataStatusResponse]] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_refresh_request( + _request = build_refresh_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._refresh_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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 - if response.status_code == 200: - deserialized = self._deserialize("SsisObjectMetadataStatusResponse", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _refresh_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/refreshObjectMetadata" - } + return deserialized # type: ignore @distributed_trace_async async def begin_refresh( @@ -293,14 +277,6 @@ async def begin_refresh( :type workspace_name: str :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_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 SsisObjectMetadataStatusResponse or the result of cls(response) :rtype: @@ -310,9 +286,7 @@ async def begin_refresh( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.SsisObjectMetadataStatusResponse] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -328,12 +302,13 @@ async def begin_refresh( 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("SsisObjectMetadataStatusResponse", pipeline_response) + deserialized = self._deserialize("SsisObjectMetadataStatusResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -346,14 +321,12 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.SsisObjectMetadataStatusResponse].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_refresh.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/refreshObjectMetadata" - } + return AsyncLROPoller[_models.SsisObjectMetadataStatusResponse]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_integration_runtime_status_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_integration_runtime_status_operations.py index 34851f8c991c..bed85722fc52 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_integration_runtime_status_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_integration_runtime_status_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -18,20 +17,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._integration_runtime_status_operations import build_get_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -70,12 +67,11 @@ async def get( :type workspace_name: str :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: IntegrationRuntimeStatusResponse or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeStatusResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -86,26 +82,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.IntegrationRuntimeStatusResponse] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -115,13 +108,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("IntegrationRuntimeStatusResponse", pipeline_response) + deserialized = self._deserialize("IntegrationRuntimeStatusResponse", 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.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/getStatus" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_integration_runtimes_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_integration_runtimes_operations.py index b7f3e5e10759..448997a07db1 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_integration_runtimes_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_integration_runtimes_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -16,12 +17,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 @@ -29,7 +31,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._integration_runtimes_operations import ( build_create_request, build_delete_request, @@ -44,10 +45,10 @@ build_upgrade_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -100,7 +101,6 @@ async def 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 :return: IntegrationRuntimeResource or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeResource :raises ~azure.core.exceptions.HttpResponseError: @@ -112,7 +112,7 @@ async def update( resource_group_name: str, workspace_name: str, integration_runtime_name: str, - update_integration_runtime_request: IO, + update_integration_runtime_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -130,11 +130,10 @@ async def update( :type integration_runtime_name: str :param update_integration_runtime_request: The parameters for updating an integration runtime. Required. - :type update_integration_runtime_request: IO + :type update_integration_runtime_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 :return: IntegrationRuntimeResource or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeResource :raises ~azure.core.exceptions.HttpResponseError: @@ -146,7 +145,7 @@ async def update( resource_group_name: str, workspace_name: str, integration_runtime_name: str, - update_integration_runtime_request: Union[_models.UpdateIntegrationRuntimeRequest, IO], + update_integration_runtime_request: Union[_models.UpdateIntegrationRuntimeRequest, IO[bytes]], **kwargs: Any ) -> _models.IntegrationRuntimeResource: """Update integration runtime. @@ -161,18 +160,14 @@ async def update( :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str :param update_integration_runtime_request: The parameters for updating an integration runtime. - Is either a model type or a IO type. Required. + Is either a UpdateIntegrationRuntimeRequest type or a IO[bytes] type. Required. :type update_integration_runtime_request: - ~azure.mgmt.synapse.models.UpdateIntegrationRuntimeRequest 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.synapse.models.UpdateIntegrationRuntimeRequest or IO[bytes] :return: IntegrationRuntimeResource or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -183,21 +178,19 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IntegrationRuntimeResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(update_integration_runtime_request, (IO, bytes)): + if isinstance(update_integration_runtime_request, (IOBase, bytes)): _content = update_integration_runtime_request else: _json = self._serialize.body(update_integration_runtime_request, "UpdateIntegrationRuntimeRequest") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, @@ -206,15 +199,14 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -224,16 +216,12 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("IntegrationRuntimeResource", pipeline_response) + deserialized = self._deserialize("IntegrationRuntimeResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -259,12 +247,11 @@ async def get( If the ETag matches the existing entity tag, or if * was provided, then no content will be returned. Default value is None. :type if_none_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: IntegrationRuntimeResource or None or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeResource or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -275,27 +262,24 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[Optional[_models.IntegrationRuntimeResource]] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, subscription_id=self._config.subscription_id, if_none_match=if_none_match, 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -307,27 +291,23 @@ async def get( deserialized = None if response.status_code == 200: - deserialized = self._deserialize("IntegrationRuntimeResource", pipeline_response) + deserialized = self._deserialize("IntegrationRuntimeResource", 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.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, - integration_runtime: Union[_models.IntegrationRuntimeResource, IO], + integration_runtime: Union[_models.IntegrationRuntimeResource, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.IntegrationRuntimeResource]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -338,21 +318,19 @@ async def _create_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.IntegrationRuntimeResource]] = 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(integration_runtime, (IO, bytes)): + if isinstance(integration_runtime, (IOBase, bytes)): _content = integration_runtime else: _json = self._serialize.body(integration_runtime, "IntegrationRuntimeResource") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, @@ -362,36 +340,34 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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=False, **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 - if response.status_code == 200: - deserialized = self._deserialize("IntegrationRuntimeResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}" - } + return deserialized # type: ignore @overload async def begin_create( @@ -425,14 +401,6 @@ async def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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 IntegrationRuntimeResource or the result of cls(response) :rtype: @@ -446,7 +414,7 @@ async def begin_create( resource_group_name: str, workspace_name: str, integration_runtime_name: str, - integration_runtime: IO, + integration_runtime: IO[bytes], if_match: Optional[str] = None, *, content_type: str = "application/json", @@ -464,7 +432,7 @@ async def begin_create( :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str :param integration_runtime: Integration runtime resource definition. Required. - :type integration_runtime: IO + :type integration_runtime: IO[bytes] :param if_match: ETag of the integration runtime entity. Should only be specified for update, for which it should match existing entity or can be * for unconditional update. Default value is None. @@ -472,14 +440,6 @@ async def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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 IntegrationRuntimeResource or the result of cls(response) :rtype: @@ -493,7 +453,7 @@ async def begin_create( resource_group_name: str, workspace_name: str, integration_runtime_name: str, - integration_runtime: Union[_models.IntegrationRuntimeResource, IO], + integration_runtime: Union[_models.IntegrationRuntimeResource, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any ) -> AsyncLROPoller[_models.IntegrationRuntimeResource]: @@ -508,24 +468,13 @@ async def begin_create( :type workspace_name: str :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :param integration_runtime: Integration runtime resource definition. Is either a model type or - a IO type. Required. - :type integration_runtime: ~azure.mgmt.synapse.models.IntegrationRuntimeResource or IO + :param integration_runtime: Integration runtime resource definition. Is either a + IntegrationRuntimeResource type or a IO[bytes] type. Required. + :type integration_runtime: ~azure.mgmt.synapse.models.IntegrationRuntimeResource or IO[bytes] :param if_match: ETag of the integration runtime entity. Should only be specified for update, for which it should match existing entity or can be * for unconditional update. 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 IntegrationRuntimeResource or the result of cls(response) :rtype: @@ -535,9 +484,7 @@ async def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IntegrationRuntimeResource] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -557,12 +504,13 @@ async def begin_create( 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("IntegrationRuntimeResource", pipeline_response) + deserialized = self._deserialize("IntegrationRuntimeResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -572,22 +520,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.IntegrationRuntimeResource].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}" - } + return AsyncLROPoller[_models.IntegrationRuntimeResource]( + 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, workspace_name: str, integration_runtime_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -598,41 +544,43 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -649,14 +597,6 @@ async def begin_delete( :type workspace_name: str :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_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: @@ -664,15 +604,13 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, @@ -682,11 +620,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)) @@ -695,20 +634,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.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async - async def upgrade( # pylint: disable=inconsistent-return-statements + async def upgrade( self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any ) -> None: """Upgrade integration runtime. @@ -722,12 +657,11 @@ async def upgrade( # pylint: disable=inconsistent-return-statements :type workspace_name: str :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -738,26 +672,23 @@ async def upgrade( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_upgrade_request( + _request = build_upgrade_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.upgrade.metadata["url"], 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -768,11 +699,7 @@ async def upgrade( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - upgrade.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/upgrade" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list_by_workspace( @@ -787,7 +714,6 @@ def list_by_workspace( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either IntegrationRuntimeResource or the result of cls(response) :rtype: @@ -797,12 +723,10 @@ def list_by_workspace( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.IntegrationRuntimeListResponse] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -813,24 +737,21 @@ def list_by_workspace( def prepare_request(next_link=None): if not next_link: - request = build_list_by_workspace_request( + _request = build_list_by_workspace_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_workspace.metadata["url"], 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("IntegrationRuntimeListResponse", pipeline_response) @@ -840,10 +761,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -856,14 +778,10 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_workspace.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes" - } - async def _start_initial( self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any - ) -> Optional[_models.IntegrationRuntimeStatusResponse]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -874,47 +792,43 @@ async def _start_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) - cls: ClsType[Optional[_models.IntegrationRuntimeStatusResponse]] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_start_request( + _request = build_start_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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 - if response.status_code == 200: - deserialized = self._deserialize("IntegrationRuntimeStatusResponse", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _start_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/start" - } + return deserialized # type: ignore @distributed_trace_async async def begin_start( @@ -931,14 +845,6 @@ async def begin_start( :type workspace_name: str :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_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 IntegrationRuntimeStatusResponse or the result of cls(response) :rtype: @@ -948,9 +854,7 @@ async def begin_start( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.IntegrationRuntimeStatusResponse] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -966,12 +870,13 @@ async def begin_start( 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("IntegrationRuntimeStatusResponse", pipeline_response) + deserialized = self._deserialize("IntegrationRuntimeStatusResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -984,22 +889,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.IntegrationRuntimeStatusResponse].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.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/start" - } + return AsyncLROPoller[_models.IntegrationRuntimeStatusResponse]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _stop_initial( # pylint: disable=inconsistent-return-statements + async def _stop_initial( self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1010,41 +913,43 @@ async def _stop_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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 = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _stop_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/stop" - } + return deserialized # type: ignore @distributed_trace_async async def begin_stop( @@ -1061,14 +966,6 @@ async def begin_stop( :type workspace_name: str :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_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: @@ -1076,15 +973,13 @@ async def begin_stop( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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._stop_initial( # type: ignore + raw_result = await self._stop_initial( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, @@ -1094,11 +989,12 @@ async def begin_stop( 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)) @@ -1107,20 +1003,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_stop.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/stop" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async - async def list_outbound_network_dependencies_endpoints( + async def list_outbound_network_dependencies_endpoints( # pylint: disable=name-too-long self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any ) -> _models.IntegrationRuntimeOutboundNetworkDependenciesEndpointsResponse: """Gets list of outbound network dependencies for a given Azure-SSIS integration runtime. @@ -1134,14 +1026,13 @@ async def list_outbound_network_dependencies_endpoints( :type workspace_name: str :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: IntegrationRuntimeOutboundNetworkDependenciesEndpointsResponse or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeOutboundNetworkDependenciesEndpointsResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1152,26 +1043,23 @@ async def list_outbound_network_dependencies_endpoints( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.IntegrationRuntimeOutboundNetworkDependenciesEndpointsResponse] = kwargs.pop("cls", None) - request = build_list_outbound_network_dependencies_endpoints_request( + _request = build_list_outbound_network_dependencies_endpoints_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_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) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1182,22 +1070,18 @@ async def list_outbound_network_dependencies_endpoints( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize( - "IntegrationRuntimeOutboundNetworkDependenciesEndpointsResponse", pipeline_response + "IntegrationRuntimeOutboundNetworkDependenciesEndpointsResponse", pipeline_response.http_response ) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - list_outbound_network_dependencies_endpoints.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/outboundNetworkDependenciesEndpoints" - } - - async def _enable_interactive_query_initial( # pylint: disable=inconsistent-return-statements + async def _enable_interactive_query_initial( self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1208,41 +1092,43 @@ async def _enable_interactive_query_initial( # pylint: disable=inconsistent-ret _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_enable_interactive_query_request( + _request = build_enable_interactive_query_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._enable_interactive_query_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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 = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _enable_interactive_query_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/enableInteractiveQuery" - } + return deserialized # type: ignore @distributed_trace_async async def begin_enable_interactive_query( @@ -1257,14 +1143,6 @@ async def begin_enable_interactive_query( :type workspace_name: str :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_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: @@ -1272,15 +1150,13 @@ async def begin_enable_interactive_query( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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._enable_interactive_query_initial( # type: ignore + raw_result = await self._enable_interactive_query_initial( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, @@ -1290,11 +1166,12 @@ async def begin_enable_interactive_query( 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)) @@ -1303,22 +1180,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_enable_interactive_query.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/enableInteractiveQuery" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _disable_interactive_query_initial( # pylint: disable=inconsistent-return-statements + async def _disable_interactive_query_initial( self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1329,41 +1202,43 @@ async def _disable_interactive_query_initial( # pylint: disable=inconsistent-re _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_disable_interactive_query_request( + _request = build_disable_interactive_query_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._disable_interactive_query_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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 = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _disable_interactive_query_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/disableInteractiveQuery" - } + return deserialized # type: ignore @distributed_trace_async async def begin_disable_interactive_query( @@ -1378,14 +1253,6 @@ async def begin_disable_interactive_query( :type workspace_name: str :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_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: @@ -1393,15 +1260,13 @@ async def begin_disable_interactive_query( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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._disable_interactive_query_initial( # type: ignore + raw_result = await self._disable_interactive_query_initial( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, @@ -1411,11 +1276,12 @@ async def begin_disable_interactive_query( 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)) @@ -1424,14 +1290,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_disable_interactive_query.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/disableInteractiveQuery" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_ip_firewall_rules_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_ip_firewall_rules_operations.py index ac36275cd84e..df6a9d6782df 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_ip_firewall_rules_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_ip_firewall_rules_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -16,12 +16,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 @@ -29,7 +30,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._ip_firewall_rules_operations import ( build_create_or_update_request, build_delete_request, @@ -38,10 +38,10 @@ build_replace_all_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -76,7 +76,6 @@ def list_by_workspace( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either IpFirewallRuleInfo or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.IpFirewallRuleInfo] :raises ~azure.core.exceptions.HttpResponseError: @@ -84,10 +83,10 @@ def list_by_workspace( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.IpFirewallRuleInfoListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -98,24 +97,21 @@ def list_by_workspace( def prepare_request(next_link=None): if not next_link: - request = build_list_by_workspace_request( + _request = build_list_by_workspace_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_workspace.metadata["url"], 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("IpFirewallRuleInfoListResult", pipeline_response) @@ -125,10 +121,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -141,19 +138,15 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_workspace.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/firewallRules" - } - async def _create_or_update_initial( self, resource_group_name: str, workspace_name: str, rule_name: str, - ip_firewall_rule_info: Union[_models.IpFirewallRuleInfo, IO], + ip_firewall_rule_info: Union[_models.IpFirewallRuleInfo, IO[bytes]], **kwargs: Any - ) -> Optional[_models.IpFirewallRuleInfo]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -164,19 +157,19 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.IpFirewallRuleInfo]] = 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(ip_firewall_rule_info, (IO, bytes)): + if isinstance(ip_firewall_rule_info, (IOBase, bytes)): _content = ip_firewall_rule_info else: _json = self._serialize.body(ip_firewall_rule_info, "IpFirewallRuleInfo") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, rule_name=rule_name, @@ -185,39 +178,34 @@ 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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("IpFirewallRuleInfo", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("IpFirewallRuleInfo", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/firewallRules/{ruleName}" - } + return deserialized # type: ignore @overload async def begin_create_or_update( @@ -244,14 +232,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 IpFirewallRuleInfo or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.IpFirewallRuleInfo] @@ -264,7 +244,7 @@ async def begin_create_or_update( resource_group_name: str, workspace_name: str, rule_name: str, - ip_firewall_rule_info: IO, + ip_firewall_rule_info: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -279,18 +259,10 @@ async def begin_create_or_update( :param rule_name: The IP firewall rule name. Required. :type rule_name: str :param ip_firewall_rule_info: IP firewall rule properties. Required. - :type ip_firewall_rule_info: IO + :type ip_firewall_rule_info: 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 IpFirewallRuleInfo or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.IpFirewallRuleInfo] @@ -303,7 +275,7 @@ async def begin_create_or_update( resource_group_name: str, workspace_name: str, rule_name: str, - ip_firewall_rule_info: Union[_models.IpFirewallRuleInfo, IO], + ip_firewall_rule_info: Union[_models.IpFirewallRuleInfo, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.IpFirewallRuleInfo]: """Creates or updates a firewall rule. @@ -315,20 +287,9 @@ async def begin_create_or_update( :type workspace_name: str :param rule_name: The IP firewall rule name. Required. :type rule_name: str - :param ip_firewall_rule_info: IP firewall rule properties. Is either a model type or a IO type. - Required. - :type ip_firewall_rule_info: ~azure.mgmt.synapse.models.IpFirewallRuleInfo 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 ip_firewall_rule_info: IP firewall rule properties. Is either a IpFirewallRuleInfo type + or a IO[bytes] type. Required. + :type ip_firewall_rule_info: ~azure.mgmt.synapse.models.IpFirewallRuleInfo or IO[bytes] :return: An instance of AsyncLROPoller that returns either IpFirewallRuleInfo or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.IpFirewallRuleInfo] @@ -337,7 +298,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IpFirewallRuleInfo] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -356,12 +317,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("IpFirewallRuleInfo", pipeline_response) + deserialized = self._deserialize("IpFirewallRuleInfo", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -373,22 +335,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.IpFirewallRuleInfo].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.Synapse/workspaces/{workspaceName}/firewallRules/{ruleName}" - } + return AsyncLROPoller[_models.IpFirewallRuleInfo]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _delete_initial( self, resource_group_name: str, workspace_name: str, rule_name: str, **kwargs: Any - ) -> Optional[_models.IpFirewallRuleInfo]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -399,45 +359,43 @@ async def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - cls: ClsType[Optional[_models.IpFirewallRuleInfo]] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_name, rule_name=rule_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("IpFirewallRuleInfo", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/firewallRules/{ruleName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -452,14 +410,6 @@ async def begin_delete( :type workspace_name: str :param rule_name: The IP firewall rule name. Required. :type rule_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 IpFirewallRuleInfo or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.IpFirewallRuleInfo] @@ -468,7 +418,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.IpFirewallRuleInfo] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -484,12 +434,13 @@ 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): - deserialized = self._deserialize("IpFirewallRuleInfo", pipeline_response) + deserialized = self._deserialize("IpFirewallRuleInfo", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -501,17 +452,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.IpFirewallRuleInfo].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.Synapse/workspaces/{workspaceName}/firewallRules/{ruleName}" - } + return AsyncLROPoller[_models.IpFirewallRuleInfo]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def get( @@ -526,12 +475,11 @@ async def get( :type workspace_name: str :param rule_name: The IP firewall rule name. Required. :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: IpFirewallRuleInfo or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IpFirewallRuleInfo :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -542,24 +490,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.IpFirewallRuleInfo] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, rule_name=rule_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -569,25 +516,21 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("IpFirewallRuleInfo", pipeline_response) + deserialized = self._deserialize("IpFirewallRuleInfo", 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.Synapse/workspaces/{workspaceName}/firewallRules/{ruleName}" - } + return deserialized # type: ignore async def _replace_all_initial( self, resource_group_name: str, workspace_name: str, - request: Union[_models.ReplaceAllIpFirewallRulesRequest, IO], + request: Union[_models.ReplaceAllIpFirewallRulesRequest, IO[bytes]], **kwargs: Any - ) -> Optional[_models.ReplaceAllFirewallRulesOperationResponse]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -598,19 +541,19 @@ async def _replace_all_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.ReplaceAllFirewallRulesOperationResponse]] = 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(request, (IO, bytes)): + if isinstance(request, (IOBase, bytes)): _content = request else: _json = self._serialize.body(request, "ReplaceAllIpFirewallRulesRequest") - request = build_replace_all_request( + _request = build_replace_all_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, @@ -618,36 +561,34 @@ async def _replace_all_initial( content_type=content_type, json=_json, content=_content, - template_url=self._replace_all_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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 - if response.status_code == 200: - deserialized = self._deserialize("ReplaceAllFirewallRulesOperationResponse", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _replace_all_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/replaceAllIpFirewallRules" - } + return deserialized # type: ignore @overload async def begin_replace_all( @@ -671,14 +612,6 @@ async def begin_replace_all( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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 ReplaceAllFirewallRulesOperationResponse or the result of cls(response) :rtype: @@ -691,7 +624,7 @@ async def begin_replace_all( self, resource_group_name: str, workspace_name: str, - request: IO, + request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -704,18 +637,10 @@ async def begin_replace_all( :param workspace_name: The name of the workspace. Required. :type workspace_name: str :param request: Replace all IP firewall rules request. Required. - :type request: IO + :type 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 ReplaceAllFirewallRulesOperationResponse or the result of cls(response) :rtype: @@ -728,7 +653,7 @@ async def begin_replace_all( self, resource_group_name: str, workspace_name: str, - request: Union[_models.ReplaceAllIpFirewallRulesRequest, IO], + request: Union[_models.ReplaceAllIpFirewallRulesRequest, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.ReplaceAllFirewallRulesOperationResponse]: """Replaces firewall rules. @@ -738,20 +663,9 @@ async def begin_replace_all( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param request: Replace all IP firewall rules request. Is either a model type or a IO type. - Required. - :type request: ~azure.mgmt.synapse.models.ReplaceAllIpFirewallRulesRequest 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 request: Replace all IP firewall rules request. Is either a + ReplaceAllIpFirewallRulesRequest type or a IO[bytes] type. Required. + :type request: ~azure.mgmt.synapse.models.ReplaceAllIpFirewallRulesRequest or IO[bytes] :return: An instance of AsyncLROPoller that returns either ReplaceAllFirewallRulesOperationResponse or the result of cls(response) :rtype: @@ -761,7 +675,7 @@ async def begin_replace_all( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ReplaceAllFirewallRulesOperationResponse] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -779,12 +693,15 @@ async def begin_replace_all( 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("ReplaceAllFirewallRulesOperationResponse", pipeline_response) + deserialized = self._deserialize( + "ReplaceAllFirewallRulesOperationResponse", 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,14 +713,12 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.ReplaceAllFirewallRulesOperationResponse].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_replace_all.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/replaceAllIpFirewallRules" - } + return AsyncLROPoller[_models.ReplaceAllFirewallRulesOperationResponse]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_keys_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_keys_operations.py index 273b2f73a4d6..417a71c24fa0 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_keys_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_keys_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload @@ -19,15 +19,13 @@ 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._keys_operations import ( build_create_or_update_request, build_delete_request, @@ -35,10 +33,10 @@ build_list_by_workspace_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -73,7 +71,6 @@ def list_by_workspace( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Key or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.Key] :raises ~azure.core.exceptions.HttpResponseError: @@ -81,10 +78,10 @@ def list_by_workspace( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.KeyInfoListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -95,24 +92,21 @@ def list_by_workspace( def prepare_request(next_link=None): if not next_link: - request = build_list_by_workspace_request( + _request = build_list_by_workspace_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_workspace.metadata["url"], 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("KeyInfoListResult", pipeline_response) @@ -122,10 +116,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -138,10 +133,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_workspace.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/keys" - } - @distributed_trace_async async def get(self, resource_group_name: str, workspace_name: str, key_name: str, **kwargs: Any) -> _models.Key: """Gets a workspace key. @@ -153,12 +144,11 @@ async def get(self, resource_group_name: str, workspace_name: str, key_name: str :type workspace_name: str :param key_name: The name of the workspace key. Required. :type key_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Key or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -169,24 +159,23 @@ async def get(self, resource_group_name: str, workspace_name: str, key_name: str _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.Key] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, key_name=key_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -196,16 +185,12 @@ async def get(self, resource_group_name: str, workspace_name: str, key_name: str error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Key", pipeline_response) + deserialized = self._deserialize("Key", 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.Synapse/workspaces/{workspaceName}/keys/{keyName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -232,7 +217,6 @@ async def 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 :return: Key or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.Key :raises ~azure.core.exceptions.HttpResponseError: @@ -244,7 +228,7 @@ async def create_or_update( resource_group_name: str, workspace_name: str, key_name: str, - key_properties: IO, + key_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -259,11 +243,10 @@ async def create_or_update( :param key_name: The name of the workspace key. Required. :type key_name: str :param key_properties: Key put request properties. Required. - :type key_properties: IO + :type key_properties: 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: Key or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.Key :raises ~azure.core.exceptions.HttpResponseError: @@ -275,7 +258,7 @@ async def create_or_update( resource_group_name: str, workspace_name: str, key_name: str, - key_properties: Union[_models.Key, IO], + key_properties: Union[_models.Key, IO[bytes]], **kwargs: Any ) -> _models.Key: """Creates or updates a workspace key. @@ -287,18 +270,14 @@ async def create_or_update( :type workspace_name: str :param key_name: The name of the workspace key. Required. :type key_name: str - :param key_properties: Key put request properties. Is either a model type or a IO type. + :param key_properties: Key put request properties. Is either a Key type or a IO[bytes] type. Required. - :type key_properties: ~azure.mgmt.synapse.models.Key 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 key_properties: ~azure.mgmt.synapse.models.Key or IO[bytes] :return: Key or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -309,19 +288,19 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Key] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(key_properties, (IO, bytes)): + if isinstance(key_properties, (IOBase, bytes)): _content = key_properties else: _json = self._serialize.body(key_properties, "Key") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, key_name=key_name, @@ -330,15 +309,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -348,16 +326,12 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Key", pipeline_response) + deserialized = self._deserialize("Key", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/keys/{keyName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( @@ -372,12 +346,11 @@ async def delete( :type workspace_name: str :param key_name: The name of the workspace key. Required. :type key_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Key or None or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.Key or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -388,24 +361,23 @@ async def delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[Optional[_models.Key]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_name, key_name=key_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -417,13 +389,9 @@ async def delete( deserialized = None if response.status_code == 200: - deserialized = self._deserialize("Key", pipeline_response) + deserialized = self._deserialize("Key", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/keys/{keyName}" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_kusto_operations_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_kusto_operations_operations.py index 48f691d6a0d5..821caec822e5 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_kusto_operations_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_kusto_operations_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -19,20 +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 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._kusto_operations_operations import build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -60,7 +57,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists available operations for the Kusto sub-resources inside Microsoft.Synapse 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.synapse.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -68,12 +64,10 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -84,21 +78,18 @@ 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _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) @@ -108,10 +99,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -123,5 +115,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Synapse/kustooperations"} diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_kusto_pool_attached_database_configurations_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_kusto_pool_attached_database_configurations_operations.py index af2b329bf040..a062bd0095e0 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_kusto_pool_attached_database_configurations_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_kusto_pool_attached_database_configurations_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -16,12 +16,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 @@ -29,7 +30,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._kusto_pool_attached_database_configurations_operations import ( build_create_or_update_request, build_delete_request, @@ -37,15 +37,15 @@ build_list_by_kusto_pool_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class KustoPoolAttachedDatabaseConfigurationsOperations: +class KustoPoolAttachedDatabaseConfigurationsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -77,7 +77,6 @@ def list_by_kusto_pool( :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 AttachedDatabaseConfiguration or the result of cls(response) :rtype: @@ -87,12 +86,10 @@ def list_by_kusto_pool( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.AttachedDatabaseConfigurationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -103,25 +100,22 @@ def list_by_kusto_pool( def prepare_request(next_link=None): if not next_link: - request = build_list_by_kusto_pool_request( + _request = build_list_by_kusto_pool_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_kusto_pool.metadata["url"], 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _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) @@ -131,10 +125,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -147,10 +142,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_kusto_pool.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations" - } - @distributed_trace_async async def get( self, @@ -172,12 +163,11 @@ async def get( :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: AttachedDatabaseConfiguration or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.AttachedDatabaseConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -188,27 +178,24 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.AttachedDatabaseConfiguration] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, attached_database_configuration_name=attached_database_configuration_name, resource_group_name=resource_group_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -218,16 +205,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("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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, @@ -235,10 +218,10 @@ async def _create_or_update_initial( kusto_pool_name: str, attached_database_configuration_name: str, resource_group_name: str, - parameters: Union[_models.AttachedDatabaseConfiguration, IO], + parameters: Union[_models.AttachedDatabaseConfiguration, IO[bytes]], **kwargs: Any - ) -> _models.AttachedDatabaseConfiguration: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -249,21 +232,19 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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 _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "AttachedDatabaseConfiguration") - request = build_create_or_update_request( + _request = build_create_or_update_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, attached_database_configuration_name=attached_database_configuration_name, @@ -273,42 +254,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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) - 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: - deserialized = self._deserialize("AttachedDatabaseConfiguration", 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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}" - } - @overload async def begin_create_or_update( self, @@ -338,14 +312,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: @@ -360,7 +326,7 @@ async def begin_create_or_update( kusto_pool_name: str, attached_database_configuration_name: str, resource_group_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -378,18 +344,10 @@ async def begin_create_or_update( Required. :type resource_group_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: @@ -404,7 +362,7 @@ async def begin_create_or_update( kusto_pool_name: str, attached_database_configuration_name: str, resource_group_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. @@ -420,19 +378,8 @@ async def begin_create_or_update( Required. :type resource_group_name: str :param parameters: The database parameters supplied to the CreateOrUpdate operation. Is either - a model type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.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.synapse.models.AttachedDatabaseConfiguration or IO[bytes] :return: An instance of AsyncLROPoller that returns either AttachedDatabaseConfiguration or the result of cls(response) :rtype: @@ -442,9 +389,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AttachedDatabaseConfiguration] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -464,12 +409,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: @@ -479,27 +425,25 @@ 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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/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, workspace_name: str, kusto_pool_name: str, attached_database_configuration_name: str, resource_group_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -510,42 +454,44 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, attached_database_configuration_name=attached_database_configuration_name, resource_group_name=resource_group_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -568,14 +514,6 @@ async def begin_delete( :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 - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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: @@ -583,15 +521,13 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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._delete_initial( # type: ignore + raw_result = await self._delete_initial( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, attached_database_configuration_name=attached_database_configuration_name, @@ -602,11 +538,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)) @@ -615,14 +552,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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_kusto_pool_child_resource_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_kusto_pool_child_resource_operations.py index 6d5422ac44b8..2a1a31830a0f 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_kusto_pool_child_resource_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_kusto_pool_child_resource_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload @@ -18,20 +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._kusto_pool_child_resource_operations import build_check_name_availability_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -80,7 +78,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.synapse.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: @@ -92,7 +89,7 @@ async def check_name_availability( workspace_name: str, kusto_pool_name: str, resource_group_name: str, - resource_name: IO, + resource_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -107,11 +104,10 @@ async def check_name_availability( Required. :type resource_group_name: str :param resource_name: The name of the Kusto Pool child 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.synapse.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: @@ -123,7 +119,7 @@ async def check_name_availability( workspace_name: str, kusto_pool_name: str, resource_group_name: str, - resource_name: Union[_models.DatabaseCheckNameRequest, IO], + resource_name: Union[_models.DatabaseCheckNameRequest, IO[bytes]], **kwargs: Any ) -> _models.CheckNameResult: """Checks that the Kusto Pool child resource name is valid and is not already in use. @@ -135,18 +131,14 @@ async def check_name_availability( :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param resource_name: The name of the Kusto Pool child resource. Is either a model type or a IO - type. Required. - :type resource_name: ~azure.mgmt.synapse.models.DatabaseCheckNameRequest 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 Kusto Pool child resource. Is either a + DatabaseCheckNameRequest type or a IO[bytes] type. Required. + :type resource_name: ~azure.mgmt.synapse.models.DatabaseCheckNameRequest or IO[bytes] :return: CheckNameResult or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -157,21 +149,19 @@ async def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CheckNameResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(resource_name, (IO, bytes)): + if isinstance(resource_name, (IOBase, bytes)): _content = resource_name else: _json = self._serialize.body(resource_name, "DatabaseCheckNameRequest") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_name, @@ -180,15 +170,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -198,13 +187,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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/checkNameAvailability" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_kusto_pool_data_connections_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_kusto_pool_data_connections_operations.py index 69da96ebb2d1..1fba0b911840 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_kusto_pool_data_connections_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_kusto_pool_data_connections_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -16,12 +17,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 @@ -29,7 +31,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._kusto_pool_data_connections_operations import ( build_check_name_availability_request, build_create_or_update_request, @@ -40,10 +41,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -95,7 +96,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.synapse.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: @@ -108,7 +108,7 @@ async def check_name_availability( workspace_name: str, kusto_pool_name: str, database_name: str, - data_connection_name: IO, + data_connection_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -125,11 +125,10 @@ async def check_name_availability( :param database_name: The name of the database in the Kusto pool. 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.synapse.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: @@ -142,7 +141,7 @@ async def check_name_availability( workspace_name: str, kusto_pool_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. @@ -156,18 +155,15 @@ async def check_name_availability( :type kusto_pool_name: str :param database_name: The name of the database in the Kusto pool. Required. :type database_name: str - :param data_connection_name: The name of the data connection. Is either a model type or a IO - type. Required. - :type data_connection_name: ~azure.mgmt.synapse.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 + :param data_connection_name: The name of the data connection. Is either a + DataConnectionCheckNameRequest type or a IO[bytes] type. Required. + :type data_connection_name: ~azure.mgmt.synapse.models.DataConnectionCheckNameRequest or + IO[bytes] :return: CheckNameResult or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -178,21 +174,19 @@ async def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CheckNameResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(data_connection_name, (IO, bytes)): + if isinstance(data_connection_name, (IOBase, bytes)): _content = data_connection_name 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, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, @@ -202,15 +196,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -220,16 +213,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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/checkNameAvailability" - } + return deserialized # type: ignore async def _data_connection_validation_initial( self, @@ -237,10 +226,10 @@ async def _data_connection_validation_initial( workspace_name: str, kusto_pool_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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -251,21 +240,19 @@ async def _data_connection_validation_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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 _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters 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, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, @@ -275,36 +262,34 @@ 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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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 - if response.status_code == 200: - deserialized = self._deserialize("DataConnectionValidationListResult", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _data_connection_validation_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnectionValidation" - } + return deserialized # type: ignore @overload async def begin_data_connection_validation( @@ -335,14 +320,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: @@ -357,7 +334,7 @@ async def begin_data_connection_validation( workspace_name: str, kusto_pool_name: str, database_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -375,18 +352,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: @@ -401,7 +370,7 @@ async def begin_data_connection_validation( workspace_name: str, kusto_pool_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. @@ -416,19 +385,8 @@ async def begin_data_connection_validation( :param database_name: The name of the database in the Kusto pool. Required. :type database_name: str :param parameters: The data connection parameters supplied to the CreateOrUpdate operation. Is - either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.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.synapse.models.DataConnectionValidation or IO[bytes] :return: An instance of AsyncLROPoller that returns either DataConnectionValidationListResult or the result of cls(response) :rtype: @@ -438,9 +396,7 @@ async def begin_data_connection_validation( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DataConnectionValidationListResult] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -460,12 +416,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: @@ -477,17 +434,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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnectionValidation" - } + return AsyncLROPoller[_models.DataConnectionValidationListResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list_by_database( @@ -504,7 +459,6 @@ def list_by_database( :type kusto_pool_name: str :param database_name: The name of the database in the Kusto pool. 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.synapse.models.DataConnection] :raises ~azure.core.exceptions.HttpResponseError: @@ -512,12 +466,10 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.DataConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -528,26 +480,23 @@ 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, workspace_name=workspace_name, kusto_pool_name=kusto_pool_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _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) @@ -557,10 +506,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -573,10 +523,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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections" - } - @distributed_trace_async async def get( self, @@ -600,12 +546,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.synapse.models.DataConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -616,12 +561,10 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.DataConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, @@ -629,15 +572,14 @@ async def get( 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -647,16 +589,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 deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, @@ -665,10 +603,10 @@ async def _create_or_update_initial( kusto_pool_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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -679,21 +617,19 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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 _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters 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, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, @@ -704,39 +640,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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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("DataConnection", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DataConnection", 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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}" - } - @overload async def begin_create_or_update( self, @@ -769,14 +701,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.synapse.models.DataConnection] @@ -791,7 +715,7 @@ async def begin_create_or_update( kusto_pool_name: str, database_name: str, data_connection_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -811,18 +735,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.synapse.models.DataConnection] @@ -837,7 +753,7 @@ async def begin_create_or_update( kusto_pool_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. @@ -854,19 +770,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 model type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.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.synapse.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.synapse.models.DataConnection] @@ -875,9 +780,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DataConnection] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -898,12 +801,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: @@ -913,17 +817,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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/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, @@ -932,10 +834,10 @@ async def _update_initial( kusto_pool_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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -946,21 +848,19 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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 _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DataConnection") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, @@ -971,39 +871,35 @@ 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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) - if response.status_code == 200: - deserialized = self._deserialize("DataConnection", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DataConnection", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}" - } - @overload async def begin_update( self, @@ -1035,14 +931,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.synapse.models.DataConnection] @@ -1057,7 +945,7 @@ async def begin_update( kusto_pool_name: str, database_name: str, data_connection_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1076,18 +964,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.synapse.models.DataConnection] @@ -1102,7 +982,7 @@ async def begin_update( kusto_pool_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. @@ -1119,19 +999,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 - model type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.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.synapse.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.synapse.models.DataConnection] @@ -1140,9 +1009,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DataConnection] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -1163,12 +1030,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: @@ -1178,19 +1046,17 @@ 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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/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, workspace_name: str, @@ -1198,8 +1064,8 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements database_name: str, data_connection_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1210,12 +1076,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, @@ -1223,30 +1087,34 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -1271,14 +1139,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: @@ -1286,15 +1146,13 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, @@ -1306,11 +1164,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)) @@ -1319,14 +1178,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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_kusto_pool_database_principal_assignments_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_kusto_pool_database_principal_assignments_operations.py index 788aa0c476b7..0f1ff39a0c1f 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_kusto_pool_database_principal_assignments_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_kusto_pool_database_principal_assignments_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -16,12 +16,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 @@ -29,7 +30,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._kusto_pool_database_principal_assignments_operations import ( build_check_name_availability_request, build_create_or_update_request, @@ -38,15 +38,15 @@ build_list_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class KustoPoolDatabasePrincipalAssignmentsOperations: +class KustoPoolDatabasePrincipalAssignmentsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -94,7 +94,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.synapse.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: @@ -107,7 +106,7 @@ async def check_name_availability( kusto_pool_name: str, database_name: str, resource_group_name: str, - principal_assignment_name: IO, + principal_assignment_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -124,11 +123,10 @@ async def check_name_availability( Required. :type resource_group_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.synapse.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: @@ -141,7 +139,7 @@ async def check_name_availability( kusto_pool_name: str, database_name: str, resource_group_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. @@ -155,19 +153,15 @@ async def check_name_availability( :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param principal_assignment_name: The name of the resource. Is either a model type or a IO - type. Required. + :param principal_assignment_name: The name of the resource. Is either a + DatabasePrincipalAssignmentCheckNameRequest type or a IO[bytes] type. Required. :type principal_assignment_name: - ~azure.mgmt.synapse.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.synapse.models.DatabasePrincipalAssignmentCheckNameRequest or IO[bytes] :return: CheckNameResult or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -178,21 +172,19 @@ async def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CheckNameResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(principal_assignment_name, (IO, bytes)): + if isinstance(principal_assignment_name, (IOBase, bytes)): _content = principal_assignment_name else: _json = self._serialize.body(principal_assignment_name, "DatabasePrincipalAssignmentCheckNameRequest") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, database_name=database_name, @@ -202,15 +194,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -220,16 +211,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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/checkPrincipalAssignmentNameAvailability" - } + return deserialized # type: ignore @distributed_trace def list( @@ -246,7 +233,6 @@ def list( :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 DatabasePrincipalAssignment or the result of cls(response) :rtype: @@ -256,12 +242,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.DatabasePrincipalAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -272,26 +256,23 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, database_name=database_name, resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _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) @@ -301,10 +282,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -317,10 +299,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments" - } - @distributed_trace_async async def get( self, @@ -344,12 +322,11 @@ async def get( :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: DatabasePrincipalAssignment or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.DatabasePrincipalAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -360,12 +337,10 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.DatabasePrincipalAssignment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, database_name=database_name, @@ -373,15 +348,14 @@ async def get( resource_group_name=resource_group_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -391,16 +365,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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, @@ -409,10 +379,10 @@ async def _create_or_update_initial( database_name: str, principal_assignment_name: str, resource_group_name: str, - parameters: Union[_models.DatabasePrincipalAssignment, IO], + parameters: Union[_models.DatabasePrincipalAssignment, IO[bytes]], **kwargs: Any - ) -> _models.DatabasePrincipalAssignment: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -423,21 +393,19 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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 _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DatabasePrincipalAssignment") - request = build_create_or_update_request( + _request = build_create_or_update_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, database_name=database_name, @@ -448,39 +416,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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}" - } - @overload async def begin_create_or_update( self, @@ -513,14 +477,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: @@ -536,7 +492,7 @@ async def begin_create_or_update( database_name: str, principal_assignment_name: str, resource_group_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -556,18 +512,10 @@ async def begin_create_or_update( :type resource_group_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: @@ -583,7 +531,7 @@ async def begin_create_or_update( database_name: str, principal_assignment_name: str, resource_group_name: str, - parameters: Union[_models.DatabasePrincipalAssignment, IO], + parameters: Union[_models.DatabasePrincipalAssignment, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.DatabasePrincipalAssignment]: """Creates a Kusto pool database principalAssignment. @@ -600,19 +548,8 @@ async def begin_create_or_update( Required. :type resource_group_name: str :param parameters: The Kusto principalAssignments parameters supplied for the operation. Is - either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.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.synapse.models.DatabasePrincipalAssignment or IO[bytes] :return: An instance of AsyncLROPoller that returns either DatabasePrincipalAssignment or the result of cls(response) :rtype: @@ -622,9 +559,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DatabasePrincipalAssignment] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -645,12 +580,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: @@ -660,19 +596,17 @@ 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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/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, workspace_name: str, kusto_pool_name: str, @@ -680,8 +614,8 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements principal_assignment_name: str, resource_group_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -692,12 +626,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, database_name=database_name, @@ -705,30 +637,34 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements resource_group_name=resource_group_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -753,14 +689,6 @@ async def begin_delete( :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 - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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: @@ -768,15 +696,13 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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._delete_initial( # type: ignore + raw_result = await self._delete_initial( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, database_name=database_name, @@ -788,11 +714,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)) @@ -801,14 +728,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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_kusto_pool_databases_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_kusto_pool_databases_operations.py index dadd81d2c388..0c90e9c5dd48 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_kusto_pool_databases_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_kusto_pool_databases_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -16,12 +16,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 @@ -29,7 +30,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._kusto_pool_databases_operations import ( build_create_or_update_request, build_delete_request, @@ -38,10 +38,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -78,7 +78,6 @@ def list_by_kusto_pool( :type workspace_name: str :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: 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.synapse.models.Database] :raises ~azure.core.exceptions.HttpResponseError: @@ -86,12 +85,10 @@ def list_by_kusto_pool( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.DatabaseListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -102,25 +99,22 @@ def list_by_kusto_pool( def prepare_request(next_link=None): if not next_link: - request = build_list_by_kusto_pool_request( + _request = build_list_by_kusto_pool_request( resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_kusto_pool.metadata["url"], 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _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) @@ -130,10 +124,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -146,10 +141,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_kusto_pool.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases" - } - @distributed_trace_async async def get( self, resource_group_name: str, workspace_name: str, kusto_pool_name: str, database_name: str, **kwargs: Any @@ -165,12 +156,11 @@ async def get( :type kusto_pool_name: str :param database_name: The name of the database in the Kusto pool. 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.synapse.models.Database :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -181,27 +171,24 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.Database] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -211,16 +198,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("Database", pipeline_response) + deserialized = self._deserialize("Database", 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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, @@ -228,10 +211,10 @@ async def _create_or_update_initial( workspace_name: str, kusto_pool_name: str, database_name: str, - parameters: Union[_models.Database, IO], + parameters: Union[_models.Database, IO[bytes]], **kwargs: Any - ) -> _models.Database: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -242,21 +225,19 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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 _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters 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, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, @@ -266,39 +247,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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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("Database", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Database", 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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}" - } - @overload async def begin_create_or_update( self, @@ -327,14 +304,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.synapse.models.Database] @@ -348,7 +317,7 @@ async def begin_create_or_update( workspace_name: str, kusto_pool_name: str, database_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -365,18 +334,10 @@ async def begin_create_or_update( :param database_name: The name of the database in the Kusto pool. Required. :type database_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 Database or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.Database] @@ -390,7 +351,7 @@ async def begin_create_or_update( workspace_name: str, kusto_pool_name: str, database_name: str, - parameters: Union[_models.Database, IO], + parameters: Union[_models.Database, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Database]: """Creates or updates a database. @@ -405,19 +366,8 @@ async def begin_create_or_update( :param database_name: The name of the database in the Kusto pool. Required. :type database_name: str :param parameters: The database parameters supplied to the CreateOrUpdate operation. Is either - a model type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.models.Database 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 Database type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.Database or IO[bytes] :return: An instance of AsyncLROPoller that returns either Database or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.Database] @@ -426,9 +376,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Database] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -448,12 +396,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: @@ -463,17 +412,15 @@ 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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}" - } + return AsyncLROPoller[_models.Database]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, @@ -481,10 +428,10 @@ async def _update_initial( workspace_name: str, kusto_pool_name: str, database_name: str, - parameters: Union[_models.Database, IO], + parameters: Union[_models.Database, IO[bytes]], **kwargs: Any - ) -> _models.Database: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -495,21 +442,19 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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 _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "Database") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, @@ -519,39 +464,35 @@ 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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) - if response.status_code == 200: - deserialized = self._deserialize("Database", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("Database", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}" - } - @overload async def begin_update( self, @@ -580,14 +521,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.synapse.models.Database] @@ -601,7 +534,7 @@ async def begin_update( workspace_name: str, kusto_pool_name: str, database_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -618,18 +551,10 @@ async def begin_update( :param database_name: The name of the database in the Kusto pool. Required. :type database_name: str :param parameters: The database 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 Database or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.Database] @@ -643,7 +568,7 @@ async def begin_update( workspace_name: str, kusto_pool_name: str, database_name: str, - parameters: Union[_models.Database, IO], + parameters: Union[_models.Database, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Database]: """Updates a database. @@ -657,20 +582,9 @@ async def begin_update( :type kusto_pool_name: str :param database_name: The name of the database in the Kusto pool. Required. :type database_name: str - :param parameters: The database parameters supplied to the Update operation. Is either a model - type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.models.Database 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: The database parameters supplied to the Update operation. Is either a + Database type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.Database or IO[bytes] :return: An instance of AsyncLROPoller that returns either Database or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.Database] @@ -679,9 +593,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Database] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -701,12 +613,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: @@ -716,22 +629,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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/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, workspace_name: str, kusto_pool_name: str, database_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -742,42 +653,44 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -794,14 +707,6 @@ async def begin_delete( :type kusto_pool_name: str :param database_name: The name of the database in the Kusto pool. 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: @@ -809,15 +714,13 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, @@ -828,11 +731,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)) @@ -841,14 +745,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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_kusto_pool_principal_assignments_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_kusto_pool_principal_assignments_operations.py index 2b3448dee01c..69dce8b0019d 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_kusto_pool_principal_assignments_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_kusto_pool_principal_assignments_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -16,12 +16,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 @@ -29,7 +30,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._kusto_pool_principal_assignments_operations import ( build_check_name_availability_request, build_create_or_update_request, @@ -38,10 +38,10 @@ build_list_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -91,7 +91,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.synapse.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: @@ -103,7 +102,7 @@ async def check_name_availability( workspace_name: str, kusto_pool_name: str, resource_group_name: str, - principal_assignment_name: IO, + principal_assignment_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -118,11 +117,10 @@ async def check_name_availability( Required. :type resource_group_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.synapse.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: @@ -134,7 +132,7 @@ async def check_name_availability( workspace_name: str, kusto_pool_name: str, resource_group_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. @@ -146,19 +144,15 @@ async def check_name_availability( :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param principal_assignment_name: The name of the principal assignment. Is either a model type - or a IO type. Required. + :param principal_assignment_name: The name of the principal assignment. Is either a + ClusterPrincipalAssignmentCheckNameRequest type or a IO[bytes] type. Required. :type principal_assignment_name: - ~azure.mgmt.synapse.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.synapse.models.ClusterPrincipalAssignmentCheckNameRequest or IO[bytes] :return: CheckNameResult or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -169,21 +163,19 @@ async def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CheckNameResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(principal_assignment_name, (IO, bytes)): + if isinstance(principal_assignment_name, (IOBase, bytes)): _content = principal_assignment_name else: _json = self._serialize.body(principal_assignment_name, "ClusterPrincipalAssignmentCheckNameRequest") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_name, @@ -192,15 +184,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -210,16 +201,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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/checkPrincipalAssignmentNameAvailability" - } + return deserialized # type: ignore @distributed_trace def list( @@ -234,7 +221,6 @@ def list( :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 ClusterPrincipalAssignment or the result of cls(response) :rtype: @@ -244,12 +230,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.ClusterPrincipalAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -260,25 +244,22 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _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) @@ -288,10 +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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -304,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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments" - } - @distributed_trace_async async def get( self, @@ -328,12 +306,11 @@ async def get( :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: ClusterPrincipalAssignment or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ClusterPrincipalAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -344,27 +321,24 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.ClusterPrincipalAssignment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, principal_assignment_name=principal_assignment_name, resource_group_name=resource_group_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -374,16 +348,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("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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments/{principalAssignmentName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, @@ -391,10 +361,10 @@ async def _create_or_update_initial( kusto_pool_name: str, principal_assignment_name: str, resource_group_name: str, - parameters: Union[_models.ClusterPrincipalAssignment, IO], + parameters: Union[_models.ClusterPrincipalAssignment, IO[bytes]], **kwargs: Any - ) -> _models.ClusterPrincipalAssignment: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -405,21 +375,19 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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 _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ClusterPrincipalAssignment") - request = build_create_or_update_request( + _request = build_create_or_update_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, principal_assignment_name=principal_assignment_name, @@ -429,39 +397,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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments/{principalAssignmentName}" - } - @overload async def begin_create_or_update( self, @@ -491,14 +455,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: @@ -513,7 +469,7 @@ async def begin_create_or_update( kusto_pool_name: str, principal_assignment_name: str, resource_group_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -531,18 +487,10 @@ async def begin_create_or_update( :type resource_group_name: str :param parameters: The Kusto pool 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: @@ -557,7 +505,7 @@ async def begin_create_or_update( kusto_pool_name: str, principal_assignment_name: str, resource_group_name: str, - parameters: Union[_models.ClusterPrincipalAssignment, IO], + parameters: Union[_models.ClusterPrincipalAssignment, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.ClusterPrincipalAssignment]: """Create a Kusto pool principalAssignment. @@ -572,19 +520,8 @@ async def begin_create_or_update( Required. :type resource_group_name: str :param parameters: The Kusto pool principalAssignment's parameters supplied for the operation. - Is either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.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. + Is either a ClusterPrincipalAssignment type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.ClusterPrincipalAssignment or IO[bytes] :return: An instance of AsyncLROPoller that returns either ClusterPrincipalAssignment or the result of cls(response) :rtype: @@ -594,9 +531,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ClusterPrincipalAssignment] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -616,12 +551,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: @@ -631,27 +567,25 @@ 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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/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, workspace_name: str, kusto_pool_name: str, principal_assignment_name: str, resource_group_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -662,42 +596,44 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, principal_assignment_name=principal_assignment_name, resource_group_name=resource_group_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments/{principalAssignmentName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -719,14 +655,6 @@ async def begin_delete( :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 - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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: @@ -734,15 +662,13 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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._delete_initial( # type: ignore + raw_result = await self._delete_initial( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, principal_assignment_name=principal_assignment_name, @@ -753,11 +679,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)) @@ -766,14 +693,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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments/{principalAssignmentName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_kusto_pool_private_link_resources_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_kusto_pool_private_link_resources_operations.py index 911e01f4172d..0393a9f986ad 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_kusto_pool_private_link_resources_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_kusto_pool_private_link_resources_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -19,20 +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 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._kusto_pool_private_link_resources_operations import build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -69,7 +66,6 @@ def list( :type workspace_name: str :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either KustoPoolPrivateLinkResources or the result of cls(response) :rtype: @@ -79,12 +75,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.PrivateLinkResources] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -95,25 +89,22 @@ 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, workspace_name=workspace_name, kusto_pool_name=kusto_pool_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateLinkResources", pipeline_response) @@ -123,10 +114,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -138,7 +130,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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/privateLinkResources" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_kusto_pools_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_kusto_pools_operations.py index ab6decb85f1d..4f2972c4f69c 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_kusto_pools_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_kusto_pools_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -16,12 +17,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 @@ -29,7 +31,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._kusto_pools_operations import ( build_add_language_extensions_request, build_check_name_availability_request, @@ -48,10 +49,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -79,7 +80,6 @@ def __init__(self, *args, **kwargs) -> None: def list_skus(self, **kwargs: Any) -> AsyncIterable["_models.SkuDescription"]: """Lists eligible SKUs for Kusto Pool resource. - :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.synapse.models.SkuDescription] :raises ~azure.core.exceptions.HttpResponseError: @@ -87,12 +87,10 @@ def list_skus(self, **kwargs: Any) -> AsyncIterable["_models.SkuDescription"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.SkuDescriptionList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -103,22 +101,19 @@ 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _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) @@ -128,10 +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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -144,8 +140,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_skus.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Synapse/skus"} - @overload async def check_name_availability( self, @@ -164,7 +158,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.synapse.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: @@ -172,18 +165,17 @@ async def check_name_availability( @overload async def check_name_availability( - self, location: str, kusto_pool_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, location: str, kusto_pool_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameResult: """Checks that the kusto pool name is valid and is not already in use. :param location: The name of Azure region. Required. :type location: str :param kusto_pool_name: The name of the cluster. Required. - :type kusto_pool_name: IO + :type kusto_pool_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.synapse.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: @@ -191,23 +183,20 @@ async def check_name_availability( @distributed_trace_async async def check_name_availability( - self, location: str, kusto_pool_name: Union[_models.KustoPoolCheckNameRequest, IO], **kwargs: Any + self, location: str, kusto_pool_name: Union[_models.KustoPoolCheckNameRequest, IO[bytes]], **kwargs: Any ) -> _models.CheckNameResult: """Checks that the kusto pool name is valid and is not already in use. :param location: The name of Azure region. Required. :type location: str - :param kusto_pool_name: The name of the cluster. Is either a model type or a IO type. Required. - :type kusto_pool_name: ~azure.mgmt.synapse.models.KustoPoolCheckNameRequest 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 kusto_pool_name: The name of the cluster. Is either a KustoPoolCheckNameRequest type or + a IO[bytes] type. Required. + :type kusto_pool_name: ~azure.mgmt.synapse.models.KustoPoolCheckNameRequest or IO[bytes] :return: CheckNameResult or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -218,36 +207,33 @@ async def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CheckNameResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(kusto_pool_name, (IO, bytes)): + if isinstance(kusto_pool_name, (IOBase, bytes)): _content = kusto_pool_name else: _json = self._serialize.body(kusto_pool_name, "KustoPoolCheckNameRequest") - 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -257,16 +243,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.Synapse/locations/{location}/kustoPoolCheckNameAvailability" - } + return deserialized # type: ignore @distributed_trace_async async def list_by_workspace( @@ -281,12 +263,11 @@ async def list_by_workspace( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: KustoPoolListResult or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.KustoPoolListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -297,25 +278,22 @@ async def list_by_workspace( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.KustoPoolListResult] = kwargs.pop("cls", None) - request = build_list_by_workspace_request( + _request = build_list_by_workspace_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_workspace.metadata["url"], 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -325,16 +303,12 @@ async def list_by_workspace( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("KustoPoolListResult", pipeline_response) + deserialized = self._deserialize("KustoPoolListResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_by_workspace.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools" - } + return deserialized # type: ignore @distributed_trace_async async def get( @@ -349,12 +323,11 @@ async def get( :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: KustoPool or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.KustoPool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -365,26 +338,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.KustoPool] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -394,28 +364,24 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("KustoPool", pipeline_response) + deserialized = self._deserialize("KustoPool", 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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, workspace_name: str, resource_group_name: str, kusto_pool_name: str, - parameters: Union[_models.KustoPool, IO], + parameters: Union[_models.KustoPool, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> _models.KustoPool: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -426,21 +392,19 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.KustoPool] = 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(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "KustoPool") - request = build_create_or_update_request( + _request = build_create_or_update_request( workspace_name=workspace_name, resource_group_name=resource_group_name, kusto_pool_name=kusto_pool_name, @@ -451,39 +415,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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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("KustoPool", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("KustoPool", 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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}" - } - @overload async def begin_create_or_update( self, @@ -520,14 +480,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 KustoPool or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.KustoPool] @@ -540,7 +492,7 @@ async def begin_create_or_update( workspace_name: str, resource_group_name: str, kusto_pool_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, if_none_match: Optional[str] = None, *, @@ -558,7 +510,7 @@ async def begin_create_or_update( :type kusto_pool_name: str :param parameters: The Kusto pool parameters supplied to the CreateOrUpdate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The ETag of the Kusto Pool. Omit this value to always overwrite the current Kusto Pool. Specify the last-seen ETag value to prevent accidentally overwriting concurrent changes. Default value is None. @@ -570,14 +522,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 KustoPool or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.KustoPool] @@ -590,7 +534,7 @@ async def begin_create_or_update( workspace_name: str, resource_group_name: str, kusto_pool_name: str, - parameters: Union[_models.KustoPool, IO], + parameters: Union[_models.KustoPool, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any @@ -605,8 +549,8 @@ async def begin_create_or_update( :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str :param parameters: The Kusto pool parameters supplied to the CreateOrUpdate operation. Is - either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.models.KustoPool or IO + either a KustoPool type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.KustoPool or IO[bytes] :param if_match: The ETag of the Kusto Pool. Omit this value to always overwrite the current Kusto Pool. Specify the last-seen ETag value to prevent accidentally overwriting concurrent changes. Default value is None. @@ -615,17 +559,6 @@ async def begin_create_or_update( updating an existing Kusto Pool. 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 KustoPool or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.KustoPool] @@ -634,9 +567,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.KustoPool] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -657,12 +588,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("KustoPool", pipeline_response) + deserialized = self._deserialize("KustoPool", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -672,28 +604,26 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.KustoPool].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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}" - } + return AsyncLROPoller[_models.KustoPool]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, workspace_name: str, resource_group_name: str, kusto_pool_name: str, - parameters: Union[_models.KustoPoolUpdate, IO], + parameters: Union[_models.KustoPoolUpdate, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any - ) -> _models.KustoPool: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -704,21 +634,19 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.KustoPool] = 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(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "KustoPoolUpdate") - request = build_update_request( + _request = build_update_request( workspace_name=workspace_name, resource_group_name=resource_group_name, kusto_pool_name=kusto_pool_name, @@ -728,39 +656,35 @@ 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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) - if response.status_code == 200: - deserialized = self._deserialize("KustoPool", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("KustoPool", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}" - } - @overload async def begin_update( self, @@ -791,14 +715,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 KustoPool or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.KustoPool] @@ -811,7 +727,7 @@ async def begin_update( workspace_name: str, resource_group_name: str, kusto_pool_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, *, content_type: str = "application/json", @@ -827,7 +743,7 @@ async def begin_update( :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str :param parameters: The Kusto pool parameters supplied to the Update operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The ETag of the Kusto Pool. Omit this value to always overwrite the current Kusto Pool. Specify the last-seen ETag value to prevent accidentally overwriting concurrent changes. Default value is None. @@ -835,14 +751,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 KustoPool or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.KustoPool] @@ -855,7 +763,7 @@ async def begin_update( workspace_name: str, resource_group_name: str, kusto_pool_name: str, - parameters: Union[_models.KustoPoolUpdate, IO], + parameters: Union[_models.KustoPoolUpdate, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any ) -> AsyncLROPoller[_models.KustoPool]: @@ -869,23 +777,12 @@ async def begin_update( :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str :param parameters: The Kusto pool parameters supplied to the Update operation. Is either a - model type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.models.KustoPoolUpdate or IO + KustoPoolUpdate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.KustoPoolUpdate or IO[bytes] :param if_match: The ETag of the Kusto Pool. Omit this value to always overwrite the current Kusto Pool. 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 KustoPool or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.KustoPool] @@ -894,9 +791,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.KustoPool] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -916,12 +811,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("KustoPool", pipeline_response) + deserialized = self._deserialize("KustoPool", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -931,22 +827,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.KustoPool].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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}" - } + return AsyncLROPoller[_models.KustoPool]( + 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, workspace_name: str, resource_group_name: str, kusto_pool_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -957,41 +851,43 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( workspace_name=workspace_name, resource_group_name=resource_group_name, kusto_pool_name=kusto_pool_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -1006,14 +902,6 @@ async def begin_delete( :type resource_group_name: str :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_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: @@ -1021,15 +909,13 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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._delete_initial( # type: ignore + raw_result = await self._delete_initial( workspace_name=workspace_name, resource_group_name=resource_group_name, kusto_pool_name=kusto_pool_name, @@ -1039,11 +925,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)) @@ -1052,22 +939,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_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _stop_initial( # pylint: disable=inconsistent-return-statements + async def _stop_initial( self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1078,41 +961,43 @@ async def _stop_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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 = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _stop_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/stop" - } + return deserialized # type: ignore @distributed_trace_async async def begin_stop( @@ -1127,14 +1012,6 @@ async def begin_stop( :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 - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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: @@ -1142,15 +1019,13 @@ async def begin_stop( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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._stop_initial( # type: ignore + raw_result = await self._stop_initial( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_name, @@ -1160,11 +1035,12 @@ async def begin_stop( 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)) @@ -1173,22 +1049,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_stop.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/stop" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _start_initial( # pylint: disable=inconsistent-return-statements + async def _start_initial( self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1199,41 +1071,43 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_start_request( + _request = build_start_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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 = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _start_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/start" - } + return deserialized # type: ignore @distributed_trace_async async def begin_start( @@ -1248,14 +1122,6 @@ async def begin_start( :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 - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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: @@ -1263,15 +1129,13 @@ async def begin_start( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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._start_initial( # type: ignore + raw_result = await self._start_initial( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_name, @@ -1281,11 +1145,12 @@ async def begin_start( 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)) @@ -1294,17 +1159,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_start.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/start" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def list_skus_by_resource( @@ -1319,7 +1180,6 @@ def list_skus_by_resource( :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 AzureResourceSku or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.AzureResourceSku] :raises ~azure.core.exceptions.HttpResponseError: @@ -1327,12 +1187,10 @@ def list_skus_by_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.ListResourceSkusResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1343,25 +1201,22 @@ 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( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _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) @@ -1371,10 +1226,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1387,10 +1243,6 @@ 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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/skus" - } - @distributed_trace def list_language_extensions( self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, **kwargs: Any @@ -1404,7 +1256,6 @@ def list_language_extensions( :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 LanguageExtension or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.LanguageExtension] :raises ~azure.core.exceptions.HttpResponseError: @@ -1412,12 +1263,10 @@ def list_language_extensions( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.LanguageExtensionsList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1428,25 +1277,22 @@ 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( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _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) @@ -1456,10 +1302,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1472,19 +1319,15 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_language_extensions.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/listLanguageExtensions" - } - - async def _add_language_extensions_initial( # pylint: disable=inconsistent-return-statements + async def _add_language_extensions_initial( self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, - language_extensions_to_add: Union[_models.LanguageExtensionsList, IO], + language_extensions_to_add: Union[_models.LanguageExtensionsList, IO[bytes]], **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1495,21 +1338,19 @@ async def _add_language_extensions_initial( # pylint: disable=inconsistent-retu _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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, (IO, bytes)): + 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( + _request = build_add_language_extensions_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_name, @@ -1518,30 +1359,34 @@ 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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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 = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _add_language_extensions_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/addLanguageExtensions" - } + return deserialized # type: ignore @overload async def begin_add_language_extensions( @@ -1568,14 +1413,6 @@ async 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 AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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: @@ -1587,7 +1424,7 @@ async def begin_add_language_extensions( workspace_name: str, kusto_pool_name: str, resource_group_name: str, - language_extensions_to_add: IO, + language_extensions_to_add: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1602,18 +1439,10 @@ async def begin_add_language_extensions( Required. :type resource_group_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 AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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: @@ -1625,7 +1454,7 @@ async def begin_add_language_extensions( workspace_name: str, kusto_pool_name: str, resource_group_name: str, - language_extensions_to_add: Union[_models.LanguageExtensionsList, IO], + 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. @@ -1637,20 +1466,10 @@ async def begin_add_language_extensions( :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param language_extensions_to_add: The language extensions to add. Is either a model type or a - IO type. Required. - :type language_extensions_to_add: ~azure.mgmt.synapse.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 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.synapse.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: @@ -1658,16 +1477,14 @@ async def begin_add_language_extensions( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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( # type: ignore + raw_result = await self._add_language_extensions_initial( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_name, @@ -1679,11 +1496,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)) @@ -1692,27 +1510,23 @@ 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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/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_language_extensions_initial( self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, - language_extensions_to_remove: Union[_models.LanguageExtensionsList, IO], + language_extensions_to_remove: Union[_models.LanguageExtensionsList, IO[bytes]], **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1723,21 +1537,19 @@ async def _remove_language_extensions_initial( # pylint: disable=inconsistent-r _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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, (IO, bytes)): + 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( + _request = build_remove_language_extensions_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_name, @@ -1746,30 +1558,34 @@ 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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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 = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _remove_language_extensions_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/removeLanguageExtensions" - } + return deserialized # type: ignore @overload async def begin_remove_language_extensions( @@ -1796,14 +1612,6 @@ async 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 AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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: @@ -1815,7 +1623,7 @@ async def begin_remove_language_extensions( workspace_name: str, kusto_pool_name: str, resource_group_name: str, - language_extensions_to_remove: IO, + language_extensions_to_remove: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1830,18 +1638,10 @@ async def begin_remove_language_extensions( Required. :type resource_group_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 AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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: @@ -1853,7 +1653,7 @@ async def begin_remove_language_extensions( workspace_name: str, kusto_pool_name: str, resource_group_name: str, - language_extensions_to_remove: Union[_models.LanguageExtensionsList, IO], + 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. @@ -1865,20 +1665,10 @@ async def begin_remove_language_extensions( :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param language_extensions_to_remove: The language extensions to remove. Is either a model type - or a IO type. Required. - :type language_extensions_to_remove: ~azure.mgmt.synapse.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 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.synapse.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: @@ -1886,16 +1676,14 @@ async def begin_remove_language_extensions( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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_language_extensions_initial( # type: ignore + raw_result = await self._remove_language_extensions_initial( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_name, @@ -1907,11 +1695,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)) @@ -1920,17 +1709,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_remove_language_extensions.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/removeLanguageExtensions" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def list_follower_databases( @@ -1946,7 +1731,6 @@ def list_follower_databases( :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 FollowerDatabaseDefinition or the result of cls(response) :rtype: @@ -1956,12 +1740,10 @@ def list_follower_databases( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.FollowerDatabaseListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1972,25 +1754,22 @@ 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( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _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) @@ -2000,10 +1779,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2016,19 +1796,15 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_follower_databases.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/listFollowerDatabases" - } - - async def _detach_follower_databases_initial( # pylint: disable=inconsistent-return-statements + async def _detach_follower_databases_initial( self, workspace_name: str, kusto_pool_name: str, resource_group_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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2039,21 +1815,19 @@ async def _detach_follower_databases_initial( # pylint: disable=inconsistent-re _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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(follower_database_to_remove, (IO, bytes)): + 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( + _request = build_detach_follower_databases_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_name, @@ -2062,30 +1836,34 @@ 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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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 = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _detach_follower_databases_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/detachFollowerDatabases" - } + return deserialized # type: ignore @overload async def begin_detach_follower_databases( @@ -2112,14 +1890,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: @@ -2131,7 +1901,7 @@ async def begin_detach_follower_databases( workspace_name: str, kusto_pool_name: str, resource_group_name: str, - follower_database_to_remove: IO, + follower_database_to_remove: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -2146,18 +1916,10 @@ async def begin_detach_follower_databases( Required. :type resource_group_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: @@ -2169,7 +1931,7 @@ async def begin_detach_follower_databases( workspace_name: str, kusto_pool_name: str, resource_group_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 Kusto Pool. @@ -2182,19 +1944,9 @@ async def begin_detach_follower_databases( Required. :type resource_group_name: str :param follower_database_to_remove: The follower databases properties to remove. Is either a - model type or a IO type. Required. - :type follower_database_to_remove: ~azure.mgmt.synapse.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.synapse.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: @@ -2202,16 +1954,14 @@ async def begin_detach_follower_databases( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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._detach_follower_databases_initial( # type: ignore + raw_result = await self._detach_follower_databases_initial( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_name, @@ -2223,11 +1973,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)) @@ -2236,14 +1987,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_detach_follower_databases.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/detachFollowerDatabases" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_libraries_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_libraries_operations.py index a92afd44a686..5036c4953e86 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_libraries_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_libraries_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -19,20 +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 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._libraries_operations import build_list_by_workspace_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -69,7 +66,6 @@ def list_by_workspace( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LibraryResource or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.LibraryResource] :raises ~azure.core.exceptions.HttpResponseError: @@ -77,12 +73,10 @@ def list_by_workspace( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.LibraryListResponse] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -93,24 +87,21 @@ def list_by_workspace( def prepare_request(next_link=None): if not next_link: - request = build_list_by_workspace_request( + _request = build_list_by_workspace_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_workspace.metadata["url"], 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("LibraryListResponse", pipeline_response) @@ -120,10 +111,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -135,7 +127,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_workspace.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/libraries" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_library_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_library_operations.py index 990d2d64e53b..e6a6c8ab19eb 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_library_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_library_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -18,20 +17,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._library_operations import build_get_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -70,12 +67,11 @@ async def get( :type library_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LibraryResource or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.LibraryResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -86,26 +82,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.LibraryResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, library_name=library_name, workspace_name=workspace_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -115,13 +108,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("LibraryResource", pipeline_response) + deserialized = self._deserialize("LibraryResource", 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.Synapse/workspaces/{workspaceName}/libraries/{libraryName}" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_operations.py index 6439a782f52a..f1b968beee68 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, overload @@ -18,14 +18,12 @@ 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 import ( build_check_name_availability_request, build_get_azure_async_header_result_request, @@ -33,10 +31,10 @@ build_list_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -73,7 +71,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: CheckNameAvailabilityResponse or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.CheckNameAvailabilityResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -81,18 +78,17 @@ async def check_name_availability( @overload async def check_name_availability( - self, request: IO, *, content_type: str = "application/json", **kwargs: Any + self, request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResponse: """Check name availability. Check whether a workspace name is available. :param request: The check request. Required. - :type request: IO + :type 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 :return: CheckNameAvailabilityResponse or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.CheckNameAvailabilityResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -100,23 +96,20 @@ async def check_name_availability( @distributed_trace_async async def check_name_availability( - self, request: Union[_models.CheckNameAvailabilityRequest, IO], **kwargs: Any + self, request: Union[_models.CheckNameAvailabilityRequest, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResponse: """Check name availability. Check whether a workspace name is available. - :param request: The check request. Is either a model type or a IO type. Required. - :type request: ~azure.mgmt.synapse.models.CheckNameAvailabilityRequest 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 request: The check request. Is either a CheckNameAvailabilityRequest type or a IO[bytes] + type. Required. + :type request: ~azure.mgmt.synapse.models.CheckNameAvailabilityRequest or IO[bytes] :return: CheckNameAvailabilityResponse or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.CheckNameAvailabilityResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -127,33 +120,32 @@ async def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CheckNameAvailabilityResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(request, (IO, bytes)): + if isinstance(request, (IOBase, bytes)): _content = request else: _json = self._serialize.body(request, "CheckNameAvailabilityRequest") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -163,16 +155,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("CheckNameAvailabilityResponse", pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResponse", 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.Synapse/checkNameAvailability" - } + return deserialized # type: ignore @distributed_trace_async async def list(self, **kwargs: Any) -> List[_models.AvailableRpOperation]: @@ -180,12 +168,11 @@ async def list(self, **kwargs: Any) -> List[_models.AvailableRpOperation]: Get all available operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: list of AvailableRpOperation or the result of cls(response) :rtype: list[~azure.mgmt.synapse.models.AvailableRpOperation] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -198,16 +185,15 @@ async def list(self, **kwargs: Any) -> List[_models.AvailableRpOperation]: cls: ClsType[List[_models.AvailableRpOperation]] = kwargs.pop("cls", None) - request = build_list_request( - template_url=self.list.metadata["url"], + _request = build_list_request( 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -217,17 +203,15 @@ async def list(self, **kwargs: Any) -> List[_models.AvailableRpOperation]: error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("[AvailableRpOperation]", pipeline_response) + deserialized = self._deserialize("[AvailableRpOperation]", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list.metadata = {"url": "/providers/Microsoft.Synapse/operations"} + return deserialized # type: ignore @distributed_trace_async - async def get_location_header_result( # pylint: disable=inconsistent-return-statements + async def get_location_header_result( self, resource_group_name: str, workspace_name: str, operation_id: str, **kwargs: Any ) -> None: """Get operation result. @@ -241,12 +225,11 @@ async def get_location_header_result( # pylint: disable=inconsistent-return-sta :type workspace_name: str :param operation_id: Operation ID. Required. :type operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -257,24 +240,23 @@ async def get_location_header_result( # pylint: disable=inconsistent-return-sta _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_get_location_header_result_request( + _request = build_get_location_header_result_request( resource_group_name=resource_group_name, workspace_name=workspace_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_location_header_result.metadata["url"], 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -285,11 +267,7 @@ async def get_location_header_result( # pylint: disable=inconsistent-return-sta raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - get_location_header_result.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/operationResults/{operationId}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get_azure_async_header_result( @@ -306,12 +284,11 @@ async def get_azure_async_header_result( :type workspace_name: str :param operation_id: Operation ID. Required. :type operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: OperationResource or None or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.OperationResource or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -322,24 +299,23 @@ async def get_azure_async_header_result( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[Optional[_models.OperationResource]] = kwargs.pop("cls", None) - request = build_get_azure_async_header_result_request( + _request = build_get_azure_async_header_result_request( resource_group_name=resource_group_name, workspace_name=workspace_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_azure_async_header_result.metadata["url"], 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -351,13 +327,9 @@ async def get_azure_async_header_result( deserialized = None if response.status_code == 200: - deserialized = self._deserialize("OperationResource", pipeline_response) + deserialized = self._deserialize("OperationResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_azure_async_header_result.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/operationStatuses/{operationId}" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_private_endpoint_connections_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_private_endpoint_connections_operations.py index 953214c1ad2a..823a8bafb244 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_private_endpoint_connections_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -16,12 +16,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 @@ -29,7 +30,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_request, build_delete_request, @@ -37,10 +37,10 @@ build_list_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -77,12 +77,11 @@ async def get( :type workspace_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.synapse.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -93,24 +92,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -120,26 +118,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.Synapse/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, workspace_name: str, private_endpoint_connection_name: str, - request: Union[_models.PrivateEndpointConnection, IO], + request: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any - ) -> _models.PrivateEndpointConnection: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -150,19 +144,19 @@ async def _create_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) 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 _content = None - if isinstance(request, (IO, bytes)): + if isinstance(request, (IOBase, bytes)): _content = request else: _json = self._serialize.body(request, "PrivateEndpointConnection") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, workspace_name=workspace_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -171,39 +165,35 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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=False, **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_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - @overload async def begin_create( self, @@ -229,14 +219,6 @@ async def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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: @@ -250,7 +232,7 @@ async def begin_create( resource_group_name: str, workspace_name: str, private_endpoint_connection_name: str, - request: IO, + request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -265,18 +247,10 @@ async def begin_create( :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param request: Request body of private endpoint connection to create. Required. - :type request: IO + :type 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 PrivateEndpointConnection or the result of cls(response) :rtype: @@ -290,7 +264,7 @@ async def begin_create( resource_group_name: str, workspace_name: str, private_endpoint_connection_name: str, - request: Union[_models.PrivateEndpointConnection, IO], + request: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Approve or reject a private endpoint connection. @@ -302,20 +276,9 @@ async def begin_create( :type workspace_name: str :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :param request: Request body of private endpoint connection to create. Is either a model type - or a IO type. Required. - :type request: ~azure.mgmt.synapse.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 request: Request body of private endpoint connection to create. Is either a + PrivateEndpointConnection type or a IO[bytes] type. Required. + :type request: ~azure.mgmt.synapse.models.PrivateEndpointConnection or IO[bytes] :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -325,7 +288,7 @@ async def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -344,12 +307,13 @@ async def begin_create( 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: @@ -362,22 +326,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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return AsyncLROPoller[_models.PrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _delete_initial( self, resource_group_name: str, workspace_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> Optional[_models.OperationResource]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -388,45 +350,43 @@ async def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - cls: ClsType[Optional[_models.OperationResource]] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) - deserialized = None - if response.status_code == 202: - deserialized = self._deserialize("OperationResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -441,14 +401,6 @@ async def begin_delete( :type workspace_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 OperationResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.OperationResource] @@ -457,7 +409,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) 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) @@ -473,12 +425,13 @@ 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): - deserialized = self._deserialize("OperationResource", pipeline_response) + deserialized = self._deserialize("OperationResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -488,17 +441,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.OperationResource].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.Synapse/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return AsyncLROPoller[_models.OperationResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list( @@ -511,7 +462,6 @@ def list( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_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: @@ -521,10 +471,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.PrivateEndpointConnectionList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -535,24 +485,21 @@ 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, workspace_name=workspace_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionList", pipeline_response) @@ -562,10 +509,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -577,7 +525,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.Synapse/workspaces/{workspaceName}/privateEndpointConnections" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_private_endpoint_connections_private_link_hub_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_private_endpoint_connections_private_link_hub_operations.py index c0ceb91a94c0..c5d5078acfc3 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_private_endpoint_connections_private_link_hub_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_private_endpoint_connections_private_link_hub_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -19,29 +18,27 @@ 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_endpoint_connections_private_link_hub_operations import ( build_get_request, build_list_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PrivateEndpointConnectionsPrivateLinkHubOperations: +class PrivateEndpointConnectionsPrivateLinkHubOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -71,7 +68,6 @@ def list( :type resource_group_name: str :param private_link_hub_name: Name of the privateLinkHub. Required. :type private_link_hub_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PrivateEndpointConnectionForPrivateLinkHub or the result of cls(response) :rtype: @@ -81,12 +77,12 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.PrivateEndpointConnectionForPrivateLinkHubResourceCollectionResponse] = kwargs.pop( "cls", None ) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,24 +93,21 @@ 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, private_link_hub_name=private_link_hub_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize( @@ -126,10 +119,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -142,10 +136,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}/privateEndpointConnections" - } - @distributed_trace_async async def get( self, resource_group_name: str, private_link_hub_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -159,12 +149,11 @@ async def get( :type private_link_hub_name: str :param private_endpoint_connection_name: Name of the privateEndpointConnection. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnectionForPrivateLinkHub or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.PrivateEndpointConnectionForPrivateLinkHub :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -175,24 +164,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.PrivateEndpointConnectionForPrivateLinkHub] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, private_link_hub_name=private_link_hub_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -202,13 +190,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("PrivateEndpointConnectionForPrivateLinkHub", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnectionForPrivateLinkHub", 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.Synapse/privateLinkHubs/{privateLinkHubName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_private_link_hub_private_link_resources_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_private_link_hub_private_link_resources_operations.py index f9dde6020cd3..06689b762811 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_private_link_hub_private_link_resources_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_private_link_hub_private_link_resources_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -19,26 +18,24 @@ 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_hub_private_link_resources_operations import build_get_request, build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PrivateLinkHubPrivateLinkResourcesOperations: +class PrivateLinkHubPrivateLinkResourcesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -70,7 +67,6 @@ def list( :type resource_group_name: str :param private_link_hub_name: The name of the private link hub. Required. :type private_link_hub_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.synapse.models.PrivateLinkResource] :raises ~azure.core.exceptions.HttpResponseError: @@ -78,10 +74,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -92,24 +88,21 @@ 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, private_link_hub_name=private_link_hub_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _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) @@ -119,10 +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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -135,10 +129,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}/privateLinkResources" - } - @distributed_trace_async async def get( self, resource_group_name: str, private_link_hub_name: str, private_link_resource_name: str, **kwargs: Any @@ -154,12 +144,11 @@ async def get( :type private_link_hub_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.synapse.models.PrivateLinkResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -170,24 +159,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, private_link_hub_name=private_link_hub_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -197,13 +185,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.Synapse/privateLinkHubs/{privateLinkHubName}/privateLinkResources/{privateLinkResourceName}" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_private_link_hubs_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_private_link_hubs_operations.py index 59210109ff6d..efbd363f1e26 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_private_link_hubs_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_private_link_hubs_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -16,12 +16,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 @@ -29,7 +30,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._private_link_hubs_operations import ( build_create_or_update_request, build_delete_request, @@ -39,10 +39,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -75,7 +75,6 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PrivateLinkHub or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.PrivateLinkHub] :raises ~azure.core.exceptions.HttpResponseError: @@ -83,10 +82,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.PrivateLinkHubInfoListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,23 +96,20 @@ def list_by_resource_group( 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateLinkHubInfoListResult", pipeline_response) @@ -123,10 +119,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -139,10 +136,6 @@ 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.Synapse/privateLinkHubs" - } - @distributed_trace_async async def get(self, resource_group_name: str, private_link_hub_name: str, **kwargs: Any) -> _models.PrivateLinkHub: """Gets a privateLinkHub. @@ -152,12 +145,11 @@ async def get(self, resource_group_name: str, private_link_hub_name: str, **kwar :type resource_group_name: str :param private_link_hub_name: Name of the privateLinkHub. Required. :type private_link_hub_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateLinkHub or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.PrivateLinkHub :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -168,23 +160,22 @@ async def get(self, resource_group_name: str, private_link_hub_name: str, **kwar _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.PrivateLinkHub] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, private_link_hub_name=private_link_hub_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -194,16 +185,12 @@ async def get(self, resource_group_name: str, private_link_hub_name: str, **kwar error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateLinkHub", pipeline_response) + deserialized = self._deserialize("PrivateLinkHub", 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.Synapse/privateLinkHubs/{privateLinkHubName}" - } + return deserialized # type: ignore @overload async def update( @@ -227,7 +214,6 @@ async def 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 :return: PrivateLinkHub or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.PrivateLinkHub :raises ~azure.core.exceptions.HttpResponseError: @@ -238,7 +224,7 @@ async def update( self, resource_group_name: str, private_link_hub_name: str, - private_link_hub_patch_info: IO, + private_link_hub_patch_info: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -251,11 +237,10 @@ async def update( :param private_link_hub_name: Name of the privateLinkHub. Required. :type private_link_hub_name: str :param private_link_hub_patch_info: PrivateLinkHub patch request properties. Required. - :type private_link_hub_patch_info: IO + :type private_link_hub_patch_info: 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: PrivateLinkHub or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.PrivateLinkHub :raises ~azure.core.exceptions.HttpResponseError: @@ -266,7 +251,7 @@ async def update( self, resource_group_name: str, private_link_hub_name: str, - private_link_hub_patch_info: Union[_models.PrivateLinkHubPatchInfo, IO], + private_link_hub_patch_info: Union[_models.PrivateLinkHubPatchInfo, IO[bytes]], **kwargs: Any ) -> _models.PrivateLinkHub: """Updates a privateLinkHub. @@ -276,18 +261,15 @@ async def update( :type resource_group_name: str :param private_link_hub_name: Name of the privateLinkHub. Required. :type private_link_hub_name: str - :param private_link_hub_patch_info: PrivateLinkHub patch request properties. Is either a model - type or a IO type. Required. - :type private_link_hub_patch_info: ~azure.mgmt.synapse.models.PrivateLinkHubPatchInfo 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 private_link_hub_patch_info: PrivateLinkHub patch request properties. Is either a + PrivateLinkHubPatchInfo type or a IO[bytes] type. Required. + :type private_link_hub_patch_info: ~azure.mgmt.synapse.models.PrivateLinkHubPatchInfo or + IO[bytes] :return: PrivateLinkHub or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.PrivateLinkHub :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -298,19 +280,19 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateLinkHub] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(private_link_hub_patch_info, (IO, bytes)): + if isinstance(private_link_hub_patch_info, (IOBase, bytes)): _content = private_link_hub_patch_info else: _json = self._serialize.body(private_link_hub_patch_info, "PrivateLinkHubPatchInfo") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, private_link_hub_name=private_link_hub_name, subscription_id=self._config.subscription_id, @@ -318,15 +300,14 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -336,21 +317,13 @@ async def update( 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("PrivateLinkHub", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("PrivateLinkHub", pipeline_response) + deserialized = self._deserialize("PrivateLinkHub", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}" - } - @overload async def create_or_update( self, @@ -373,7 +346,6 @@ async def 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 :return: PrivateLinkHub or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.PrivateLinkHub :raises ~azure.core.exceptions.HttpResponseError: @@ -384,7 +356,7 @@ async def create_or_update( self, resource_group_name: str, private_link_hub_name: str, - private_link_hub_info: IO, + private_link_hub_info: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -397,11 +369,10 @@ async def create_or_update( :param private_link_hub_name: Name of the privateLinkHub. Required. :type private_link_hub_name: str :param private_link_hub_info: PrivateLinkHub create or update request properties. Required. - :type private_link_hub_info: IO + :type private_link_hub_info: 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: PrivateLinkHub or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.PrivateLinkHub :raises ~azure.core.exceptions.HttpResponseError: @@ -412,7 +383,7 @@ async def create_or_update( self, resource_group_name: str, private_link_hub_name: str, - private_link_hub_info: Union[_models.PrivateLinkHub, IO], + private_link_hub_info: Union[_models.PrivateLinkHub, IO[bytes]], **kwargs: Any ) -> _models.PrivateLinkHub: """Creates or updates a privateLinkHub. @@ -423,17 +394,13 @@ async def create_or_update( :param private_link_hub_name: Name of the privateLinkHub. Required. :type private_link_hub_name: str :param private_link_hub_info: PrivateLinkHub create or update request properties. Is either a - model type or a IO type. Required. - :type private_link_hub_info: ~azure.mgmt.synapse.models.PrivateLinkHub 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 + PrivateLinkHub type or a IO[bytes] type. Required. + :type private_link_hub_info: ~azure.mgmt.synapse.models.PrivateLinkHub or IO[bytes] :return: PrivateLinkHub or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.PrivateLinkHub :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -444,19 +411,19 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateLinkHub] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(private_link_hub_info, (IO, bytes)): + if isinstance(private_link_hub_info, (IOBase, bytes)): _content = private_link_hub_info else: _json = self._serialize.body(private_link_hub_info, "PrivateLinkHub") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, private_link_hub_name=private_link_hub_name, subscription_id=self._config.subscription_id, @@ -464,15 +431,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -482,25 +448,17 @@ async def create_or_update( 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("PrivateLinkHub", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("PrivateLinkHub", pipeline_response) + deserialized = self._deserialize("PrivateLinkHub", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}" - } - - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, private_link_hub_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -511,38 +469,42 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, private_link_hub_name=private_link_hub_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -555,14 +517,6 @@ async def begin_delete( :type resource_group_name: str :param private_link_hub_name: Name of the privateLinkHub. Required. :type private_link_hub_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: @@ -570,13 +524,13 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) 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._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, private_link_hub_name=private_link_hub_name, api_version=api_version, @@ -585,36 +539,35 @@ 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)) + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) 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.Synapse/privateLinkHubs/{privateLinkHubName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.PrivateLinkHub"]: """Returns a list of privateLinkHubs in a subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PrivateLinkHub or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.PrivateLinkHub] :raises ~azure.core.exceptions.HttpResponseError: @@ -622,10 +575,10 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.PrivateLinkHub"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.PrivateLinkHubInfoListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -636,22 +589,19 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.PrivateLinkHub"]: 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateLinkHubInfoListResult", pipeline_response) @@ -661,10 +611,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -676,5 +627,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Synapse/privateLinkHubs"} diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_private_link_resources_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_private_link_resources_operations.py index c5eefab2689a..137e4b21a0e8 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_private_link_resources_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_private_link_resources_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -19,21 +18,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, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -70,7 +67,6 @@ def list( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_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.synapse.models.PrivateLinkResource] :raises ~azure.core.exceptions.HttpResponseError: @@ -78,10 +74,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -92,24 +88,21 @@ 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, workspace_name=workspace_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _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) @@ -119,10 +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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -135,10 +129,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateLinkResources" - } - @distributed_trace_async async def get( self, resource_group_name: str, workspace_name: str, private_link_resource_name: str, **kwargs: Any @@ -154,12 +144,11 @@ async def get( :type workspace_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.synapse.models.PrivateLinkResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -170,24 +159,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -197,13 +185,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.Synapse/workspaces/{workspaceName}/privateLinkResources/{privateLinkResourceName}" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_restorable_dropped_sql_pools_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_restorable_dropped_sql_pools_operations.py index 9311dff8dc0a..7c5523152957 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_restorable_dropped_sql_pools_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_restorable_dropped_sql_pools_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -19,21 +18,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._restorable_dropped_sql_pools_operations import build_get_request, build_list_by_workspace_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -71,12 +68,11 @@ async def get( :param restorable_dropped_sql_pool_id: The id of the deleted Sql Pool in the form of sqlPoolName,deletionTimeInFileTimeFormat. Required. :type restorable_dropped_sql_pool_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RestorableDroppedSqlPool or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.RestorableDroppedSqlPool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -87,24 +83,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.RestorableDroppedSqlPool] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, restorable_dropped_sql_pool_id=restorable_dropped_sql_pool_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -114,16 +109,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("RestorableDroppedSqlPool", pipeline_response) + deserialized = self._deserialize("RestorableDroppedSqlPool", 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.Synapse/workspaces/{workspaceName}/restorableDroppedSqlPools/{restorableDroppedSqlPoolId}" - } + return deserialized # type: ignore @distributed_trace def list_by_workspace( @@ -136,7 +127,6 @@ def list_by_workspace( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RestorableDroppedSqlPool or the result of cls(response) :rtype: @@ -146,10 +136,10 @@ def list_by_workspace( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.RestorableDroppedSqlPoolListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -160,24 +150,21 @@ def list_by_workspace( def prepare_request(next_link=None): if not next_link: - request = build_list_by_workspace_request( + _request = build_list_by_workspace_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_workspace.metadata["url"], 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RestorableDroppedSqlPoolListResult", pipeline_response) @@ -187,10 +174,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -202,7 +190,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_workspace.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/restorableDroppedSqlPools" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_spark_configuration_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_spark_configuration_operations.py index b4c6ac249467..03e9fafddbcb 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_spark_configuration_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_spark_configuration_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -18,20 +17,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._spark_configuration_operations import build_get_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -70,12 +67,11 @@ async def get( :type spark_configuration_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SparkConfigurationResource or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SparkConfigurationResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -86,26 +82,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.SparkConfigurationResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, spark_configuration_name=spark_configuration_name, workspace_name=workspace_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -115,13 +108,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("SparkConfigurationResource", pipeline_response) + deserialized = self._deserialize("SparkConfigurationResource", 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.Synapse/workspaces/{workspaceName}/sparkconfigurations/{sparkConfigurationName}" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_spark_configurations_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_spark_configurations_operations.py index 6a207ac4034f..fcd4d51b46a8 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_spark_configurations_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_spark_configurations_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -19,20 +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 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._spark_configurations_operations import build_list_by_workspace_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -69,7 +66,6 @@ def list_by_workspace( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SparkConfigurationResource or the result of cls(response) :rtype: @@ -79,12 +75,10 @@ def list_by_workspace( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.SparkConfigurationListResponse] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -95,24 +89,21 @@ def list_by_workspace( def prepare_request(next_link=None): if not next_link: - request = build_list_by_workspace_request( + _request = build_list_by_workspace_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_workspace.metadata["url"], 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("SparkConfigurationListResponse", pipeline_response) @@ -122,10 +113,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -137,7 +129,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_workspace.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sparkconfigurations" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_blob_auditing_policies_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_blob_auditing_policies_operations.py index 85489683e35b..10bf88af3fd6 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_blob_auditing_policies_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_blob_auditing_policies_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,25 +19,23 @@ 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._sql_pool_blob_auditing_policies_operations import ( build_create_or_update_request, build_get_request, build_list_by_sql_pool_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -76,15 +74,11 @@ async def get( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword blob_auditing_policy_name: The name of the blob auditing policy. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype blob_auditing_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SqlPoolBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolBlobAuditingPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -95,26 +89,25 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") cls: ClsType[_models.SqlPoolBlobAuditingPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, subscription_id=self._config.subscription_id, api_version=api_version, blob_auditing_policy_name=blob_auditing_policy_name, - 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -123,16 +116,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("SqlPoolBlobAuditingPolicy", pipeline_response) + deserialized = self._deserialize("SqlPoolBlobAuditingPolicy", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/auditingSettings/{blobAuditingPolicyName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -161,10 +150,6 @@ async def 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 blob_auditing_policy_name: The name of the blob auditing policy. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype blob_auditing_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SqlPoolBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolBlobAuditingPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -176,7 +161,7 @@ async def create_or_update( resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -193,14 +178,10 @@ async def create_or_update( :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str :param parameters: The database blob auditing policy. 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 blob_auditing_policy_name: The name of the blob auditing policy. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype blob_auditing_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SqlPoolBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolBlobAuditingPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -212,7 +193,7 @@ async def create_or_update( resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: Union[_models.SqlPoolBlobAuditingPolicy, IO], + parameters: Union[_models.SqlPoolBlobAuditingPolicy, IO[bytes]], **kwargs: Any ) -> _models.SqlPoolBlobAuditingPolicy: """Creates or updates a SQL pool's blob auditing policy. @@ -226,21 +207,14 @@ async def create_or_update( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param parameters: The database blob auditing policy. Is either a model type or a IO type. - Required. - :type parameters: ~azure.mgmt.synapse.models.SqlPoolBlobAuditingPolicy or IO - :keyword blob_auditing_policy_name: The name of the blob auditing policy. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype blob_auditing_policy_name: 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 + :param parameters: The database blob auditing policy. Is either a SqlPoolBlobAuditingPolicy + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.SqlPoolBlobAuditingPolicy or IO[bytes] :return: SqlPoolBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolBlobAuditingPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -251,7 +225,7 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SqlPoolBlobAuditingPolicy] = kwargs.pop("cls", None) @@ -259,12 +233,12 @@ async def create_or_update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "SqlPoolBlobAuditingPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -274,15 +248,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -291,21 +264,13 @@ async def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("SqlPoolBlobAuditingPolicy", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SqlPoolBlobAuditingPolicy", pipeline_response) + deserialized = self._deserialize("SqlPoolBlobAuditingPolicy", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/auditingSettings/{blobAuditingPolicyName}" - } - @distributed_trace def list_by_sql_pool( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any @@ -319,7 +284,6 @@ def list_by_sql_pool( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SqlPoolBlobAuditingPolicy or the result of cls(response) :rtype: @@ -329,10 +293,10 @@ def list_by_sql_pool( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPoolBlobAuditingPolicyListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -343,25 +307,22 @@ def list_by_sql_pool( def prepare_request(next_link=None): if not next_link: - request = build_list_by_sql_pool_request( + _request = build_list_by_sql_pool_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_sql_pool.metadata["url"], 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("SqlPoolBlobAuditingPolicyListResult", pipeline_response) @@ -371,10 +332,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -385,7 +347,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_sql_pool.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/auditingSettings" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_columns_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_columns_operations.py index f0b94aee8fbb..38ea1cd5f085 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_columns_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_columns_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -18,20 +17,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._sql_pool_columns_operations import build_get_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -81,12 +78,11 @@ async def get( :type table_name: str :param column_name: The name of the column. Required. :type column_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SqlPoolColumn or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolColumn :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,10 +93,10 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPoolColumn] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -109,15 +105,14 @@ async def get( column_name=column_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -126,13 +121,9 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("SqlPoolColumn", pipeline_response) + deserialized = self._deserialize("SqlPoolColumn", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_connection_policies_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_connection_policies_operations.py index 0fdca0bd2f6d..1de93106440b 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_connection_policies_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_connection_policies_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -18,20 +17,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._sql_pool_connection_policies_operations import build_get_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -77,12 +74,11 @@ async def get( :type sql_pool_name: str :param connection_policy_name: The name of the connection policy. "default" Required. :type connection_policy_name: str or ~azure.mgmt.synapse.models.ConnectionPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: SqlPoolConnectionPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolConnectionPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -93,25 +89,24 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPoolConnectionPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, connection_policy_name=connection_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -121,13 +116,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("SqlPoolConnectionPolicy", pipeline_response) + deserialized = self._deserialize("SqlPoolConnectionPolicy", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/connectionPolicies/{connectionPolicyName}" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_data_warehouse_user_activities_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_data_warehouse_user_activities_operations.py index 35baafeb64c2..f92965d4bc06 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_data_warehouse_user_activities_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_data_warehouse_user_activities_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -18,25 +17,23 @@ 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._sql_pool_data_warehouse_user_activities_operations import build_get_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SqlPoolDataWarehouseUserActivitiesOperations: +class SqlPoolDataWarehouseUserActivitiesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -79,12 +76,11 @@ async def get( Required. :type data_warehouse_user_activity_name: str or ~azure.mgmt.synapse.models.DataWarehouseUserActivityName - :keyword callable cls: A custom type or function that will be passed the direct response :return: DataWarehouseUserActivities or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.DataWarehouseUserActivities :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -95,25 +91,24 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.DataWarehouseUserActivities] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, data_warehouse_user_activity_name=data_warehouse_user_activity_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -122,13 +117,9 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("DataWarehouseUserActivities", pipeline_response) + deserialized = self._deserialize("DataWarehouseUserActivities", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataWarehouseUserActivities/{dataWarehouseUserActivityName}" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_geo_backup_policies_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_geo_backup_policies_operations.py index 50aef3caa2de..c792614bcbf6 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_geo_backup_policies_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_geo_backup_policies_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload @@ -19,25 +19,23 @@ 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._sql_pool_geo_backup_policies_operations import ( build_create_or_update_request, build_get_request, build_list_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -76,7 +74,6 @@ def list( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either GeoBackupPolicy or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.GeoBackupPolicy] :raises ~azure.core.exceptions.HttpResponseError: @@ -84,10 +81,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.GeoBackupPolicyListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -98,25 +95,22 @@ 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, workspace_name=workspace_name, sql_pool_name=sql_pool_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("GeoBackupPolicyListResult", pipeline_response) @@ -126,10 +120,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -142,10 +137,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/geoBackupPolicies" - } - @overload async def create_or_update( self, @@ -175,7 +166,6 @@ async def 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 :return: GeoBackupPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.GeoBackupPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -188,7 +178,7 @@ async def create_or_update( workspace_name: str, sql_pool_name: str, geo_backup_policy_name: Union[str, _models.GeoBackupPolicyName], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -206,11 +196,10 @@ async def create_or_update( :type geo_backup_policy_name: str or ~azure.mgmt.synapse.models.GeoBackupPolicyName :param parameters: The required parameters for creating or updating the geo backup policy. 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: GeoBackupPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.GeoBackupPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -223,7 +212,7 @@ async def create_or_update( workspace_name: str, sql_pool_name: str, geo_backup_policy_name: Union[str, _models.GeoBackupPolicyName], - parameters: Union[_models.GeoBackupPolicy, IO], + parameters: Union[_models.GeoBackupPolicy, IO[bytes]], **kwargs: Any ) -> _models.GeoBackupPolicy: """Updates a SQL Pool geo backup policy. @@ -238,17 +227,13 @@ async def create_or_update( :param geo_backup_policy_name: The name of the geo backup policy. "Default" Required. :type geo_backup_policy_name: str or ~azure.mgmt.synapse.models.GeoBackupPolicyName :param parameters: The required parameters for creating or updating the geo backup policy. Is - either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.models.GeoBackupPolicy 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 + either a GeoBackupPolicy type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.GeoBackupPolicy or IO[bytes] :return: GeoBackupPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.GeoBackupPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -259,19 +244,19 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.GeoBackupPolicy] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "GeoBackupPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -281,15 +266,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -299,21 +283,13 @@ async def create_or_update( 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("GeoBackupPolicy", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("GeoBackupPolicy", pipeline_response) + deserialized = self._deserialize("GeoBackupPolicy", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/geoBackupPolicies/{geoBackupPolicyName}" - } - @distributed_trace_async async def get( self, @@ -336,12 +312,11 @@ async def get( :type sql_pool_name: str :param geo_backup_policy_name: The name of the geo backup policy. "Default" Required. :type geo_backup_policy_name: str or ~azure.mgmt.synapse.models.GeoBackupPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: GeoBackupPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.GeoBackupPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -352,25 +327,24 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.GeoBackupPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, geo_backup_policy_name=geo_backup_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -380,13 +354,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("GeoBackupPolicy", pipeline_response) + deserialized = self._deserialize("GeoBackupPolicy", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/geoBackupPolicies/{geoBackupPolicyName}" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_maintenance_window_options_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_maintenance_window_options_operations.py index 91c64759b623..ee7760f99ac7 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_maintenance_window_options_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_maintenance_window_options_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -18,25 +17,23 @@ 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._sql_pool_maintenance_window_options_operations import build_get_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SqlPoolMaintenanceWindowOptionsOperations: +class SqlPoolMaintenanceWindowOptionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -77,12 +74,11 @@ async def get( :type sql_pool_name: str :param maintenance_window_options_name: Maintenance window options name. Required. :type maintenance_window_options_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: MaintenanceWindowOptions or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.MaintenanceWindowOptions :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -93,25 +89,24 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.MaintenanceWindowOptions] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, subscription_id=self._config.subscription_id, maintenance_window_options_name=maintenance_window_options_name, 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -120,13 +115,9 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("MaintenanceWindowOptions", pipeline_response) + deserialized = self._deserialize("MaintenanceWindowOptions", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/maintenanceWindowOptions/current" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_maintenance_windows_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_maintenance_windows_operations.py index ee402a7a2147..5b3a8157989c 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_maintenance_windows_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_maintenance_windows_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload @@ -18,20 +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._sql_pool_maintenance_windows_operations import build_create_or_update_request, build_get_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -77,12 +75,11 @@ async def get( :type sql_pool_name: str :param maintenance_window_name: Maintenance window name. Required. :type maintenance_window_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: MaintenanceWindows or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.MaintenanceWindows :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -93,25 +90,24 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.MaintenanceWindows] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, subscription_id=self._config.subscription_id, maintenance_window_name=maintenance_window_name, 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -121,19 +117,15 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("MaintenanceWindows", pipeline_response) + deserialized = self._deserialize("MaintenanceWindows", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/maintenancewindows/current" - } + return deserialized # type: ignore @overload - async def create_or_update( # pylint: disable=inconsistent-return-statements + async def create_or_update( self, resource_group_name: str, workspace_name: str, @@ -163,20 +155,19 @@ async def create_or_update( # pylint: disable=inconsistent-return-statements :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. 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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def create_or_update( # pylint: disable=inconsistent-return-statements + async def create_or_update( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, maintenance_window_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -196,24 +187,23 @@ async def create_or_update( # pylint: disable=inconsistent-return-statements :type maintenance_window_name: str :param parameters: The required parameters for creating or updating Maintenance Windows settings. 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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def create_or_update( # pylint: disable=inconsistent-return-statements + async def create_or_update( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, maintenance_window_name: str, - parameters: Union[_models.MaintenanceWindows, IO], + parameters: Union[_models.MaintenanceWindows, IO[bytes]], **kwargs: Any ) -> None: """Creates or updates a Sql pool's maintenance windows settings. @@ -230,17 +220,13 @@ async def create_or_update( # pylint: disable=inconsistent-return-statements :param maintenance_window_name: Maintenance window name. Required. :type maintenance_window_name: str :param parameters: The required parameters for creating or updating Maintenance Windows - settings. Is either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.models.MaintenanceWindows 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 + settings. Is either a MaintenanceWindows type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.MaintenanceWindows or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -251,19 +237,19 @@ async def create_or_update( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "MaintenanceWindows") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -273,15 +259,14 @@ async def create_or_update( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -291,8 +276,4 @@ async def create_or_update( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/maintenancewindows/current" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_metadata_sync_configs_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_metadata_sync_configs_operations.py index dd2ccb8cd777..a4b2ba53f529 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_metadata_sync_configs_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_metadata_sync_configs_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload @@ -18,20 +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._sql_pool_metadata_sync_configs_operations import build_create_request, build_get_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -70,40 +68,38 @@ async def get( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: MetadataSyncConfig or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.MetadataSyncConfig :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, + 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, - 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.MetadataSyncConfig] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -113,16 +109,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("MetadataSyncConfig", pipeline_response) + deserialized = self._deserialize("MetadataSyncConfig", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/metadataSync/config" - } + return deserialized # type: ignore @overload async def create( @@ -151,7 +143,6 @@ async def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. 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: MetadataSyncConfig or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.MetadataSyncConfig :raises ~azure.core.exceptions.HttpResponseError: @@ -163,7 +154,7 @@ async def create( resource_group_name: str, workspace_name: str, sql_pool_name: str, - metadata_sync_configuration: IO, + metadata_sync_configuration: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -180,11 +171,10 @@ async def create( :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str :param metadata_sync_configuration: Metadata sync configuration. Required. - :type metadata_sync_configuration: IO + :type metadata_sync_configuration: 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: MetadataSyncConfig or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.MetadataSyncConfig :raises ~azure.core.exceptions.HttpResponseError: @@ -196,7 +186,7 @@ async def create( resource_group_name: str, workspace_name: str, sql_pool_name: str, - metadata_sync_configuration: Union[_models.MetadataSyncConfig, IO], + metadata_sync_configuration: Union[_models.MetadataSyncConfig, IO[bytes]], **kwargs: Any ) -> _models.MetadataSyncConfig: """Set SQL pool metadata sync config. @@ -210,41 +200,37 @@ async def create( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param metadata_sync_configuration: Metadata sync configuration. Is either a model type or a IO - type. Required. - :type metadata_sync_configuration: ~azure.mgmt.synapse.models.MetadataSyncConfig 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 metadata_sync_configuration: Metadata sync configuration. Is either a MetadataSyncConfig + type or a IO[bytes] type. Required. + :type metadata_sync_configuration: ~azure.mgmt.synapse.models.MetadataSyncConfig or IO[bytes] :return: MetadataSyncConfig or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.MetadataSyncConfig :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, + 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, - 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), } 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: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.MetadataSyncConfig] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(metadata_sync_configuration, (IO, bytes)): + if isinstance(metadata_sync_configuration, (IOBase, bytes)): _content = metadata_sync_configuration else: _json = self._serialize.body(metadata_sync_configuration, "MetadataSyncConfig") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -253,15 +239,14 @@ async def create( content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -271,13 +256,9 @@ async def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("MetadataSyncConfig", pipeline_response) + deserialized = self._deserialize("MetadataSyncConfig", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/metadataSync/config" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_operation_results_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_operation_results_operations.py index 20f3dd6a91cd..413593fd9d98 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_operation_results_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_operation_results_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, TypeVar, Union, cast +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,22 +17,18 @@ 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_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._sql_pool_operation_results_operations import build_get_location_header_result_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -57,10 +52,28 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - async def _get_location_header_result_initial( + @distributed_trace_async + async def get_location_header_result( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, operation_id: str, **kwargs: Any ) -> _models.SqlPool: - error_map = { + """Get SQL pool operation status. + + Get the status of a SQL pool operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param sql_pool_name: SQL pool name. Required. + :type sql_pool_name: str + :param operation_id: Operation ID. Required. + :type operation_id: str + :return: SqlPool or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.SqlPool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -71,122 +84,36 @@ async def _get_location_header_result_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPool] = kwargs.pop("cls", None) - request = build_get_location_header_result_request( + _request = build_get_location_header_result_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._get_location_header_result_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 pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("SqlPool", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("SqlPool", pipeline_response) + deserialized = self._deserialize("SqlPool", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - - _get_location_header_result_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/operationResults/{operationId}" - } - - @distributed_trace_async - async def begin_get_location_header_result( - self, resource_group_name: str, workspace_name: str, sql_pool_name: str, operation_id: str, **kwargs: Any - ) -> AsyncLROPoller[_models.SqlPool]: - """Get SQL pool operation status. - - Get the status of a SQL pool operation. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param workspace_name: The name of the workspace. Required. - :type workspace_name: str - :param sql_pool_name: SQL pool name. Required. - :type sql_pool_name: str - :param operation_id: Operation ID. Required. - :type operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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 SqlPool or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.SqlPool] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - cls: ClsType[_models.SqlPool] = 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._get_location_header_result_initial( - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - operation_id=operation_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SqlPool", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - 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.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_get_location_header_result.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/operationResults/{operationId}" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_operations_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_operations_operations.py index 47a4f7e7c1a7..e1608b3e8766 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_operations_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_operations_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -19,20 +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 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._sql_pool_operations_operations import build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -71,7 +68,6 @@ def list( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SqlPoolOperation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.SqlPoolOperation] :raises ~azure.core.exceptions.HttpResponseError: @@ -79,10 +75,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPoolBlobAuditingPolicySqlPoolOperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -93,25 +89,22 @@ 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, workspace_name=workspace_name, sql_pool_name=sql_pool_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("SqlPoolBlobAuditingPolicySqlPoolOperationListResult", pipeline_response) @@ -121,10 +114,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -135,7 +129,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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/operations" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_recommended_sensitivity_labels_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_recommended_sensitivity_labels_operations.py index 1d78b02f2e59..e41b294669e8 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_recommended_sensitivity_labels_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_recommended_sensitivity_labels_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload @@ -18,25 +18,23 @@ 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._sql_pool_recommended_sensitivity_labels_operations import build_update_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SqlPoolRecommendedSensitivityLabelsOperations: +class SqlPoolRecommendedSensitivityLabelsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -56,7 +54,7 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @overload - async def update( # pylint: disable=inconsistent-return-statements + async def update( self, resource_group_name: str, workspace_name: str, @@ -80,19 +78,18 @@ async def update( # pylint: disable=inconsistent-return-statements :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. 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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def update( # pylint: disable=inconsistent-return-statements + async def update( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -107,23 +104,22 @@ async def update( # pylint: disable=inconsistent-return-statements :param sql_pool_name: SQL pool name. Required. :type sql_pool_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 :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def update( # pylint: disable=inconsistent-return-statements + async def update( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: Union[_models.RecommendedSensitivityLabelUpdateList, IO], + parameters: Union[_models.RecommendedSensitivityLabelUpdateList, IO[bytes]], **kwargs: Any ) -> None: """Update recommended sensitivity labels states of a given SQL Pool using an operations batch. @@ -135,17 +131,14 @@ async def update( # pylint: disable=inconsistent-return-statements :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param parameters: Is either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.models.RecommendedSensitivityLabelUpdateList 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 parameters: Is either a RecommendedSensitivityLabelUpdateList type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.synapse.models.RecommendedSensitivityLabelUpdateList or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -156,19 +149,19 @@ async def update( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RecommendedSensitivityLabelUpdateList") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -177,15 +170,14 @@ async def update( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -195,8 +187,4 @@ async def update( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/recommendedSensitivityLabels" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_replication_links_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_replication_links_operations.py index 3a16479f7656..44d96b849f0d 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_replication_links_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_replication_links_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -19,21 +18,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._sql_pool_replication_links_operations import build_get_by_name_request, build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -72,7 +69,6 @@ def list( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ReplicationLink or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.ReplicationLink] :raises ~azure.core.exceptions.HttpResponseError: @@ -80,10 +76,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.ReplicationLinkListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -94,25 +90,22 @@ 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, workspace_name=workspace_name, sql_pool_name=sql_pool_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ReplicationLinkListResult", pipeline_response) @@ -122,10 +115,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -138,10 +132,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/replicationLinks" - } - @distributed_trace_async async def get_by_name( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, link_id: str, **kwargs: Any @@ -159,12 +149,11 @@ async def get_by_name( :type sql_pool_name: str :param link_id: The ID of the replication link. Required. :type link_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ReplicationLink or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ReplicationLink :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -175,25 +164,24 @@ async def get_by_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.ReplicationLink] = kwargs.pop("cls", None) - request = build_get_by_name_request( + _request = build_get_by_name_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, link_id=link_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_by_name.metadata["url"], 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -203,13 +191,9 @@ async def get_by_name( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ReplicationLink", pipeline_response) + deserialized = self._deserialize("ReplicationLink", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_by_name.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/replicationLinks/{linkId}" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_restore_points_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_restore_points_operations.py index e0a8fcfa3716..bb314b16cb31 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_restore_points_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_restore_points_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -16,12 +16,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 @@ -29,7 +30,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._sql_pool_restore_points_operations import ( build_create_request, build_delete_request, @@ -37,10 +37,10 @@ build_list_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -79,7 +79,6 @@ def list( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RestorePoint or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.RestorePoint] :raises ~azure.core.exceptions.HttpResponseError: @@ -87,10 +86,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.RestorePointListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -101,25 +100,22 @@ 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, workspace_name=workspace_name, sql_pool_name=sql_pool_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RestorePointListResult", pipeline_response) @@ -129,10 +125,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -145,19 +142,15 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints" - } - async def _create_initial( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: Union[_models.CreateSqlPoolRestorePointDefinition, IO], + parameters: Union[_models.CreateSqlPoolRestorePointDefinition, IO[bytes]], **kwargs: Any - ) -> Optional[_models.RestorePoint]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -168,19 +161,19 @@ async def _create_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.RestorePoint]] = 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(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "CreateSqlPoolRestorePointDefinition") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -189,38 +182,33 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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=False, **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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("RestorePoint", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("RestorePoint", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints" - } + return deserialized # type: ignore @overload async def begin_create( @@ -247,14 +235,6 @@ async def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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 RestorePoint or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.RestorePoint] @@ -267,7 +247,7 @@ async def begin_create( resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -282,18 +262,10 @@ async def begin_create( :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str :param parameters: The definition for creating the restore point of this Sql pool. 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 RestorePoint or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.RestorePoint] @@ -306,7 +278,7 @@ async def begin_create( resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: Union[_models.CreateSqlPoolRestorePointDefinition, IO], + parameters: Union[_models.CreateSqlPoolRestorePointDefinition, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.RestorePoint]: """Creates a restore point for a data warehouse. @@ -319,19 +291,8 @@ async def begin_create( :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str :param parameters: The definition for creating the restore point of this Sql pool. Is either a - model type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.models.CreateSqlPoolRestorePointDefinition 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. + CreateSqlPoolRestorePointDefinition type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.CreateSqlPoolRestorePointDefinition or IO[bytes] :return: An instance of AsyncLROPoller that returns either RestorePoint or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.RestorePoint] @@ -340,7 +301,7 @@ async def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RestorePoint] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -359,12 +320,13 @@ async def begin_create( 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("RestorePoint", pipeline_response) + deserialized = self._deserialize("RestorePoint", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -376,17 +338,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.RestorePoint].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints" - } + return AsyncLROPoller[_models.RestorePoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def get( @@ -403,12 +363,11 @@ async def get( :type sql_pool_name: str :param restore_point_name: The name of the restore point. Required. :type restore_point_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RestorePoint or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.RestorePoint :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -419,25 +378,24 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.RestorePoint] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, restore_point_name=restore_point_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -446,19 +404,15 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RestorePoint", pipeline_response) + deserialized = self._deserialize("RestorePoint", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints/{restorePointName}" - } + return deserialized # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements + async def delete( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, restore_point_name: str, **kwargs: Any ) -> None: """Deletes a restore point. @@ -472,12 +426,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :type sql_pool_name: str :param restore_point_name: The name of the restore point. Required. :type restore_point_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -488,25 +441,24 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, restore_point_name=restore_point_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -516,8 +468,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints/{restorePointName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_schemas_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_schemas_operations.py index b77f8c096f47..951f1f1bdafc 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_schemas_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_schemas_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -19,21 +18,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._sql_pool_schemas_operations import build_get_request, build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -80,7 +77,6 @@ def list( :param filter: An OData filter expression that filters elements in the collection. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SqlPoolSchema or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.SqlPoolSchema] :raises ~azure.core.exceptions.HttpResponseError: @@ -88,10 +84,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPoolSchemaListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -102,26 +98,23 @@ 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, workspace_name=workspace_name, sql_pool_name=sql_pool_name, subscription_id=self._config.subscription_id, filter=filter, 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("SqlPoolSchemaListResult", pipeline_response) @@ -131,10 +124,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -146,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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas" - } - @distributed_trace_async async def get( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, schema_name: str, **kwargs: Any @@ -165,12 +155,11 @@ async def get( :type sql_pool_name: str :param schema_name: The name of the schema. Required. :type schema_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SqlPoolSchema or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolSchema :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -181,25 +170,24 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPoolSchema] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, schema_name=schema_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -208,13 +196,9 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("SqlPoolSchema", pipeline_response) + deserialized = self._deserialize("SqlPoolSchema", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_security_alert_policies_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_security_alert_policies_operations.py index 4e766eebfe19..c90b3375c617 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_security_alert_policies_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_security_alert_policies_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload @@ -19,25 +19,23 @@ 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._sql_pool_security_alert_policies_operations import ( build_create_or_update_request, build_get_request, build_list_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -76,7 +74,6 @@ def list( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SqlPoolSecurityAlertPolicy or the result of cls(response) :rtype: @@ -86,10 +83,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.ListSqlPoolSecurityAlertPolicies] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -100,25 +97,22 @@ 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, workspace_name=workspace_name, sql_pool_name=sql_pool_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ListSqlPoolSecurityAlertPolicies", pipeline_response) @@ -128,10 +122,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -143,10 +138,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/securityAlertPolicies" - } - @distributed_trace_async async def get( self, @@ -169,12 +160,11 @@ async def get( :type sql_pool_name: str :param security_alert_policy_name: The name of the security alert policy. "default" Required. :type security_alert_policy_name: str or ~azure.mgmt.synapse.models.SecurityAlertPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: SqlPoolSecurityAlertPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolSecurityAlertPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -185,25 +175,24 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPoolSecurityAlertPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, security_alert_policy_name=security_alert_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -212,16 +201,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("SqlPoolSecurityAlertPolicy", pipeline_response) + deserialized = self._deserialize("SqlPoolSecurityAlertPolicy", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/securityAlertPolicies/{securityAlertPolicyName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -253,7 +238,6 @@ async def 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 :return: SqlPoolSecurityAlertPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolSecurityAlertPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -266,7 +250,7 @@ async def create_or_update( workspace_name: str, sql_pool_name: str, security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -285,11 +269,10 @@ async def create_or_update( :param security_alert_policy_name: The name of the security alert policy. "default" Required. :type security_alert_policy_name: str or ~azure.mgmt.synapse.models.SecurityAlertPolicyName :param parameters: The Sql pool security alert policy. 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: SqlPoolSecurityAlertPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolSecurityAlertPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -302,7 +285,7 @@ async def create_or_update( workspace_name: str, sql_pool_name: str, security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - parameters: Union[_models.SqlPoolSecurityAlertPolicy, IO], + parameters: Union[_models.SqlPoolSecurityAlertPolicy, IO[bytes]], **kwargs: Any ) -> _models.SqlPoolSecurityAlertPolicy: """Create or update a Sql pool's security alert policy. @@ -318,18 +301,14 @@ async def create_or_update( :type sql_pool_name: str :param security_alert_policy_name: The name of the security alert policy. "default" Required. :type security_alert_policy_name: str or ~azure.mgmt.synapse.models.SecurityAlertPolicyName - :param parameters: The Sql pool security alert policy. Is either a model type or a IO type. - Required. - :type parameters: ~azure.mgmt.synapse.models.SqlPoolSecurityAlertPolicy 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 parameters: The Sql pool security alert policy. Is either a SqlPoolSecurityAlertPolicy + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.SqlPoolSecurityAlertPolicy or IO[bytes] :return: SqlPoolSecurityAlertPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolSecurityAlertPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -340,19 +319,19 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SqlPoolSecurityAlertPolicy] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "SqlPoolSecurityAlertPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -362,15 +341,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -379,17 +357,9 @@ async def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("SqlPoolSecurityAlertPolicy", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SqlPoolSecurityAlertPolicy", pipeline_response) + deserialized = self._deserialize("SqlPoolSecurityAlertPolicy", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/securityAlertPolicies/{securityAlertPolicyName}" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_sensitivity_labels_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_sensitivity_labels_operations.py index ac023a785ff3..29a0c798fcb3 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_sensitivity_labels_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_sensitivity_labels_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,15 +19,13 @@ 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._sql_pool_sensitivity_labels_operations import ( build_create_or_update_request, build_delete_request, @@ -39,10 +37,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -89,7 +87,6 @@ def list_current( :param filter: An OData filter expression that filters elements in the collection. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SensitivityLabel or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.SensitivityLabel] :raises ~azure.core.exceptions.HttpResponseError: @@ -97,10 +94,10 @@ def list_current( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SensitivityLabelListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -111,26 +108,23 @@ def list_current( def prepare_request(next_link=None): if not next_link: - request = build_list_current_request( + _request = build_list_current_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list_current.metadata["url"], 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("SensitivityLabelListResult", pipeline_response) @@ -140,10 +134,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -156,12 +151,8 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_current.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/currentSensitivityLabels" - } - @overload - async def update( # pylint: disable=inconsistent-return-statements + async def update( self, resource_group_name: str, workspace_name: str, @@ -185,19 +176,18 @@ async def update( # pylint: disable=inconsistent-return-statements :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. 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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def update( # pylint: disable=inconsistent-return-statements + async def update( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -212,23 +202,22 @@ async def update( # pylint: disable=inconsistent-return-statements :param sql_pool_name: SQL pool name. Required. :type sql_pool_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 :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def update( # pylint: disable=inconsistent-return-statements + async def update( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: Union[_models.SensitivityLabelUpdateList, IO], + parameters: Union[_models.SensitivityLabelUpdateList, IO[bytes]], **kwargs: Any ) -> None: """Update sensitivity labels of a given SQL Pool using an operations batch. @@ -240,17 +229,13 @@ async def update( # pylint: disable=inconsistent-return-statements :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param parameters: Is either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.models.SensitivityLabelUpdateList 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 parameters: Is either a SensitivityLabelUpdateList type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.SensitivityLabelUpdateList or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -261,19 +246,19 @@ async def update( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "SensitivityLabelUpdateList") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -282,15 +267,14 @@ async def update( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -300,11 +284,7 @@ async def update( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/currentSensitivityLabels" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list_recommended( @@ -337,7 +317,6 @@ def list_recommended( :param filter: An OData filter expression that filters elements in the collection. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SensitivityLabel or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.SensitivityLabel] :raises ~azure.core.exceptions.HttpResponseError: @@ -345,10 +324,10 @@ def list_recommended( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SensitivityLabelListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -359,7 +338,7 @@ def list_recommended( def prepare_request(next_link=None): if not next_link: - request = build_list_recommended_request( + _request = build_list_recommended_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -368,19 +347,16 @@ def prepare_request(next_link=None): skip_token=skip_token, filter=filter, api_version=api_version, - template_url=self.list_recommended.metadata["url"], 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("SensitivityLabelListResult", pipeline_response) @@ -390,10 +366,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -405,10 +382,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_recommended.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/recommendedSensitivityLabels" - } - @overload async def create_or_update( self, @@ -443,10 +416,6 @@ async def 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 sensitivity_label_source: The source of the sensitivity label. Default value is - "current". Note that overriding this default value may result in unsupported behavior. - :paramtype sensitivity_label_source: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SensitivityLabel or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SensitivityLabel :raises ~azure.core.exceptions.HttpResponseError: @@ -461,7 +430,7 @@ async def create_or_update( schema_name: str, table_name: str, column_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -482,14 +451,10 @@ async def create_or_update( :param column_name: The name of the column. Required. :type column_name: str :param parameters: The column sensitivity label resource. 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 sensitivity_label_source: The source of the sensitivity label. Default value is - "current". Note that overriding this default value may result in unsupported behavior. - :paramtype sensitivity_label_source: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SensitivityLabel or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SensitivityLabel :raises ~azure.core.exceptions.HttpResponseError: @@ -504,7 +469,7 @@ async def create_or_update( schema_name: str, table_name: str, column_name: str, - parameters: Union[_models.SensitivityLabel, IO], + parameters: Union[_models.SensitivityLabel, IO[bytes]], **kwargs: Any ) -> _models.SensitivityLabel: """Creates or updates the sensitivity label of a given column in a Sql pool. @@ -522,21 +487,14 @@ async def create_or_update( :type table_name: str :param column_name: The name of the column. Required. :type column_name: str - :param parameters: The column sensitivity label resource. Is either a model type or a IO type. - Required. - :type parameters: ~azure.mgmt.synapse.models.SensitivityLabel or IO - :keyword sensitivity_label_source: The source of the sensitivity label. Default value is - "current". Note that overriding this default value may result in unsupported behavior. - :paramtype sensitivity_label_source: 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 + :param parameters: The column sensitivity label resource. Is either a SensitivityLabel type or + a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.SensitivityLabel or IO[bytes] :return: SensitivityLabel or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SensitivityLabel :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -547,7 +505,7 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SensitivityLabel] = kwargs.pop("cls", None) @@ -555,12 +513,12 @@ async def create_or_update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "SensitivityLabel") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -573,15 +531,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -590,23 +547,15 @@ async def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("SensitivityLabel", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SensitivityLabel", pipeline_response) + deserialized = self._deserialize("SensitivityLabel", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}" - } - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements + async def delete( self, resource_group_name: str, workspace_name: str, @@ -631,15 +580,11 @@ async def delete( # pylint: disable=inconsistent-return-statements :type table_name: str :param column_name: The name of the column. Required. :type column_name: str - :keyword sensitivity_label_source: The source of the sensitivity label. Default value is - "current". Note that overriding this default value may result in unsupported behavior. - :paramtype sensitivity_label_source: 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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -650,11 +595,11 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -664,15 +609,14 @@ async def delete( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, sensitivity_label_source=sensitivity_label_source, - template_url=self.delete.metadata["url"], 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -682,11 +626,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get( @@ -718,12 +658,11 @@ async def get( :param sensitivity_label_source: The source of the sensitivity label. Known values are: "current" and "recommended". Required. :type sensitivity_label_source: str or ~azure.mgmt.synapse.models.SensitivityLabelSource - :keyword callable cls: A custom type or function that will be passed the direct response :return: SensitivityLabel or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SensitivityLabel :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -734,10 +673,10 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SensitivityLabel] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -747,15 +686,14 @@ async def get( sensitivity_label_source=sensitivity_label_source, 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -764,19 +702,15 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("SensitivityLabel", pipeline_response) + deserialized = self._deserialize("SensitivityLabel", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}" - } + return deserialized # type: ignore @distributed_trace_async - async def enable_recommendation( # pylint: disable=inconsistent-return-statements + async def enable_recommendation( self, resource_group_name: str, workspace_name: str, @@ -802,15 +736,11 @@ async def enable_recommendation( # pylint: disable=inconsistent-return-statemen :type table_name: str :param column_name: The name of the column. Required. :type column_name: str - :keyword sensitivity_label_source: The source of the sensitivity label. Default value is - "recommended". Note that overriding this default value may result in unsupported behavior. - :paramtype sensitivity_label_source: 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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -821,11 +751,11 @@ async def enable_recommendation( # pylint: disable=inconsistent-return-statemen _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") cls: ClsType[None] = kwargs.pop("cls", None) - request = build_enable_recommendation_request( + _request = build_enable_recommendation_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -835,15 +765,14 @@ async def enable_recommendation( # pylint: disable=inconsistent-return-statemen subscription_id=self._config.subscription_id, api_version=api_version, sensitivity_label_source=sensitivity_label_source, - template_url=self.enable_recommendation.metadata["url"], 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -853,14 +782,10 @@ async def enable_recommendation( # pylint: disable=inconsistent-return-statemen raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - enable_recommendation.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/enable" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async - async def disable_recommendation( # pylint: disable=inconsistent-return-statements + async def disable_recommendation( self, resource_group_name: str, workspace_name: str, @@ -885,15 +810,11 @@ async def disable_recommendation( # pylint: disable=inconsistent-return-stateme :type table_name: str :param column_name: The name of the column. Required. :type column_name: str - :keyword sensitivity_label_source: The source of the sensitivity label. Default value is - "recommended". Note that overriding this default value may result in unsupported behavior. - :paramtype sensitivity_label_source: 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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -904,11 +825,11 @@ async def disable_recommendation( # pylint: disable=inconsistent-return-stateme _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") cls: ClsType[None] = kwargs.pop("cls", None) - request = build_disable_recommendation_request( + _request = build_disable_recommendation_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -918,15 +839,14 @@ async def disable_recommendation( # pylint: disable=inconsistent-return-stateme subscription_id=self._config.subscription_id, api_version=api_version, sensitivity_label_source=sensitivity_label_source, - template_url=self.disable_recommendation.metadata["url"], 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -936,8 +856,4 @@ async def disable_recommendation( # pylint: disable=inconsistent-return-stateme raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - disable_recommendation.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/disable" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_table_columns_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_table_columns_operations.py index aa8808c1ea26..c93178ef6f5a 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_table_columns_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_table_columns_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -19,20 +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 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._sql_pool_table_columns_operations import build_list_by_table_name_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -85,7 +82,6 @@ def list_by_table_name( :param filter: An OData filter expression that filters elements in the collection. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SqlPoolColumn or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.SqlPoolColumn] :raises ~azure.core.exceptions.HttpResponseError: @@ -93,10 +89,10 @@ def list_by_table_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPoolColumnListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -107,7 +103,7 @@ def list_by_table_name( def prepare_request(next_link=None): if not next_link: - request = build_list_by_table_name_request( + _request = build_list_by_table_name_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -116,19 +112,16 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list_by_table_name.metadata["url"], 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("SqlPoolColumnListResult", pipeline_response) @@ -138,10 +131,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -152,7 +146,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_table_name.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_tables_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_tables_operations.py index 6ae7a88876e5..3b2439a4b6a7 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_tables_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_tables_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -19,21 +18,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._sql_pool_tables_operations import build_get_request, build_list_by_schema_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -83,7 +80,6 @@ def list_by_schema( :param filter: An OData filter expression that filters elements in the collection. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SqlPoolTable or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.SqlPoolTable] :raises ~azure.core.exceptions.HttpResponseError: @@ -91,10 +87,10 @@ def list_by_schema( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPoolTableListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -105,7 +101,7 @@ def list_by_schema( def prepare_request(next_link=None): if not next_link: - request = build_list_by_schema_request( + _request = build_list_by_schema_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -113,19 +109,16 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list_by_schema.metadata["url"], 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("SqlPoolTableListResult", pipeline_response) @@ -135,10 +128,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -150,10 +144,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_schema.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables" - } - @distributed_trace_async async def get( self, @@ -177,12 +167,11 @@ async def get( :type schema_name: str :param table_name: The name of the table. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SqlPoolTable or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolTable :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -193,10 +182,10 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPoolTable] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -204,15 +193,14 @@ async def get( table_name=table_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -221,13 +209,9 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("SqlPoolTable", pipeline_response) + deserialized = self._deserialize("SqlPoolTable", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_transparent_data_encryptions_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_transparent_data_encryptions_operations.py index 9afc9e85db14..1e94ae5e516b 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_transparent_data_encryptions_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_transparent_data_encryptions_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload @@ -19,30 +19,28 @@ 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._sql_pool_transparent_data_encryptions_operations import ( build_create_or_update_request, build_get_request, build_list_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SqlPoolTransparentDataEncryptionsOperations: +class SqlPoolTransparentDataEncryptionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -85,12 +83,11 @@ async def get( configuration. "current" Required. :type transparent_data_encryption_name: str or ~azure.mgmt.synapse.models.TransparentDataEncryptionName - :keyword callable cls: A custom type or function that will be passed the direct response :return: TransparentDataEncryption or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.TransparentDataEncryption :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -101,25 +98,24 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.TransparentDataEncryption] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, transparent_data_encryption_name=transparent_data_encryption_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -129,16 +125,12 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("TransparentDataEncryption", pipeline_response) + deserialized = self._deserialize("TransparentDataEncryption", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/transparentDataEncryption/{transparentDataEncryptionName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -173,7 +165,6 @@ async def 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 :return: TransparentDataEncryption or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.TransparentDataEncryption :raises ~azure.core.exceptions.HttpResponseError: @@ -186,7 +177,7 @@ async def create_or_update( workspace_name: str, sql_pool_name: str, transparent_data_encryption_name: Union[str, _models.TransparentDataEncryptionName], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -208,11 +199,10 @@ async def create_or_update( ~azure.mgmt.synapse.models.TransparentDataEncryptionName :param parameters: The required parameters for creating or updating transparent data encryption. 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: TransparentDataEncryption or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.TransparentDataEncryption :raises ~azure.core.exceptions.HttpResponseError: @@ -225,7 +215,7 @@ async def create_or_update( workspace_name: str, sql_pool_name: str, transparent_data_encryption_name: Union[str, _models.TransparentDataEncryptionName], - parameters: Union[_models.TransparentDataEncryption, IO], + parameters: Union[_models.TransparentDataEncryption, IO[bytes]], **kwargs: Any ) -> _models.TransparentDataEncryption: """Creates or updates a Sql pool's transparent data encryption configuration. @@ -244,17 +234,13 @@ async def create_or_update( :type transparent_data_encryption_name: str or ~azure.mgmt.synapse.models.TransparentDataEncryptionName :param parameters: The required parameters for creating or updating transparent data - encryption. Is either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.models.TransparentDataEncryption 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 + encryption. Is either a TransparentDataEncryption type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.TransparentDataEncryption or IO[bytes] :return: TransparentDataEncryption or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.TransparentDataEncryption :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -265,19 +251,19 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TransparentDataEncryption] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "TransparentDataEncryption") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -287,15 +273,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -305,21 +290,13 @@ async def create_or_update( 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("TransparentDataEncryption", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("TransparentDataEncryption", pipeline_response) + deserialized = self._deserialize("TransparentDataEncryption", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/transparentDataEncryption/{transparentDataEncryptionName}" - } - @distributed_trace def list( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any @@ -335,7 +312,6 @@ def list( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TransparentDataEncryption or the result of cls(response) :rtype: @@ -345,10 +321,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.TransparentDataEncryptionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -359,25 +335,22 @@ 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, workspace_name=workspace_name, sql_pool_name=sql_pool_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("TransparentDataEncryptionListResult", pipeline_response) @@ -387,10 +360,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -401,7 +375,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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/transparentDataEncryption" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_usages_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_usages_operations.py index e64657bb936d..ba5ebeb16976 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_usages_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_usages_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -19,20 +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 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._sql_pool_usages_operations import build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -71,7 +68,6 @@ def list( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SqlPoolUsage or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.SqlPoolUsage] :raises ~azure.core.exceptions.HttpResponseError: @@ -79,10 +75,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPoolUsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -93,25 +89,22 @@ 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, workspace_name=workspace_name, sql_pool_name=sql_pool_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("SqlPoolUsageListResult", pipeline_response) @@ -121,10 +114,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -136,7 +130,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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/usages" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_vulnerability_assessment_rule_baselines_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_vulnerability_assessment_rule_baselines_operations.py index 900c3b8e80aa..c50e8614eaea 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_vulnerability_assessment_rule_baselines_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_vulnerability_assessment_rule_baselines_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload @@ -18,29 +18,27 @@ 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._sql_pool_vulnerability_assessment_rule_baselines_operations import ( build_create_or_update_request, build_delete_request, build_get_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SqlPoolVulnerabilityAssessmentRuleBaselinesOperations: +class SqlPoolVulnerabilityAssessmentRuleBaselinesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -98,7 +96,6 @@ async def 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 :return: SqlPoolVulnerabilityAssessmentRuleBaseline or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessmentRuleBaseline :raises ~azure.core.exceptions.HttpResponseError: @@ -113,7 +110,7 @@ async def create_or_update( vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], rule_id: str, baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -139,11 +136,10 @@ async def create_or_update( :type baseline_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentPolicyBaselineName :param parameters: The requested rule baseline resource. 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: SqlPoolVulnerabilityAssessmentRuleBaseline or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessmentRuleBaseline :raises ~azure.core.exceptions.HttpResponseError: @@ -158,7 +154,7 @@ async def create_or_update( vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], rule_id: str, baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], - parameters: Union[_models.SqlPoolVulnerabilityAssessmentRuleBaseline, IO], + parameters: Union[_models.SqlPoolVulnerabilityAssessmentRuleBaseline, IO[bytes]], **kwargs: Any ) -> _models.SqlPoolVulnerabilityAssessmentRuleBaseline: """Creates or updates a Sql pool's vulnerability assessment rule baseline. @@ -181,18 +177,15 @@ async def create_or_update( "master" and "default". Required. :type baseline_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentPolicyBaselineName - :param parameters: The requested rule baseline resource. Is either a model type or a IO type. - Required. - :type parameters: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessmentRuleBaseline 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 parameters: The requested rule baseline resource. Is either a + SqlPoolVulnerabilityAssessmentRuleBaseline type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessmentRuleBaseline or + IO[bytes] :return: SqlPoolVulnerabilityAssessmentRuleBaseline or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessmentRuleBaseline :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -203,19 +196,19 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SqlPoolVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "SqlPoolVulnerabilityAssessmentRuleBaseline") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -227,15 +220,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -244,19 +236,15 @@ async def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("SqlPoolVulnerabilityAssessmentRuleBaseline", pipeline_response) + deserialized = self._deserialize("SqlPoolVulnerabilityAssessmentRuleBaseline", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}" - } + return deserialized # type: ignore @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements + async def delete( self, resource_group_name: str, workspace_name: str, @@ -286,12 +274,11 @@ async def delete( # pylint: disable=inconsistent-return-statements "master" and "default". Required. :type baseline_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentPolicyBaselineName - :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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -302,10 +289,10 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -314,15 +301,14 @@ async def delete( # pylint: disable=inconsistent-return-statements baseline_name=baseline_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -332,11 +318,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get( @@ -369,12 +351,11 @@ async def get( and "default". Required. :type baseline_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentPolicyBaselineName - :keyword callable cls: A custom type or function that will be passed the direct response :return: SqlPoolVulnerabilityAssessmentRuleBaseline or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessmentRuleBaseline :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -385,10 +366,10 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPoolVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -397,15 +378,14 @@ async def get( baseline_name=baseline_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -414,13 +394,9 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("SqlPoolVulnerabilityAssessmentRuleBaseline", pipeline_response) + deserialized = self._deserialize("SqlPoolVulnerabilityAssessmentRuleBaseline", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_vulnerability_assessment_scans_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_vulnerability_assessment_scans_operations.py index 55acd04ed3e8..3822f1627d75 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_vulnerability_assessment_scans_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_vulnerability_assessment_scans_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -16,12 +15,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 @@ -29,7 +29,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._sql_pool_vulnerability_assessment_scans_operations import ( build_export_request, build_get_request, @@ -37,15 +36,15 @@ build_list_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SqlPoolVulnerabilityAssessmentScansOperations: +class SqlPoolVulnerabilityAssessmentScansOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -88,7 +87,6 @@ def list( Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either VulnerabilityAssessmentScanRecord or the result of cls(response) :rtype: @@ -98,10 +96,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.VulnerabilityAssessmentScanRecordListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -112,26 +110,23 @@ 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, workspace_name=workspace_name, sql_pool_name=sql_pool_name, vulnerability_assessment_name=vulnerability_assessment_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("VulnerabilityAssessmentScanRecordListResult", pipeline_response) @@ -141,10 +136,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -156,11 +152,7 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans" - } - - async def _initiate_scan_initial( # pylint: disable=inconsistent-return-statements + async def _initiate_scan_initial( self, resource_group_name: str, workspace_name: str, @@ -168,8 +160,8 @@ async def _initiate_scan_initial( # pylint: disable=inconsistent-return-stateme vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], scan_id: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -180,10 +172,10 @@ async def _initiate_scan_initial( # pylint: disable=inconsistent-return-stateme _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_initiate_scan_request( + _request = build_initiate_scan_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -191,29 +183,33 @@ async def _initiate_scan_initial( # pylint: disable=inconsistent-return-stateme scan_id=scan_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._initiate_scan_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _initiate_scan_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan" - } + return deserialized # type: ignore @distributed_trace_async async def begin_initiate_scan( @@ -240,14 +236,6 @@ async def begin_initiate_scan( ~azure.mgmt.synapse.models.VulnerabilityAssessmentName :param scan_id: The vulnerability assessment scan Id of the scan to retrieve. Required. :type scan_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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: @@ -255,13 +243,13 @@ async def begin_initiate_scan( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) 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._initiate_scan_initial( # type: ignore + raw_result = await self._initiate_scan_initial( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -273,11 +261,12 @@ async def begin_initiate_scan( 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)) @@ -286,17 +275,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_initiate_scan.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async async def export( @@ -323,12 +308,11 @@ async def export( ~azure.mgmt.synapse.models.VulnerabilityAssessmentName :param scan_id: The vulnerability assessment scan Id of the scan to retrieve. Required. :type scan_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SqlPoolVulnerabilityAssessmentScansExport or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessmentScansExport :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -339,10 +323,10 @@ async def export( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPoolVulnerabilityAssessmentScansExport] = kwargs.pop("cls", None) - request = build_export_request( + _request = build_export_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -350,15 +334,14 @@ async def export( scan_id=scan_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export.metadata["url"], 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -367,21 +350,13 @@ async def export( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("SqlPoolVulnerabilityAssessmentScansExport", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SqlPoolVulnerabilityAssessmentScansExport", pipeline_response) + deserialized = self._deserialize("SqlPoolVulnerabilityAssessmentScansExport", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - export.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/export" - } - @distributed_trace_async async def get( self, @@ -407,12 +382,11 @@ async def get( ~azure.mgmt.synapse.models.VulnerabilityAssessmentName :param scan_id: The vulnerability assessment scan Id of the scan to retrieve. Required. :type scan_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: VulnerabilityAssessmentScanRecord or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.VulnerabilityAssessmentScanRecord :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -423,10 +397,10 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.VulnerabilityAssessmentScanRecord] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -434,15 +408,14 @@ async def get( scan_id=scan_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -451,13 +424,9 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("VulnerabilityAssessmentScanRecord", pipeline_response) + deserialized = self._deserialize("VulnerabilityAssessmentScanRecord", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_vulnerability_assessments_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_vulnerability_assessments_operations.py index 99cc2084ad86..49e5587b30f4 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_vulnerability_assessments_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_vulnerability_assessments_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload @@ -19,15 +19,13 @@ 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._sql_pool_vulnerability_assessments_operations import ( build_create_or_update_request, build_delete_request, @@ -35,15 +33,15 @@ build_list_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SqlPoolVulnerabilityAssessmentsOperations: +class SqlPoolVulnerabilityAssessmentsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -77,7 +75,6 @@ def list( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SqlPoolVulnerabilityAssessment or the result of cls(response) :rtype: @@ -87,10 +84,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPoolVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -101,25 +98,22 @@ 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, workspace_name=workspace_name, sql_pool_name=sql_pool_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("SqlPoolVulnerabilityAssessmentListResult", pipeline_response) @@ -129,10 +123,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -144,10 +139,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments" - } - @distributed_trace_async async def get( self, @@ -172,12 +163,11 @@ async def get( Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :keyword callable cls: A custom type or function that will be passed the direct response :return: SqlPoolVulnerabilityAssessment or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -188,25 +178,24 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPoolVulnerabilityAssessment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, vulnerability_assessment_name=vulnerability_assessment_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -215,16 +204,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("SqlPoolVulnerabilityAssessment", pipeline_response) + deserialized = self._deserialize("SqlPoolVulnerabilityAssessment", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -258,7 +243,6 @@ async def 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 :return: SqlPoolVulnerabilityAssessment or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessment :raises ~azure.core.exceptions.HttpResponseError: @@ -271,7 +255,7 @@ async def create_or_update( workspace_name: str, sql_pool_name: str, vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -292,11 +276,10 @@ async def create_or_update( :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName :param parameters: The requested resource. 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: SqlPoolVulnerabilityAssessment or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessment :raises ~azure.core.exceptions.HttpResponseError: @@ -309,7 +292,7 @@ async def create_or_update( workspace_name: str, sql_pool_name: str, vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - parameters: Union[_models.SqlPoolVulnerabilityAssessment, IO], + parameters: Union[_models.SqlPoolVulnerabilityAssessment, IO[bytes]], **kwargs: Any ) -> _models.SqlPoolVulnerabilityAssessment: """Creates or updates the Sql pool vulnerability assessment. @@ -327,17 +310,14 @@ async def create_or_update( Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :param parameters: The requested resource. Is either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessment 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 parameters: The requested resource. Is either a SqlPoolVulnerabilityAssessment type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessment or IO[bytes] :return: SqlPoolVulnerabilityAssessment or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -348,19 +328,19 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SqlPoolVulnerabilityAssessment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "SqlPoolVulnerabilityAssessment") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -370,15 +350,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -387,23 +366,15 @@ async def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("SqlPoolVulnerabilityAssessment", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SqlPoolVulnerabilityAssessment", pipeline_response) + deserialized = self._deserialize("SqlPoolVulnerabilityAssessment", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}" - } - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements + async def delete( self, resource_group_name: str, workspace_name: str, @@ -426,12 +397,11 @@ async def delete( # pylint: disable=inconsistent-return-statements Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -442,25 +412,24 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, vulnerability_assessment_name=vulnerability_assessment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -470,8 +439,4 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_workload_classifier_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_workload_classifier_operations.py index cb477fb3b338..6553a4727204 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_workload_classifier_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_workload_classifier_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -16,12 +16,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 @@ -29,7 +30,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._sql_pool_workload_classifier_operations import ( build_create_or_update_request, build_delete_request, @@ -37,10 +37,10 @@ build_list_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -89,12 +89,11 @@ async def get( :type workload_group_name: str :param workload_classifier_name: The name of the workload classifier. Required. :type workload_classifier_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: WorkloadClassifier or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.WorkloadClassifier :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -105,10 +104,10 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.WorkloadClassifier] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -116,15 +115,14 @@ async def get( workload_classifier_name=workload_classifier_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -133,16 +131,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("WorkloadClassifier", pipeline_response) + deserialized = self._deserialize("WorkloadClassifier", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, @@ -151,10 +145,10 @@ async def _create_or_update_initial( sql_pool_name: str, workload_group_name: str, workload_classifier_name: str, - parameters: Union[_models.WorkloadClassifier, IO], + parameters: Union[_models.WorkloadClassifier, IO[bytes]], **kwargs: Any - ) -> Optional[_models.WorkloadClassifier]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -165,19 +159,19 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.WorkloadClassifier]] = 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(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "WorkloadClassifier") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -188,38 +182,33 @@ 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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("WorkloadClassifier", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("WorkloadClassifier", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}" - } + return deserialized # type: ignore @overload async def begin_create_or_update( @@ -254,14 +243,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 WorkloadClassifier or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.WorkloadClassifier] @@ -276,7 +257,7 @@ async def begin_create_or_update( sql_pool_name: str, workload_group_name: str, workload_classifier_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -297,18 +278,10 @@ async def begin_create_or_update( :param workload_classifier_name: The name of the workload classifier. Required. :type workload_classifier_name: str :param parameters: The properties of the workload classifier. 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 WorkloadClassifier or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.WorkloadClassifier] @@ -323,7 +296,7 @@ async def begin_create_or_update( sql_pool_name: str, workload_group_name: str, workload_classifier_name: str, - parameters: Union[_models.WorkloadClassifier, IO], + parameters: Union[_models.WorkloadClassifier, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.WorkloadClassifier]: """Create Or Update workload classifier. @@ -341,20 +314,9 @@ async def begin_create_or_update( :type workload_group_name: str :param workload_classifier_name: The name of the workload classifier. Required. :type workload_classifier_name: str - :param parameters: The properties of the workload classifier. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.synapse.models.WorkloadClassifier 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: The properties of the workload classifier. Is either a WorkloadClassifier + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.WorkloadClassifier or IO[bytes] :return: An instance of AsyncLROPoller that returns either WorkloadClassifier or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.WorkloadClassifier] @@ -363,7 +325,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WorkloadClassifier] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -384,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("WorkloadClassifier", pipeline_response) + deserialized = self._deserialize("WorkloadClassifier", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -399,19 +362,17 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.WorkloadClassifier].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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}" - } + return AsyncLROPoller[_models.WorkloadClassifier]( + 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, workspace_name: str, @@ -419,8 +380,8 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements workload_group_name: str, workload_classifier_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -431,10 +392,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -442,29 +403,33 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements workload_classifier_name=workload_classifier_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -491,14 +456,6 @@ async def begin_delete( :type workload_group_name: str :param workload_classifier_name: The name of the workload classifier. Required. :type workload_classifier_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: @@ -506,13 +463,13 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) 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._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -524,11 +481,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)) @@ -537,17 +495,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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def list( @@ -566,7 +520,6 @@ def list( :type sql_pool_name: str :param workload_group_name: The name of the workload group. Required. :type workload_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 WorkloadClassifier or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.WorkloadClassifier] :raises ~azure.core.exceptions.HttpResponseError: @@ -574,10 +527,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.WorkloadClassifierListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -588,26 +541,23 @@ 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, workspace_name=workspace_name, sql_pool_name=sql_pool_name, workload_group_name=workload_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("WorkloadClassifierListResult", pipeline_response) @@ -617,10 +567,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -631,7 +582,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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_workload_group_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_workload_group_operations.py index 0f6ce83fc812..3bdaf5bb3cb1 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_workload_group_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pool_workload_group_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -16,12 +16,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 @@ -29,7 +30,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._sql_pool_workload_group_operations import ( build_create_or_update_request, build_delete_request, @@ -37,10 +37,10 @@ build_list_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -81,12 +81,11 @@ async def get( :type sql_pool_name: str :param workload_group_name: The name of the workload group. Required. :type workload_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: WorkloadGroup or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.WorkloadGroup :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,25 +96,24 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.WorkloadGroup] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, workload_group_name=workload_group_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -124,16 +122,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("WorkloadGroup", pipeline_response) + deserialized = self._deserialize("WorkloadGroup", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, @@ -141,10 +135,10 @@ async def _create_or_update_initial( workspace_name: str, sql_pool_name: str, workload_group_name: str, - parameters: Union[_models.WorkloadGroup, IO], + parameters: Union[_models.WorkloadGroup, IO[bytes]], **kwargs: Any - ) -> Optional[_models.WorkloadGroup]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -155,19 +149,19 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.WorkloadGroup]] = 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(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "WorkloadGroup") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -177,38 +171,33 @@ 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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("WorkloadGroup", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("WorkloadGroup", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}" - } + return deserialized # type: ignore @overload async def begin_create_or_update( @@ -240,14 +229,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 WorkloadGroup or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.WorkloadGroup] @@ -261,7 +242,7 @@ async def begin_create_or_update( workspace_name: str, sql_pool_name: str, workload_group_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -280,18 +261,10 @@ async def begin_create_or_update( :param workload_group_name: The name of the workload group. Required. :type workload_group_name: str :param parameters: The requested workload group state. 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 WorkloadGroup or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.WorkloadGroup] @@ -305,7 +278,7 @@ async def begin_create_or_update( workspace_name: str, sql_pool_name: str, workload_group_name: str, - parameters: Union[_models.WorkloadGroup, IO], + parameters: Union[_models.WorkloadGroup, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.WorkloadGroup]: """Create Or Update workload group. @@ -321,20 +294,9 @@ async def begin_create_or_update( :type sql_pool_name: str :param workload_group_name: The name of the workload group. Required. :type workload_group_name: str - :param parameters: The requested workload group state. Is either a model type or a IO type. - Required. - :type parameters: ~azure.mgmt.synapse.models.WorkloadGroup 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: The requested workload group state. Is either a WorkloadGroup type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.WorkloadGroup or IO[bytes] :return: An instance of AsyncLROPoller that returns either WorkloadGroup or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.WorkloadGroup] @@ -343,7 +305,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WorkloadGroup] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -363,12 +325,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("WorkloadGroup", pipeline_response) + deserialized = self._deserialize("WorkloadGroup", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -378,22 +341,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.WorkloadGroup].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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}" - } + return AsyncLROPoller[_models.WorkloadGroup]( + 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, workspace_name: str, sql_pool_name: str, workload_group_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -404,39 +365,43 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, workload_group_name=workload_group_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -455,14 +420,6 @@ async def begin_delete( :type sql_pool_name: str :param workload_group_name: The name of the workload group. Required. :type workload_group_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: @@ -470,13 +427,13 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) 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._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -487,11 +444,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)) @@ -500,17 +458,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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def list( @@ -527,7 +481,6 @@ def list( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WorkloadGroup or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.WorkloadGroup] :raises ~azure.core.exceptions.HttpResponseError: @@ -535,10 +488,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.WorkloadGroupListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -549,25 +502,22 @@ 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, workspace_name=workspace_name, sql_pool_name=sql_pool_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("WorkloadGroupListResult", pipeline_response) @@ -577,10 +527,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -591,7 +542,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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pools_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pools_operations.py index eabd52d0fc9f..3b48e2fafd74 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pools_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_sql_pools_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -16,12 +16,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 @@ -29,22 +30,20 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._sql_pools_operations import ( build_create_request, build_delete_request, build_get_request, build_list_by_workspace_request, build_pause_request, - build_rename_request, build_resume_request, build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -83,12 +82,11 @@ async def get( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SqlPool or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -99,24 +97,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPool] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -126,26 +123,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("SqlPool", pipeline_response) + deserialized = self._deserialize("SqlPool", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}" - } + return deserialized # type: ignore async def _update_initial( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, - sql_pool_info: Union[_models.SqlPoolPatchInfo, IO], + sql_pool_info: Union[_models.SqlPoolPatchInfo, IO[bytes]], **kwargs: Any - ) -> Optional[_models.SqlPool]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -156,19 +149,19 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.SqlPool]] = 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(sql_pool_info, (IO, bytes)): + if isinstance(sql_pool_info, (IOBase, bytes)): _content = sql_pool_info else: _json = self._serialize.body(sql_pool_info, "SqlPoolPatchInfo") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -177,36 +170,34 @@ 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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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 - if response.status_code == 200: - deserialized = self._deserialize("SqlPool", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}" - } + return deserialized # type: ignore @overload async def begin_update( @@ -235,14 +226,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 SqlPool or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.SqlPool] @@ -255,7 +238,7 @@ async def begin_update( resource_group_name: str, workspace_name: str, sql_pool_name: str, - sql_pool_info: IO, + sql_pool_info: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -272,18 +255,10 @@ async def begin_update( :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str :param sql_pool_info: The updated SQL pool properties. Required. - :type sql_pool_info: IO + :type sql_pool_info: 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 SqlPool or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.SqlPool] @@ -296,7 +271,7 @@ async def begin_update( resource_group_name: str, workspace_name: str, sql_pool_name: str, - sql_pool_info: Union[_models.SqlPoolPatchInfo, IO], + sql_pool_info: Union[_models.SqlPoolPatchInfo, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.SqlPool]: """Update SQL pool. @@ -310,20 +285,9 @@ async def begin_update( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param sql_pool_info: The updated SQL pool properties. Is either a model type or a IO type. - Required. - :type sql_pool_info: ~azure.mgmt.synapse.models.SqlPoolPatchInfo 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 sql_pool_info: The updated SQL pool properties. Is either a SqlPoolPatchInfo type or a + IO[bytes] type. Required. + :type sql_pool_info: ~azure.mgmt.synapse.models.SqlPoolPatchInfo or IO[bytes] :return: An instance of AsyncLROPoller that returns either SqlPool or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.SqlPool] @@ -332,7 +296,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SqlPool] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -351,12 +315,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("SqlPool", pipeline_response) + deserialized = self._deserialize("SqlPool", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -366,50 +331,48 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.SqlPool].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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}" - } + return AsyncLROPoller[_models.SqlPool]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _create_initial( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, - sql_pool_info: Union[_models.SqlPool, IO], + sql_pool_info: Union[_models.SqlPool, IO[bytes]], **kwargs: Any - ) -> Optional[_models.SqlPool]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, + 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, - 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), } 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: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.SqlPool]] = 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(sql_pool_info, (IO, bytes)): + if isinstance(sql_pool_info, (IOBase, bytes)): _content = sql_pool_info else: _json = self._serialize.body(sql_pool_info, "SqlPool") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -418,36 +381,34 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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=False, **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 - if response.status_code == 200: - deserialized = self._deserialize("SqlPool", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}" - } + return deserialized # type: ignore @overload async def begin_create( @@ -476,14 +437,6 @@ async def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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 SqlPool or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.SqlPool] @@ -496,7 +449,7 @@ async def begin_create( resource_group_name: str, workspace_name: str, sql_pool_name: str, - sql_pool_info: IO, + sql_pool_info: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -513,18 +466,10 @@ async def begin_create( :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str :param sql_pool_info: The SQL pool to create. Required. - :type sql_pool_info: IO + :type sql_pool_info: 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 SqlPool or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.SqlPool] @@ -537,7 +482,7 @@ async def begin_create( resource_group_name: str, workspace_name: str, sql_pool_name: str, - sql_pool_info: Union[_models.SqlPool, IO], + sql_pool_info: Union[_models.SqlPool, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.SqlPool]: """Create SQL pool. @@ -551,19 +496,9 @@ async def begin_create( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param sql_pool_info: The SQL pool to create. Is either a model type or a IO type. Required. - :type sql_pool_info: ~azure.mgmt.synapse.models.SqlPool 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 sql_pool_info: The SQL pool to create. Is either a SqlPool type or a IO[bytes] type. + Required. + :type sql_pool_info: ~azure.mgmt.synapse.models.SqlPool or IO[bytes] :return: An instance of AsyncLROPoller that returns either SqlPool or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.SqlPool] @@ -572,7 +507,7 @@ async def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SqlPool] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -591,12 +526,13 @@ async def begin_create( 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("SqlPool", pipeline_response) + deserialized = self._deserialize("SqlPool", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -608,22 +544,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.SqlPool].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}" - } + return AsyncLROPoller[_models.SqlPool]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _delete_initial( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any - ) -> Optional[_models.SqlPool]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -634,48 +568,43 @@ async def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - cls: ClsType[Optional[_models.SqlPool]] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("SqlPool", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("SqlPool", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -692,14 +621,6 @@ async def begin_delete( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_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 SqlPool or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.SqlPool] @@ -708,7 +629,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPool] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -724,12 +645,13 @@ 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): - deserialized = self._deserialize("SqlPool", pipeline_response) + deserialized = self._deserialize("SqlPool", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -741,17 +663,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.SqlPool].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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}" - } + return AsyncLROPoller[_models.SqlPool]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list_by_workspace( @@ -766,7 +686,6 @@ def list_by_workspace( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SqlPool or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.SqlPool] :raises ~azure.core.exceptions.HttpResponseError: @@ -774,10 +693,10 @@ def list_by_workspace( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPoolInfoListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -788,24 +707,21 @@ def list_by_workspace( def prepare_request(next_link=None): if not next_link: - request = build_list_by_workspace_request( + _request = build_list_by_workspace_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_workspace.metadata["url"], 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("SqlPoolInfoListResult", pipeline_response) @@ -815,10 +731,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -831,14 +748,10 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_workspace.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools" - } - async def _pause_initial( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any - ) -> _models.SqlPool: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -849,48 +762,44 @@ async def _pause_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - cls: ClsType[_models.SqlPool] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_pause_request( + _request = build_pause_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._pause_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) - if response.status_code == 200: - deserialized = self._deserialize("SqlPool", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("SqlPool", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _pause_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/pause" - } - @distributed_trace_async async def begin_pause( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any @@ -906,14 +815,6 @@ async def begin_pause( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_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 SqlPool or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.SqlPool] @@ -922,7 +823,7 @@ async def begin_pause( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPool] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -938,12 +839,13 @@ async def begin_pause( 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("SqlPool", pipeline_response) + deserialized = self._deserialize("SqlPool", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -955,22 +857,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.SqlPool].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_pause.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/pause" - } + return AsyncLROPoller[_models.SqlPool]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _resume_initial( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any - ) -> _models.SqlPool: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -981,48 +881,44 @@ async def _resume_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - cls: ClsType[_models.SqlPool] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_resume_request( + _request = build_resume_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._resume_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) - if response.status_code == 200: - deserialized = self._deserialize("SqlPool", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("SqlPool", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _resume_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/resume" - } - @distributed_trace_async async def begin_resume( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any @@ -1038,14 +934,6 @@ async def begin_resume( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_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 SqlPool or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.SqlPool] @@ -1054,7 +942,7 @@ async def begin_resume( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPool] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -1070,12 +958,13 @@ async def begin_resume( 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("SqlPool", pipeline_response) + deserialized = self._deserialize("SqlPool", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1087,167 +976,12 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.SqlPool].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_resume.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/resume" - } - - @overload - async def rename( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - parameters: _models.ResourceMoveDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Rename a SQL pool. - - Rename a SQL pool. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param workspace_name: The name of the workspace. Required. - :type workspace_name: str - :param sql_pool_name: SQL pool name. Required. - :type sql_pool_name: str - :param parameters: The resource move definition for renaming this Sql pool. Required. - :type parameters: ~azure.mgmt.synapse.models.ResourceMoveDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - 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: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def rename( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Rename a SQL pool. - - Rename a SQL pool. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param workspace_name: The name of the workspace. Required. - :type workspace_name: str - :param sql_pool_name: SQL pool name. Required. - :type sql_pool_name: str - :param parameters: The resource move definition for renaming this Sql pool. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def rename( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - parameters: Union[_models.ResourceMoveDefinition, IO], - **kwargs: Any - ) -> None: - """Rename a SQL pool. - - Rename a SQL pool. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param workspace_name: The name of the workspace. Required. - :type workspace_name: str - :param sql_pool_name: SQL pool name. Required. - :type sql_pool_name: str - :param parameters: The resource move definition for renaming this Sql pool. Is either a model - type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.models.ResourceMoveDefinition or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ResourceMoveDefinition") - - request = build_rename_request( - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.rename.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + return AsyncLROPoller[_models.SqlPool]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - rename.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/move" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_aad_admins_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_aad_admins_operations.py index df34b8fa1302..76f20dc8202b 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_aad_admins_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_aad_admins_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,29 +15,29 @@ 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_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._workspace_aad_admins_operations import ( build_create_or_update_request, build_delete_request, build_get_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -70,12 +70,11 @@ async def get(self, resource_group_name: str, workspace_name: str, **kwargs: Any :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: WorkspaceAadAdminInfo or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.WorkspaceAadAdminInfo :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -86,23 +85,22 @@ async def get(self, resource_group_name: str, workspace_name: str, **kwargs: Any _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.WorkspaceAadAdminInfo] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -112,25 +110,21 @@ async def get(self, resource_group_name: str, workspace_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("WorkspaceAadAdminInfo", pipeline_response) + deserialized = self._deserialize("WorkspaceAadAdminInfo", 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.Synapse/workspaces/{workspaceName}/administrators/activeDirectory" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, workspace_name: str, - aad_admin_info: Union[_models.WorkspaceAadAdminInfo, IO], + aad_admin_info: Union[_models.WorkspaceAadAdminInfo, IO[bytes]], **kwargs: Any - ) -> _models.WorkspaceAadAdminInfo: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -141,19 +135,19 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.WorkspaceAadAdminInfo] = 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(aad_admin_info, (IO, bytes)): + if isinstance(aad_admin_info, (IOBase, bytes)): _content = aad_admin_info else: _json = self._serialize.body(aad_admin_info, "WorkspaceAadAdminInfo") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, @@ -161,39 +155,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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) - if response.status_code == 200: - deserialized = self._deserialize("WorkspaceAadAdminInfo", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("WorkspaceAadAdminInfo", 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.Synapse/workspaces/{workspaceName}/administrators/activeDirectory" - } - @overload async def begin_create_or_update( self, @@ -216,14 +206,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 WorkspaceAadAdminInfo or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.WorkspaceAadAdminInfo] @@ -235,7 +217,7 @@ async def begin_create_or_update( self, resource_group_name: str, workspace_name: str, - aad_admin_info: IO, + aad_admin_info: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -248,18 +230,10 @@ async def begin_create_or_update( :param workspace_name: The name of the workspace. Required. :type workspace_name: str :param aad_admin_info: Workspace active directory administrator properties. Required. - :type aad_admin_info: IO + :type aad_admin_info: 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 WorkspaceAadAdminInfo or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.WorkspaceAadAdminInfo] @@ -271,7 +245,7 @@ async def begin_create_or_update( self, resource_group_name: str, workspace_name: str, - aad_admin_info: Union[_models.WorkspaceAadAdminInfo, IO], + aad_admin_info: Union[_models.WorkspaceAadAdminInfo, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.WorkspaceAadAdminInfo]: """Creates or updates a workspace active directory admin. @@ -281,20 +255,9 @@ async def begin_create_or_update( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param aad_admin_info: Workspace active directory administrator properties. Is either a model - type or a IO type. Required. - :type aad_admin_info: ~azure.mgmt.synapse.models.WorkspaceAadAdminInfo 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 aad_admin_info: Workspace active directory administrator properties. Is either a + WorkspaceAadAdminInfo type or a IO[bytes] type. Required. + :type aad_admin_info: ~azure.mgmt.synapse.models.WorkspaceAadAdminInfo or IO[bytes] :return: An instance of AsyncLROPoller that returns either WorkspaceAadAdminInfo or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.WorkspaceAadAdminInfo] @@ -303,7 +266,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WorkspaceAadAdminInfo] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -321,12 +284,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("WorkspaceAadAdminInfo", pipeline_response) + deserialized = self._deserialize("WorkspaceAadAdminInfo", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -338,22 +302,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.WorkspaceAadAdminInfo].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.Synapse/workspaces/{workspaceName}/administrators/activeDirectory" - } + return AsyncLROPoller[_models.WorkspaceAadAdminInfo]( + 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, workspace_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -364,38 +326,42 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/administrators/activeDirectory" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete(self, resource_group_name: str, workspace_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -406,14 +372,6 @@ async def begin_delete(self, resource_group_name: str, workspace_name: str, **kw :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_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: @@ -421,13 +379,13 @@ async def begin_delete(self, resource_group_name: str, workspace_name: str, **kw _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) 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._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, workspace_name=workspace_name, api_version=api_version, @@ -436,11 +394,12 @@ async def begin_delete(self, resource_group_name: str, workspace_name: str, **kw 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( @@ -451,14 +410,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.Synapse/workspaces/{workspaceName}/administrators/activeDirectory" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_managed_identity_sql_control_settings_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_managed_identity_sql_control_settings_operations.py index e105662f1605..7273fd724700 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_managed_identity_sql_control_settings_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_managed_identity_sql_control_settings_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,33 +15,33 @@ 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_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._workspace_managed_identity_sql_control_settings_operations import ( build_create_or_update_request, build_get_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class WorkspaceManagedIdentitySqlControlSettingsOperations: +class WorkspaceManagedIdentitySqlControlSettingsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -73,12 +73,11 @@ async def get( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagedIdentitySqlControlSettingsModel or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ManagedIdentitySqlControlSettingsModel :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -89,23 +88,22 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.ManagedIdentitySqlControlSettingsModel] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -115,25 +113,21 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ManagedIdentitySqlControlSettingsModel", pipeline_response) + deserialized = self._deserialize("ManagedIdentitySqlControlSettingsModel", 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.Synapse/workspaces/{workspaceName}/managedIdentitySqlControlSettings/default" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, workspace_name: str, - managed_identity_sql_control_settings: Union[_models.ManagedIdentitySqlControlSettingsModel, IO], + managed_identity_sql_control_settings: Union[_models.ManagedIdentitySqlControlSettingsModel, IO[bytes]], **kwargs: Any - ) -> _models.ManagedIdentitySqlControlSettingsModel: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -144,21 +138,21 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ManagedIdentitySqlControlSettingsModel] = 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(managed_identity_sql_control_settings, (IO, bytes)): + if isinstance(managed_identity_sql_control_settings, (IOBase, bytes)): _content = managed_identity_sql_control_settings else: _json = self._serialize.body( managed_identity_sql_control_settings, "ManagedIdentitySqlControlSettingsModel" ) - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, @@ -166,39 +160,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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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("ManagedIdentitySqlControlSettingsModel", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ManagedIdentitySqlControlSettingsModel", 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.Synapse/workspaces/{workspaceName}/managedIdentitySqlControlSettings/default" - } - @overload async def begin_create_or_update( self, @@ -224,14 +214,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 ManagedIdentitySqlControlSettingsModel or the result of cls(response) :rtype: @@ -244,7 +226,7 @@ async def begin_create_or_update( self, resource_group_name: str, workspace_name: str, - managed_identity_sql_control_settings: IO, + managed_identity_sql_control_settings: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -259,18 +241,10 @@ async def begin_create_or_update( :param workspace_name: The name of the workspace. Required. :type workspace_name: str :param managed_identity_sql_control_settings: Managed Identity Sql Control Settings. Required. - :type managed_identity_sql_control_settings: IO + :type managed_identity_sql_control_settings: 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 ManagedIdentitySqlControlSettingsModel or the result of cls(response) :rtype: @@ -283,7 +257,7 @@ async def begin_create_or_update( self, resource_group_name: str, workspace_name: str, - managed_identity_sql_control_settings: Union[_models.ManagedIdentitySqlControlSettingsModel, IO], + managed_identity_sql_control_settings: Union[_models.ManagedIdentitySqlControlSettingsModel, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.ManagedIdentitySqlControlSettingsModel]: """Create or update Managed Identity Sql Control Settings. @@ -296,20 +270,9 @@ async def begin_create_or_update( :param workspace_name: The name of the workspace. Required. :type workspace_name: str :param managed_identity_sql_control_settings: Managed Identity Sql Control Settings. Is either - a model type or a IO type. Required. + a ManagedIdentitySqlControlSettingsModel type or a IO[bytes] type. Required. :type managed_identity_sql_control_settings: - ~azure.mgmt.synapse.models.ManagedIdentitySqlControlSettingsModel 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. + ~azure.mgmt.synapse.models.ManagedIdentitySqlControlSettingsModel or IO[bytes] :return: An instance of AsyncLROPoller that returns either ManagedIdentitySqlControlSettingsModel or the result of cls(response) :rtype: @@ -319,7 +282,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedIdentitySqlControlSettingsModel] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -337,12 +300,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("ManagedIdentitySqlControlSettingsModel", pipeline_response) + deserialized = self._deserialize("ManagedIdentitySqlControlSettingsModel", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -355,14 +319,12 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.ManagedIdentitySqlControlSettingsModel].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.Synapse/workspaces/{workspaceName}/managedIdentitySqlControlSettings/default" - } + return AsyncLROPoller[_models.ManagedIdentitySqlControlSettingsModel]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_managed_sql_server_blob_auditing_policies_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_managed_sql_server_blob_auditing_policies_operations.py index b1df1653778f..386974a29fcb 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_managed_sql_server_blob_auditing_policies_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_managed_sql_server_blob_auditing_policies_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -16,12 +16,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 @@ -29,22 +30,21 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._workspace_managed_sql_server_blob_auditing_policies_operations import ( build_create_or_update_request, build_get_request, build_list_by_workspace_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class WorkspaceManagedSqlServerBlobAuditingPoliciesOperations: +class WorkspaceManagedSqlServerBlobAuditingPoliciesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -82,12 +82,11 @@ async def get( :type workspace_name: str :param blob_auditing_policy_name: The name of the blob auditing policy. "default" Required. :type blob_auditing_policy_name: str or ~azure.mgmt.synapse.models.BlobAuditingPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: ServerBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ServerBlobAuditingPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -98,24 +97,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.ServerBlobAuditingPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, blob_auditing_policy_name=blob_auditing_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -124,26 +122,22 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ServerBlobAuditingPolicy", pipeline_response) + deserialized = self._deserialize("ServerBlobAuditingPolicy", 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.Synapse/workspaces/{workspaceName}/auditingSettings/{blobAuditingPolicyName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, workspace_name: str, blob_auditing_policy_name: Union[str, _models.BlobAuditingPolicyName], - parameters: Union[_models.ServerBlobAuditingPolicy, IO], + parameters: Union[_models.ServerBlobAuditingPolicy, IO[bytes]], **kwargs: Any - ) -> Optional[_models.ServerBlobAuditingPolicy]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -154,19 +148,19 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.ServerBlobAuditingPolicy]] = 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(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ServerBlobAuditingPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, blob_auditing_policy_name=blob_auditing_policy_name, @@ -175,35 +169,33 @@ 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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("ServerBlobAuditingPolicy", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/auditingSettings/{blobAuditingPolicyName}" - } + return deserialized # type: ignore @overload async def begin_create_or_update( @@ -232,14 +224,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 ServerBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.ServerBlobAuditingPolicy] @@ -252,7 +236,7 @@ async def begin_create_or_update( resource_group_name: str, workspace_name: str, blob_auditing_policy_name: Union[str, _models.BlobAuditingPolicyName], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -269,18 +253,10 @@ async def begin_create_or_update( :param blob_auditing_policy_name: The name of the blob auditing policy. "default" Required. :type blob_auditing_policy_name: str or ~azure.mgmt.synapse.models.BlobAuditingPolicyName :param parameters: Properties of extended blob auditing policy. 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 ServerBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.ServerBlobAuditingPolicy] @@ -293,7 +269,7 @@ async def begin_create_or_update( resource_group_name: str, workspace_name: str, blob_auditing_policy_name: Union[str, _models.BlobAuditingPolicyName], - parameters: Union[_models.ServerBlobAuditingPolicy, IO], + parameters: Union[_models.ServerBlobAuditingPolicy, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.ServerBlobAuditingPolicy]: """Create or Update server's blob auditing policy. @@ -307,20 +283,9 @@ async def begin_create_or_update( :type workspace_name: str :param blob_auditing_policy_name: The name of the blob auditing policy. "default" Required. :type blob_auditing_policy_name: str or ~azure.mgmt.synapse.models.BlobAuditingPolicyName - :param parameters: Properties of extended blob auditing policy. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.synapse.models.ServerBlobAuditingPolicy 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: Properties of extended blob auditing policy. Is either a + ServerBlobAuditingPolicy type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.ServerBlobAuditingPolicy or IO[bytes] :return: An instance of AsyncLROPoller that returns either ServerBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.ServerBlobAuditingPolicy] @@ -329,7 +294,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ServerBlobAuditingPolicy] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -348,12 +313,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("ServerBlobAuditingPolicy", pipeline_response) + deserialized = self._deserialize("ServerBlobAuditingPolicy", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -363,17 +329,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.ServerBlobAuditingPolicy].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.Synapse/workspaces/{workspaceName}/auditingSettings/{blobAuditingPolicyName}" - } + return AsyncLROPoller[_models.ServerBlobAuditingPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list_by_workspace( @@ -388,7 +352,6 @@ def list_by_workspace( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ServerBlobAuditingPolicy or the result of cls(response) :rtype: @@ -398,10 +361,10 @@ def list_by_workspace( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.ServerBlobAuditingPolicyListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -412,24 +375,21 @@ def list_by_workspace( def prepare_request(next_link=None): if not next_link: - request = build_list_by_workspace_request( + _request = build_list_by_workspace_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_workspace.metadata["url"], 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ServerBlobAuditingPolicyListResult", pipeline_response) @@ -439,10 +399,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -453,7 +414,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_workspace.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/auditingSettings" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_managed_sql_server_dedicated_sql_minimal_tls_settings_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_managed_sql_server_dedicated_sql_minimal_tls_settings_operations.py index f417f33b4f5f..1665711f9fcf 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_managed_sql_server_dedicated_sql_minimal_tls_settings_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_managed_sql_server_dedicated_sql_minimal_tls_settings_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -16,12 +16,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 @@ -29,22 +30,21 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._workspace_managed_sql_server_dedicated_sql_minimal_tls_settings_operations import ( build_get_request, build_list_request, build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class WorkspaceManagedSqlServerDedicatedSQLMinimalTlsSettingsOperations: +class WorkspaceManagedSqlServerDedicatedSQLMinimalTlsSettingsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -68,10 +68,10 @@ async def _update_initial( resource_group_name: str, workspace_name: str, dedicated_sq_lminimal_tls_settings_name: Union[str, _models.DedicatedSQLMinimalTlsSettingsName], - parameters: Union[_models.DedicatedSQLminimalTlsSettings, IO], + parameters: Union[_models.DedicatedSQLminimalTlsSettings, IO[bytes]], **kwargs: Any - ) -> Optional[_models.DedicatedSQLminimalTlsSettings]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -82,19 +82,19 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.DedicatedSQLminimalTlsSettings]] = 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(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DedicatedSQLminimalTlsSettings") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, dedicated_sq_lminimal_tls_settings_name=dedicated_sq_lminimal_tls_settings_name, @@ -103,36 +103,34 @@ 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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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 - if response.status_code == 200: - deserialized = self._deserialize("DedicatedSQLminimalTlsSettings", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/dedicatedSQLminimalTlsSettings/{dedicatedSQLminimalTlsSettingsName}" - } + return deserialized # type: ignore @overload async def begin_update( @@ -163,14 +161,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 DedicatedSQLminimalTlsSettings or the result of cls(response) :rtype: @@ -184,7 +174,7 @@ async def begin_update( resource_group_name: str, workspace_name: str, dedicated_sq_lminimal_tls_settings_name: Union[str, _models.DedicatedSQLMinimalTlsSettingsName], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -203,18 +193,10 @@ async def begin_update( :type dedicated_sq_lminimal_tls_settings_name: str or ~azure.mgmt.synapse.models.DedicatedSQLMinimalTlsSettingsName :param parameters: minimal tls settings. 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 DedicatedSQLminimalTlsSettings or the result of cls(response) :rtype: @@ -228,7 +210,7 @@ async def begin_update( resource_group_name: str, workspace_name: str, dedicated_sq_lminimal_tls_settings_name: Union[str, _models.DedicatedSQLMinimalTlsSettingsName], - parameters: Union[_models.DedicatedSQLminimalTlsSettings, IO], + parameters: Union[_models.DedicatedSQLminimalTlsSettings, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.DedicatedSQLminimalTlsSettings]: """Update server's tls settings. @@ -244,19 +226,9 @@ async def begin_update( settings. "default" Required. :type dedicated_sq_lminimal_tls_settings_name: str or ~azure.mgmt.synapse.models.DedicatedSQLMinimalTlsSettingsName - :param parameters: minimal tls settings. Is either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.models.DedicatedSQLminimalTlsSettings 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: minimal tls settings. Is either a DedicatedSQLminimalTlsSettings type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.DedicatedSQLminimalTlsSettings or IO[bytes] :return: An instance of AsyncLROPoller that returns either DedicatedSQLminimalTlsSettings or the result of cls(response) :rtype: @@ -266,7 +238,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DedicatedSQLminimalTlsSettings] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -285,12 +257,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("DedicatedSQLminimalTlsSettings", pipeline_response) + deserialized = self._deserialize("DedicatedSQLminimalTlsSettings", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -300,17 +273,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.DedicatedSQLminimalTlsSettings].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.Synapse/workspaces/{workspaceName}/dedicatedSQLminimalTlsSettings/{dedicatedSQLminimalTlsSettingsName}" - } + return AsyncLROPoller[_models.DedicatedSQLminimalTlsSettings]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def get( @@ -328,12 +299,11 @@ async def get( :param dedicated_sq_lminimal_tls_settings_name: The name of the dedicated sql minimal tls settings. Required. :type dedicated_sq_lminimal_tls_settings_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DedicatedSQLminimalTlsSettings or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.DedicatedSQLminimalTlsSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -344,24 +314,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.DedicatedSQLminimalTlsSettings] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, dedicated_sq_lminimal_tls_settings_name=dedicated_sq_lminimal_tls_settings_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -371,16 +340,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("DedicatedSQLminimalTlsSettings", pipeline_response) + deserialized = self._deserialize("DedicatedSQLminimalTlsSettings", 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.Synapse/workspaces/{workspaceName}/dedicatedSQLminimalTlsSettings/{dedicatedSQLminimalTlsSettingsName}" - } + return deserialized # type: ignore @distributed_trace def list( @@ -395,7 +360,6 @@ def list( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DedicatedSQLminimalTlsSettings or the result of cls(response) :rtype: @@ -405,10 +369,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.DedicatedSQLminimalTlsSettingsListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -419,24 +383,21 @@ 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, workspace_name=workspace_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DedicatedSQLminimalTlsSettingsListResult", pipeline_response) @@ -446,10 +407,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -461,7 +423,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.Synapse/workspaces/{workspaceName}/dedicatedSQLminimalTlsSettings" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_managed_sql_server_encryption_protector_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_managed_sql_server_encryption_protector_operations.py index d2163664ad5f..01d149b0c5b9 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_managed_sql_server_encryption_protector_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_managed_sql_server_encryption_protector_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -16,12 +16,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 @@ -29,7 +30,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._workspace_managed_sql_server_encryption_protector_operations import ( build_create_or_update_request, build_get_request, @@ -37,15 +37,15 @@ build_revalidate_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class WorkspaceManagedSqlServerEncryptionProtectorOperations: +class WorkspaceManagedSqlServerEncryptionProtectorOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -83,12 +83,11 @@ async def get( :type workspace_name: str :param encryption_protector_name: The name of the encryption protector. "current" Required. :type encryption_protector_name: str or ~azure.mgmt.synapse.models.EncryptionProtectorName - :keyword callable cls: A custom type or function that will be passed the direct response :return: EncryptionProtector or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.EncryptionProtector :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -99,24 +98,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.EncryptionProtector] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, encryption_protector_name=encryption_protector_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -126,26 +124,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("EncryptionProtector", pipeline_response) + deserialized = self._deserialize("EncryptionProtector", 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.Synapse/workspaces/{workspaceName}/encryptionProtector/{encryptionProtectorName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, workspace_name: str, encryption_protector_name: Union[str, _models.EncryptionProtectorName], - parameters: Union[_models.EncryptionProtector, IO], + parameters: Union[_models.EncryptionProtector, IO[bytes]], **kwargs: Any - ) -> Optional[_models.EncryptionProtector]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -156,19 +150,19 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.EncryptionProtector]] = 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(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "EncryptionProtector") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, encryption_protector_name=encryption_protector_name, @@ -177,36 +171,34 @@ 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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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 - if response.status_code == 200: - deserialized = self._deserialize("EncryptionProtector", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector/{encryptionProtectorName}" - } + return deserialized # type: ignore @overload async def begin_create_or_update( @@ -235,14 +227,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 EncryptionProtector or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.EncryptionProtector] @@ -255,7 +239,7 @@ async def begin_create_or_update( resource_group_name: str, workspace_name: str, encryption_protector_name: Union[str, _models.EncryptionProtectorName], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -272,18 +256,10 @@ async def begin_create_or_update( :param encryption_protector_name: The name of the encryption protector. "current" Required. :type encryption_protector_name: str or ~azure.mgmt.synapse.models.EncryptionProtectorName :param parameters: The requested encryption protector resource state. 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 EncryptionProtector or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.EncryptionProtector] @@ -296,7 +272,7 @@ async def begin_create_or_update( resource_group_name: str, workspace_name: str, encryption_protector_name: Union[str, _models.EncryptionProtectorName], - parameters: Union[_models.EncryptionProtector, IO], + parameters: Union[_models.EncryptionProtector, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.EncryptionProtector]: """Updates workspace server's encryption protector. @@ -310,20 +286,9 @@ async def begin_create_or_update( :type workspace_name: str :param encryption_protector_name: The name of the encryption protector. "current" Required. :type encryption_protector_name: str or ~azure.mgmt.synapse.models.EncryptionProtectorName - :param parameters: The requested encryption protector resource state. Is either a model type or - a IO type. Required. - :type parameters: ~azure.mgmt.synapse.models.EncryptionProtector 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: The requested encryption protector resource state. Is either a + EncryptionProtector type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.EncryptionProtector or IO[bytes] :return: An instance of AsyncLROPoller that returns either EncryptionProtector or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.EncryptionProtector] @@ -332,7 +297,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.EncryptionProtector] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -351,12 +316,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("EncryptionProtector", pipeline_response) + deserialized = self._deserialize("EncryptionProtector", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -366,17 +332,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.EncryptionProtector].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.Synapse/workspaces/{workspaceName}/encryptionProtector/{encryptionProtectorName}" - } + return AsyncLROPoller[_models.EncryptionProtector]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list( @@ -391,7 +355,6 @@ def list( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EncryptionProtector or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.EncryptionProtector] :raises ~azure.core.exceptions.HttpResponseError: @@ -399,10 +362,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.EncryptionProtectorListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -413,24 +376,21 @@ 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, workspace_name=workspace_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("EncryptionProtectorListResult", pipeline_response) @@ -440,10 +400,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -455,18 +416,14 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector" - } - - async def _revalidate_initial( # pylint: disable=inconsistent-return-statements + async def _revalidate_initial( self, resource_group_name: str, workspace_name: str, encryption_protector_name: Union[str, _models.EncryptionProtectorName], **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -477,38 +434,42 @@ async def _revalidate_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_revalidate_request( + _request = build_revalidate_request( resource_group_name=resource_group_name, workspace_name=workspace_name, encryption_protector_name=encryption_protector_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._revalidate_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _revalidate_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector/{encryptionProtectorName}/revalidate" - } + return deserialized # type: ignore @distributed_trace_async async def begin_revalidate( @@ -529,14 +490,6 @@ async def begin_revalidate( :type workspace_name: str :param encryption_protector_name: The name of the encryption protector. "current" Required. :type encryption_protector_name: str or ~azure.mgmt.synapse.models.EncryptionProtectorName - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~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: @@ -544,13 +497,13 @@ async def begin_revalidate( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) 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._revalidate_initial( # type: ignore + raw_result = await self._revalidate_initial( resource_group_name=resource_group_name, workspace_name=workspace_name, encryption_protector_name=encryption_protector_name, @@ -560,11 +513,12 @@ async def begin_revalidate( 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 +527,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_revalidate.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector/{encryptionProtectorName}/revalidate" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_managed_sql_server_extended_blob_auditing_policies_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_managed_sql_server_extended_blob_auditing_policies_operations.py index b2622fd1d91a..d540b1aac0a3 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_managed_sql_server_extended_blob_auditing_policies_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_managed_sql_server_extended_blob_auditing_policies_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -16,12 +16,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 @@ -29,22 +30,21 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._workspace_managed_sql_server_extended_blob_auditing_policies_operations import ( build_create_or_update_request, build_get_request, build_list_by_workspace_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class WorkspaceManagedSqlServerExtendedBlobAuditingPoliciesOperations: +class WorkspaceManagedSqlServerExtendedBlobAuditingPoliciesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -82,12 +82,11 @@ async def get( :type workspace_name: str :param blob_auditing_policy_name: The name of the blob auditing policy. "default" Required. :type blob_auditing_policy_name: str or ~azure.mgmt.synapse.models.BlobAuditingPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: ExtendedServerBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ExtendedServerBlobAuditingPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -98,24 +97,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.ExtendedServerBlobAuditingPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, blob_auditing_policy_name=blob_auditing_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -124,26 +122,22 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ExtendedServerBlobAuditingPolicy", pipeline_response) + deserialized = self._deserialize("ExtendedServerBlobAuditingPolicy", 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.Synapse/workspaces/{workspaceName}/extendedAuditingSettings/{blobAuditingPolicyName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, workspace_name: str, blob_auditing_policy_name: Union[str, _models.BlobAuditingPolicyName], - parameters: Union[_models.ExtendedServerBlobAuditingPolicy, IO], + parameters: Union[_models.ExtendedServerBlobAuditingPolicy, IO[bytes]], **kwargs: Any - ) -> Optional[_models.ExtendedServerBlobAuditingPolicy]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -154,19 +148,19 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.ExtendedServerBlobAuditingPolicy]] = 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(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ExtendedServerBlobAuditingPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, blob_auditing_policy_name=blob_auditing_policy_name, @@ -175,35 +169,33 @@ 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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("ExtendedServerBlobAuditingPolicy", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/extendedAuditingSettings/{blobAuditingPolicyName}" - } + return deserialized # type: ignore @overload async def begin_create_or_update( @@ -232,14 +224,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 ExtendedServerBlobAuditingPolicy or the result of cls(response) :rtype: @@ -253,7 +237,7 @@ async def begin_create_or_update( resource_group_name: str, workspace_name: str, blob_auditing_policy_name: Union[str, _models.BlobAuditingPolicyName], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -270,18 +254,10 @@ async def begin_create_or_update( :param blob_auditing_policy_name: The name of the blob auditing policy. "default" Required. :type blob_auditing_policy_name: str or ~azure.mgmt.synapse.models.BlobAuditingPolicyName :param parameters: Properties of extended blob auditing policy. 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 ExtendedServerBlobAuditingPolicy or the result of cls(response) :rtype: @@ -295,7 +271,7 @@ async def begin_create_or_update( resource_group_name: str, workspace_name: str, blob_auditing_policy_name: Union[str, _models.BlobAuditingPolicyName], - parameters: Union[_models.ExtendedServerBlobAuditingPolicy, IO], + parameters: Union[_models.ExtendedServerBlobAuditingPolicy, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.ExtendedServerBlobAuditingPolicy]: """Create or Update server's extended blob auditing policy. @@ -309,20 +285,9 @@ async def begin_create_or_update( :type workspace_name: str :param blob_auditing_policy_name: The name of the blob auditing policy. "default" Required. :type blob_auditing_policy_name: str or ~azure.mgmt.synapse.models.BlobAuditingPolicyName - :param parameters: Properties of extended blob auditing policy. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.synapse.models.ExtendedServerBlobAuditingPolicy 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: Properties of extended blob auditing policy. Is either a + ExtendedServerBlobAuditingPolicy type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.ExtendedServerBlobAuditingPolicy or IO[bytes] :return: An instance of AsyncLROPoller that returns either ExtendedServerBlobAuditingPolicy or the result of cls(response) :rtype: @@ -332,7 +297,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ExtendedServerBlobAuditingPolicy] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -351,12 +316,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("ExtendedServerBlobAuditingPolicy", pipeline_response) + deserialized = self._deserialize("ExtendedServerBlobAuditingPolicy", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -366,17 +332,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.ExtendedServerBlobAuditingPolicy].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.Synapse/workspaces/{workspaceName}/extendedAuditingSettings/{blobAuditingPolicyName}" - } + return AsyncLROPoller[_models.ExtendedServerBlobAuditingPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list_by_workspace( @@ -391,7 +355,6 @@ def list_by_workspace( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ExtendedServerBlobAuditingPolicy or the result of cls(response) :rtype: @@ -401,10 +364,10 @@ def list_by_workspace( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.ExtendedServerBlobAuditingPolicyListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -415,24 +378,21 @@ def list_by_workspace( def prepare_request(next_link=None): if not next_link: - request = build_list_by_workspace_request( + _request = build_list_by_workspace_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_workspace.metadata["url"], 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ExtendedServerBlobAuditingPolicyListResult", pipeline_response) @@ -442,10 +402,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -456,7 +417,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_workspace.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/extendedAuditingSettings" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_managed_sql_server_recoverable_sql_pools_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_managed_sql_server_recoverable_sql_pools_operations.py index 56e453738e92..674dcbf6501c 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_managed_sql_server_recoverable_sql_pools_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_managed_sql_server_recoverable_sql_pools_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -19,29 +18,27 @@ 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._workspace_managed_sql_server_recoverable_sql_pools_operations import ( build_get_request, build_list_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class WorkspaceManagedSqlServerRecoverableSqlPoolsOperations: +class WorkspaceManagedSqlServerRecoverableSqlPoolsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -73,7 +70,6 @@ def list( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecoverableSqlPool or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.RecoverableSqlPool] :raises ~azure.core.exceptions.HttpResponseError: @@ -81,10 +77,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.RecoverableSqlPoolListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -95,24 +91,21 @@ 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, workspace_name=workspace_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RecoverableSqlPoolListResult", pipeline_response) @@ -122,10 +115,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -137,10 +131,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/recoverableSqlPools" - } - @distributed_trace_async async def get( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any @@ -156,12 +146,11 @@ async def get( :type workspace_name: str :param sql_pool_name: The name of the sql pool. Required. :type sql_pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecoverableSqlPool or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.RecoverableSqlPool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -172,24 +161,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.RecoverableSqlPool] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -198,13 +186,9 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RecoverableSqlPool", pipeline_response) + deserialized = self._deserialize("RecoverableSqlPool", 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.Synapse/workspaces/{workspaceName}/recoverableSqlPools/{sqlPoolName}" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_managed_sql_server_security_alert_policy_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_managed_sql_server_security_alert_policy_operations.py index d1e1e668c078..6181dc8d25ef 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_managed_sql_server_security_alert_policy_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_managed_sql_server_security_alert_policy_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -16,12 +16,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 @@ -29,22 +30,21 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._workspace_managed_sql_server_security_alert_policy_operations import ( build_create_or_update_request, build_get_request, build_list_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class WorkspaceManagedSqlServerSecurityAlertPolicyOperations: +class WorkspaceManagedSqlServerSecurityAlertPolicyOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -83,12 +83,11 @@ async def get( :param security_alert_policy_name: The name of the security alert policy. "Default" Required. :type security_alert_policy_name: str or ~azure.mgmt.synapse.models.SecurityAlertPolicyNameAutoGenerated - :keyword callable cls: A custom type or function that will be passed the direct response :return: ServerSecurityAlertPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ServerSecurityAlertPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -99,24 +98,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.ServerSecurityAlertPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, security_alert_policy_name=security_alert_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -125,26 +123,22 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ServerSecurityAlertPolicy", pipeline_response) + deserialized = self._deserialize("ServerSecurityAlertPolicy", 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.Synapse/workspaces/{workspaceName}/securityAlertPolicies/{securityAlertPolicyName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, workspace_name: str, security_alert_policy_name: Union[str, _models.SecurityAlertPolicyNameAutoGenerated], - parameters: Union[_models.ServerSecurityAlertPolicy, IO], + parameters: Union[_models.ServerSecurityAlertPolicy, IO[bytes]], **kwargs: Any - ) -> Optional[_models.ServerSecurityAlertPolicy]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -155,19 +149,19 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.ServerSecurityAlertPolicy]] = 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(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ServerSecurityAlertPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, security_alert_policy_name=security_alert_policy_name, @@ -176,35 +170,33 @@ 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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("ServerSecurityAlertPolicy", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/securityAlertPolicies/{securityAlertPolicyName}" - } + return deserialized # type: ignore @overload async def begin_create_or_update( @@ -234,14 +226,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 ServerSecurityAlertPolicy or the result of cls(response) :rtype: @@ -255,7 +239,7 @@ async def begin_create_or_update( resource_group_name: str, workspace_name: str, security_alert_policy_name: Union[str, _models.SecurityAlertPolicyNameAutoGenerated], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -273,18 +257,10 @@ async def begin_create_or_update( :type security_alert_policy_name: str or ~azure.mgmt.synapse.models.SecurityAlertPolicyNameAutoGenerated :param parameters: The workspace managed sql server security alert policy. 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 ServerSecurityAlertPolicy or the result of cls(response) :rtype: @@ -298,7 +274,7 @@ async def begin_create_or_update( resource_group_name: str, workspace_name: str, security_alert_policy_name: Union[str, _models.SecurityAlertPolicyNameAutoGenerated], - parameters: Union[_models.ServerSecurityAlertPolicy, IO], + parameters: Union[_models.ServerSecurityAlertPolicy, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.ServerSecurityAlertPolicy]: """Create or Update server's threat detection policy. @@ -313,20 +289,9 @@ async def begin_create_or_update( :param security_alert_policy_name: The name of the security alert policy. "Default" Required. :type security_alert_policy_name: str or ~azure.mgmt.synapse.models.SecurityAlertPolicyNameAutoGenerated - :param parameters: The workspace managed sql server security alert policy. Is either a model - type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.models.ServerSecurityAlertPolicy 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: The workspace managed sql server security alert policy. Is either a + ServerSecurityAlertPolicy type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.ServerSecurityAlertPolicy or IO[bytes] :return: An instance of AsyncLROPoller that returns either ServerSecurityAlertPolicy or the result of cls(response) :rtype: @@ -336,7 +301,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ServerSecurityAlertPolicy] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -355,12 +320,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("ServerSecurityAlertPolicy", pipeline_response) + deserialized = self._deserialize("ServerSecurityAlertPolicy", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -370,17 +336,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.ServerSecurityAlertPolicy].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.Synapse/workspaces/{workspaceName}/securityAlertPolicies/{securityAlertPolicyName}" - } + return AsyncLROPoller[_models.ServerSecurityAlertPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list( @@ -395,7 +359,6 @@ def list( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ServerSecurityAlertPolicy or the result of cls(response) :rtype: @@ -405,10 +368,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.ServerSecurityAlertPolicyListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -419,24 +382,21 @@ 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, workspace_name=workspace_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ServerSecurityAlertPolicyListResult", pipeline_response) @@ -446,10 +406,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -460,7 +421,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.Synapse/workspaces/{workspaceName}/securityAlertPolicies" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_managed_sql_server_usages_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_managed_sql_server_usages_operations.py index 6c9f510fafc2..e85821936ef0 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_managed_sql_server_usages_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_managed_sql_server_usages_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -19,25 +18,23 @@ 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._workspace_managed_sql_server_usages_operations import build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class WorkspaceManagedSqlServerUsagesOperations: +class WorkspaceManagedSqlServerUsagesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -69,7 +66,6 @@ def list( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ServerUsage or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.ServerUsage] :raises ~azure.core.exceptions.HttpResponseError: @@ -77,10 +73,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.ServerUsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -91,24 +87,21 @@ 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, workspace_name=workspace_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ServerUsageListResult", pipeline_response) @@ -118,10 +111,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -132,7 +126,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.Synapse/workspaces/{workspaceName}/sqlUsages" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_managed_sql_server_vulnerability_assessments_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_managed_sql_server_vulnerability_assessments_operations.py index 33705e9a035f..035276cabdd0 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_managed_sql_server_vulnerability_assessments_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_managed_sql_server_vulnerability_assessments_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload @@ -19,15 +19,13 @@ 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._workspace_managed_sql_server_vulnerability_assessments_operations import ( build_create_or_update_request, build_delete_request, @@ -35,15 +33,15 @@ build_list_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class WorkspaceManagedSqlServerVulnerabilityAssessmentsOperations: +class WorkspaceManagedSqlServerVulnerabilityAssessmentsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -83,12 +81,11 @@ async def get( Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :keyword callable cls: A custom type or function that will be passed the direct response :return: ServerVulnerabilityAssessment or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ServerVulnerabilityAssessment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -99,24 +96,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.ServerVulnerabilityAssessment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, vulnerability_assessment_name=vulnerability_assessment_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -125,16 +121,12 @@ async def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ServerVulnerabilityAssessment", pipeline_response) + deserialized = self._deserialize("ServerVulnerabilityAssessment", 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.Synapse/workspaces/{workspaceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}" - } + return deserialized # type: ignore @overload async def create_or_update( @@ -165,7 +157,6 @@ async def 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 :return: ServerVulnerabilityAssessment or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ServerVulnerabilityAssessment :raises ~azure.core.exceptions.HttpResponseError: @@ -177,7 +168,7 @@ async def create_or_update( resource_group_name: str, workspace_name: str, vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -196,11 +187,10 @@ async def create_or_update( :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName :param parameters: Properties for vulnerability assessment. 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: ServerVulnerabilityAssessment or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ServerVulnerabilityAssessment :raises ~azure.core.exceptions.HttpResponseError: @@ -212,7 +202,7 @@ async def create_or_update( resource_group_name: str, workspace_name: str, vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - parameters: Union[_models.ServerVulnerabilityAssessment, IO], + parameters: Union[_models.ServerVulnerabilityAssessment, IO[bytes]], **kwargs: Any ) -> _models.ServerVulnerabilityAssessment: """Create or Update server's vulnerability assessment. @@ -228,18 +218,14 @@ async def create_or_update( Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :param parameters: Properties for vulnerability assessment. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.synapse.models.ServerVulnerabilityAssessment 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 parameters: Properties for vulnerability assessment. Is either a + ServerVulnerabilityAssessment type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.ServerVulnerabilityAssessment or IO[bytes] :return: ServerVulnerabilityAssessment or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ServerVulnerabilityAssessment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -250,19 +236,19 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ServerVulnerabilityAssessment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ServerVulnerabilityAssessment") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, vulnerability_assessment_name=vulnerability_assessment_name, @@ -271,15 +257,14 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -288,23 +273,15 @@ async def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ServerVulnerabilityAssessment", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ServerVulnerabilityAssessment", pipeline_response) + deserialized = self._deserialize("ServerVulnerabilityAssessment", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}" - } - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements + async def delete( self, resource_group_name: str, workspace_name: str, @@ -324,12 +301,11 @@ async def delete( # pylint: disable=inconsistent-return-statements Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -340,24 +316,23 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_name, vulnerability_assessment_name=vulnerability_assessment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -367,11 +342,7 @@ async def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -386,7 +357,6 @@ def list( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ServerVulnerabilityAssessment or the result of cls(response) :rtype: @@ -396,10 +366,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.ServerVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -410,24 +380,21 @@ 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, workspace_name=workspace_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("ServerVulnerabilityAssessmentListResult", pipeline_response) @@ -437,10 +404,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -451,7 +419,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.Synapse/workspaces/{workspaceName}/vulnerabilityAssessments" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_sql_aad_admins_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_sql_aad_admins_operations.py index 261740c54f93..ef7783ae4496 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_sql_aad_admins_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspace_sql_aad_admins_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,29 +15,29 @@ 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_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._workspace_sql_aad_admins_operations import ( build_create_or_update_request, build_delete_request, build_get_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -70,12 +70,11 @@ async def get(self, resource_group_name: str, workspace_name: str, **kwargs: Any :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: WorkspaceAadAdminInfo or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.WorkspaceAadAdminInfo :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -86,23 +85,22 @@ async def get(self, resource_group_name: str, workspace_name: str, **kwargs: Any _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.WorkspaceAadAdminInfo] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -112,25 +110,21 @@ async def get(self, resource_group_name: str, workspace_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("WorkspaceAadAdminInfo", pipeline_response) + deserialized = self._deserialize("WorkspaceAadAdminInfo", 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.Synapse/workspaces/{workspaceName}/sqlAdministrators/activeDirectory" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, workspace_name: str, - aad_admin_info: Union[_models.WorkspaceAadAdminInfo, IO], + aad_admin_info: Union[_models.WorkspaceAadAdminInfo, IO[bytes]], **kwargs: Any - ) -> _models.WorkspaceAadAdminInfo: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -141,19 +135,19 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.WorkspaceAadAdminInfo] = 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(aad_admin_info, (IO, bytes)): + if isinstance(aad_admin_info, (IOBase, bytes)): _content = aad_admin_info else: _json = self._serialize.body(aad_admin_info, "WorkspaceAadAdminInfo") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, @@ -161,39 +155,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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) - if response.status_code == 200: - deserialized = self._deserialize("WorkspaceAadAdminInfo", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("WorkspaceAadAdminInfo", 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.Synapse/workspaces/{workspaceName}/sqlAdministrators/activeDirectory" - } - @overload async def begin_create_or_update( self, @@ -216,14 +206,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 WorkspaceAadAdminInfo or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.WorkspaceAadAdminInfo] @@ -235,7 +217,7 @@ async def begin_create_or_update( self, resource_group_name: str, workspace_name: str, - aad_admin_info: IO, + aad_admin_info: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -248,18 +230,10 @@ async def begin_create_or_update( :param workspace_name: The name of the workspace. Required. :type workspace_name: str :param aad_admin_info: Workspace active directory administrator properties. Required. - :type aad_admin_info: IO + :type aad_admin_info: 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 WorkspaceAadAdminInfo or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.WorkspaceAadAdminInfo] @@ -271,7 +245,7 @@ async def begin_create_or_update( self, resource_group_name: str, workspace_name: str, - aad_admin_info: Union[_models.WorkspaceAadAdminInfo, IO], + aad_admin_info: Union[_models.WorkspaceAadAdminInfo, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.WorkspaceAadAdminInfo]: """Creates or updates a workspace SQL active directory admin. @@ -281,20 +255,9 @@ async def begin_create_or_update( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param aad_admin_info: Workspace active directory administrator properties. Is either a model - type or a IO type. Required. - :type aad_admin_info: ~azure.mgmt.synapse.models.WorkspaceAadAdminInfo 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 aad_admin_info: Workspace active directory administrator properties. Is either a + WorkspaceAadAdminInfo type or a IO[bytes] type. Required. + :type aad_admin_info: ~azure.mgmt.synapse.models.WorkspaceAadAdminInfo or IO[bytes] :return: An instance of AsyncLROPoller that returns either WorkspaceAadAdminInfo or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.WorkspaceAadAdminInfo] @@ -303,7 +266,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WorkspaceAadAdminInfo] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -321,12 +284,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("WorkspaceAadAdminInfo", pipeline_response) + deserialized = self._deserialize("WorkspaceAadAdminInfo", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -338,22 +302,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.WorkspaceAadAdminInfo].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.Synapse/workspaces/{workspaceName}/sqlAdministrators/activeDirectory" - } + return AsyncLROPoller[_models.WorkspaceAadAdminInfo]( + 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, workspace_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -364,38 +326,42 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlAdministrators/activeDirectory" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete(self, resource_group_name: str, workspace_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -406,14 +372,6 @@ async def begin_delete(self, resource_group_name: str, workspace_name: str, **kw :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_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: @@ -421,13 +379,13 @@ async def begin_delete(self, resource_group_name: str, workspace_name: str, **kw _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) 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._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, workspace_name=workspace_name, api_version=api_version, @@ -436,11 +394,12 @@ async def begin_delete(self, resource_group_name: str, workspace_name: str, **kw 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( @@ -451,14 +410,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.Synapse/workspaces/{workspaceName}/sqlAdministrators/activeDirectory" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspaces_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspaces_operations.py index 92e909b31fc6..ffc4b548d46b 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspaces_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_workspaces_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -16,12 +16,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 @@ -29,7 +30,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._workspaces_operations import ( build_create_or_update_request, build_delete_request, @@ -39,10 +39,10 @@ build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -73,7 +73,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 Workspace or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.Workspace] :raises ~azure.core.exceptions.HttpResponseError: @@ -81,10 +80,10 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.WorkspaceInfoListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -95,23 +94,20 @@ 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("WorkspaceInfoListResult", pipeline_response) @@ -121,10 +117,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -137,10 +134,6 @@ 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.Synapse/workspaces" - } - @distributed_trace_async async def get(self, resource_group_name: str, workspace_name: str, **kwargs: Any) -> _models.Workspace: """Gets a workspace. @@ -150,12 +143,11 @@ async def get(self, resource_group_name: str, workspace_name: str, **kwargs: Any :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Workspace or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.Workspace :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -166,23 +158,22 @@ async def get(self, resource_group_name: str, workspace_name: str, **kwargs: Any _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.Workspace] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -192,25 +183,21 @@ async def get(self, resource_group_name: str, workspace_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("Workspace", pipeline_response) + deserialized = self._deserialize("Workspace", 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.Synapse/workspaces/{workspaceName}" - } + return deserialized # type: ignore async def _update_initial( self, resource_group_name: str, workspace_name: str, - workspace_patch_info: Union[_models.WorkspacePatchInfo, IO], + workspace_patch_info: Union[_models.WorkspacePatchInfo, IO[bytes]], **kwargs: Any - ) -> _models.Workspace: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -221,19 +208,19 @@ async def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Workspace] = 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(workspace_patch_info, (IO, bytes)): + if isinstance(workspace_patch_info, (IOBase, bytes)): _content = workspace_patch_info else: _json = self._serialize.body(workspace_patch_info, "WorkspacePatchInfo") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, @@ -241,39 +228,35 @@ 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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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("Workspace", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Workspace", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}" - } - @overload async def begin_update( self, @@ -296,14 +279,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 Workspace or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.Workspace] @@ -315,7 +290,7 @@ async def begin_update( self, resource_group_name: str, workspace_name: str, - workspace_patch_info: IO, + workspace_patch_info: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -328,18 +303,10 @@ async def begin_update( :param workspace_name: The name of the workspace. Required. :type workspace_name: str :param workspace_patch_info: Workspace patch request properties. Required. - :type workspace_patch_info: IO + :type workspace_patch_info: 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 Workspace or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.Workspace] @@ -351,7 +318,7 @@ async def begin_update( self, resource_group_name: str, workspace_name: str, - workspace_patch_info: Union[_models.WorkspacePatchInfo, IO], + workspace_patch_info: Union[_models.WorkspacePatchInfo, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Workspace]: """Updates a workspace. @@ -361,20 +328,9 @@ async def begin_update( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param workspace_patch_info: Workspace patch request properties. Is either a model type or a IO - type. Required. - :type workspace_patch_info: ~azure.mgmt.synapse.models.WorkspacePatchInfo 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 workspace_patch_info: Workspace patch request properties. Is either a WorkspacePatchInfo + type or a IO[bytes] type. Required. + :type workspace_patch_info: ~azure.mgmt.synapse.models.WorkspacePatchInfo or IO[bytes] :return: An instance of AsyncLROPoller that returns either Workspace or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.Workspace] @@ -383,7 +339,7 @@ async def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Workspace] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -401,12 +357,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("Workspace", pipeline_response) + deserialized = self._deserialize("Workspace", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -418,22 +375,24 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Workspace].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.Synapse/workspaces/{workspaceName}" - } + return AsyncLROPoller[_models.Workspace]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _create_or_update_initial( - self, resource_group_name: str, workspace_name: str, workspace_info: Union[_models.Workspace, IO], **kwargs: Any - ) -> _models.Workspace: - error_map = { + self, + resource_group_name: str, + workspace_name: str, + workspace_info: Union[_models.Workspace, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -444,19 +403,19 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Workspace] = 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(workspace_info, (IO, bytes)): + if isinstance(workspace_info, (IOBase, bytes)): _content = workspace_info else: _json = self._serialize.body(workspace_info, "Workspace") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, @@ -464,39 +423,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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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("Workspace", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Workspace", 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.Synapse/workspaces/{workspaceName}" - } - @overload async def begin_create_or_update( self, @@ -519,14 +474,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 Workspace or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.Workspace] @@ -538,7 +485,7 @@ async def begin_create_or_update( self, resource_group_name: str, workspace_name: str, - workspace_info: IO, + workspace_info: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -551,18 +498,10 @@ async def begin_create_or_update( :param workspace_name: The name of the workspace. Required. :type workspace_name: str :param workspace_info: Workspace create or update request properties. Required. - :type workspace_info: IO + :type workspace_info: 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 Workspace or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.Workspace] @@ -571,7 +510,11 @@ async def begin_create_or_update( @distributed_trace_async async def begin_create_or_update( - self, resource_group_name: str, workspace_name: str, workspace_info: Union[_models.Workspace, IO], **kwargs: Any + self, + resource_group_name: str, + workspace_name: str, + workspace_info: Union[_models.Workspace, IO[bytes]], + **kwargs: Any ) -> AsyncLROPoller[_models.Workspace]: """Creates or updates a workspace. @@ -580,20 +523,9 @@ async def begin_create_or_update( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param workspace_info: Workspace create or update request properties. Is either a model type or - a IO type. Required. - :type workspace_info: ~azure.mgmt.synapse.models.Workspace 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 workspace_info: Workspace create or update request properties. Is either a Workspace + type or a IO[bytes] type. Required. + :type workspace_info: ~azure.mgmt.synapse.models.Workspace or IO[bytes] :return: An instance of AsyncLROPoller that returns either Workspace or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.Workspace] @@ -602,7 +534,7 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Workspace] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -620,12 +552,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("Workspace", pipeline_response) + deserialized = self._deserialize("Workspace", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -637,22 +570,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Workspace].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.Synapse/workspaces/{workspaceName}" - } + return AsyncLROPoller[_models.Workspace]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _delete_initial( self, resource_group_name: str, workspace_name: str, **kwargs: Any - ) -> Optional[_models.Workspace]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -663,47 +594,42 @@ async def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - cls: ClsType[Optional[_models.Workspace]] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("Workspace", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("Workspace", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -716,14 +642,6 @@ async def begin_delete( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_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 Workspace or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.Workspace] @@ -732,7 +650,7 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.Workspace] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -747,12 +665,13 @@ 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): - deserialized = self._deserialize("Workspace", pipeline_response) + deserialized = self._deserialize("Workspace", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -764,23 +683,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Workspace].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.Synapse/workspaces/{workspaceName}" - } + return AsyncLROPoller[_models.Workspace]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Workspace"]: """Returns a list of workspaces in a subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Workspace or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.Workspace] :raises ~azure.core.exceptions.HttpResponseError: @@ -788,10 +704,10 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Workspace"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.WorkspaceInfoListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -802,22 +718,19 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Workspace"]: 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("WorkspaceInfoListResult", pipeline_response) @@ -827,10 +740,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -842,5 +756,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Synapse/workspaces"} diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/models/__init__.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/models/__init__.py index da1c54367b79..0971c2237e63 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/models/__init__.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/models/__init__.py @@ -5,353 +5,366 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._models_py3 import AttachedDatabaseConfiguration -from ._models_py3 import AttachedDatabaseConfigurationListResult -from ._models_py3 import AutoPauseProperties -from ._models_py3 import AutoScaleProperties -from ._models_py3 import AvailableRpOperation -from ._models_py3 import AvailableRpOperationDisplayInfo -from ._models_py3 import AzureADOnlyAuthentication -from ._models_py3 import AzureADOnlyAuthenticationListResult -from ._models_py3 import AzureCapacity -from ._models_py3 import AzureEntityResource -from ._models_py3 import AzureResourceSku -from ._models_py3 import AzureSku -from ._models_py3 import BigDataPoolPatchInfo -from ._models_py3 import BigDataPoolResourceInfo -from ._models_py3 import BigDataPoolResourceInfoListResult -from ._models_py3 import CheckNameAvailabilityRequest -from ._models_py3 import CheckNameAvailabilityResponse -from ._models_py3 import CheckNameResult -from ._models_py3 import ClusterPrincipalAssignment -from ._models_py3 import ClusterPrincipalAssignmentCheckNameRequest -from ._models_py3 import ClusterPrincipalAssignmentListResult -from ._models_py3 import CmdkeySetup -from ._models_py3 import ComponentSetup -from ._models_py3 import CreateSqlPoolRestorePointDefinition -from ._models_py3 import CspWorkspaceAdminProperties -from ._models_py3 import CustomSetupBase -from ._models_py3 import CustomerManagedKeyDetails -from ._models_py3 import DataConnection -from ._models_py3 import DataConnectionCheckNameRequest -from ._models_py3 import DataConnectionListResult -from ._models_py3 import DataConnectionValidation -from ._models_py3 import DataConnectionValidationListResult -from ._models_py3 import DataConnectionValidationResult -from ._models_py3 import DataLakeStorageAccountDetails -from ._models_py3 import DataMaskingPolicy -from ._models_py3 import DataMaskingRule -from ._models_py3 import DataMaskingRuleListResult -from ._models_py3 import DataWarehouseUserActivities -from ._models_py3 import Database -from ._models_py3 import DatabaseCheckNameRequest -from ._models_py3 import DatabaseListResult -from ._models_py3 import DatabasePrincipalAssignment -from ._models_py3 import DatabasePrincipalAssignmentCheckNameRequest -from ._models_py3 import DatabasePrincipalAssignmentListResult -from ._models_py3 import DatabaseStatistics -from ._models_py3 import DedicatedSQLminimalTlsSettings -from ._models_py3 import DedicatedSQLminimalTlsSettingsListResult -from ._models_py3 import DedicatedSQLminimalTlsSettingsPatchInfo -from ._models_py3 import DynamicExecutorAllocation -from ._models_py3 import EncryptionDetails -from ._models_py3 import EncryptionProtector -from ._models_py3 import EncryptionProtectorListResult -from ._models_py3 import EntityReference -from ._models_py3 import EnvironmentVariableSetup -from ._models_py3 import ErrorAdditionalInfo -from ._models_py3 import ErrorDetail -from ._models_py3 import ErrorResponse -from ._models_py3 import ErrorResponseAutoGenerated -from ._models_py3 import EventGridDataConnection -from ._models_py3 import EventHubDataConnection -from ._models_py3 import ExtendedServerBlobAuditingPolicy -from ._models_py3 import ExtendedServerBlobAuditingPolicyListResult -from ._models_py3 import ExtendedSqlPoolBlobAuditingPolicy -from ._models_py3 import ExtendedSqlPoolBlobAuditingPolicyListResult -from ._models_py3 import FollowerDatabaseDefinition -from ._models_py3 import FollowerDatabaseListResult -from ._models_py3 import GeoBackupPolicy -from ._models_py3 import GeoBackupPolicyListResult -from ._models_py3 import GetSsisObjectMetadataRequest -from ._models_py3 import IntegrationRuntime -from ._models_py3 import IntegrationRuntimeAuthKeys -from ._models_py3 import IntegrationRuntimeComputeProperties -from ._models_py3 import IntegrationRuntimeConnectionInfo -from ._models_py3 import IntegrationRuntimeCustomSetupScriptProperties -from ._models_py3 import IntegrationRuntimeDataFlowProperties -from ._models_py3 import IntegrationRuntimeDataProxyProperties -from ._models_py3 import IntegrationRuntimeEnableinteractivequery -from ._models_py3 import IntegrationRuntimeListResponse -from ._models_py3 import IntegrationRuntimeMonitoringData -from ._models_py3 import IntegrationRuntimeNodeIpAddress -from ._models_py3 import IntegrationRuntimeNodeMonitoringData -from ._models_py3 import IntegrationRuntimeOperationStatus -from ._models_py3 import IntegrationRuntimeOutboundNetworkDependenciesCategoryEndpoint -from ._models_py3 import IntegrationRuntimeOutboundNetworkDependenciesEndpoint -from ._models_py3 import IntegrationRuntimeOutboundNetworkDependenciesEndpointDetails -from ._models_py3 import IntegrationRuntimeOutboundNetworkDependenciesEndpointsResponse -from ._models_py3 import IntegrationRuntimeRegenerateKeyParameters -from ._models_py3 import IntegrationRuntimeResource -from ._models_py3 import IntegrationRuntimeSsisCatalogInfo -from ._models_py3 import IntegrationRuntimeSsisProperties -from ._models_py3 import IntegrationRuntimeStatus -from ._models_py3 import IntegrationRuntimeStatusResponse -from ._models_py3 import IntegrationRuntimeStopOperationStatus -from ._models_py3 import IntegrationRuntimeVNetProperties -from ._models_py3 import IotHubDataConnection -from ._models_py3 import IpFirewallRuleInfo -from ._models_py3 import IpFirewallRuleInfoListResult -from ._models_py3 import IpFirewallRuleProperties -from ._models_py3 import KekIdentityProperties -from ._models_py3 import Key -from ._models_py3 import KeyInfoListResult -from ._models_py3 import KustoPool -from ._models_py3 import KustoPoolCheckNameRequest -from ._models_py3 import KustoPoolListResult -from ._models_py3 import KustoPoolPrivateLinkResources -from ._models_py3 import KustoPoolUpdate -from ._models_py3 import LanguageExtension -from ._models_py3 import LanguageExtensionsList -from ._models_py3 import LibraryInfo -from ._models_py3 import LibraryListResponse -from ._models_py3 import LibraryRequirements -from ._models_py3 import LibraryResource -from ._models_py3 import LinkedIntegrationRuntime -from ._models_py3 import LinkedIntegrationRuntimeKeyAuthorization -from ._models_py3 import LinkedIntegrationRuntimeRbacAuthorization -from ._models_py3 import LinkedIntegrationRuntimeType -from ._models_py3 import ListResourceSkusResult -from ._models_py3 import ListSqlPoolSecurityAlertPolicies -from ._models_py3 import MaintenanceWindowOptions -from ._models_py3 import MaintenanceWindowTimeRange -from ._models_py3 import MaintenanceWindows -from ._models_py3 import ManagedIdentity -from ._models_py3 import ManagedIdentitySqlControlSettingsModel -from ._models_py3 import ManagedIdentitySqlControlSettingsModelPropertiesGrantSqlControlToManagedIdentity -from ._models_py3 import ManagedIntegrationRuntime -from ._models_py3 import ManagedIntegrationRuntimeError -from ._models_py3 import ManagedIntegrationRuntimeNode -from ._models_py3 import ManagedIntegrationRuntimeOperationResult -from ._models_py3 import ManagedIntegrationRuntimeStatus -from ._models_py3 import ManagedVirtualNetworkSettings -from ._models_py3 import MetadataSyncConfig -from ._models_py3 import Operation -from ._models_py3 import OperationDisplay -from ._models_py3 import OperationListResult -from ._models_py3 import OperationMetaLogSpecification -from ._models_py3 import OperationMetaMetricDimensionSpecification -from ._models_py3 import OperationMetaMetricSpecification -from ._models_py3 import OperationMetaServiceSpecification -from ._models_py3 import OperationResource -from ._models_py3 import OptimizedAutoscale -from ._models_py3 import PrivateEndpoint -from ._models_py3 import PrivateEndpointConnection -from ._models_py3 import PrivateEndpointConnectionForPrivateLinkHub -from ._models_py3 import PrivateEndpointConnectionForPrivateLinkHubBasic -from ._models_py3 import PrivateEndpointConnectionForPrivateLinkHubBasicAutoGenerated -from ._models_py3 import PrivateEndpointConnectionForPrivateLinkHubResourceCollectionResponse -from ._models_py3 import PrivateEndpointConnectionList -from ._models_py3 import PrivateEndpointConnectionProperties -from ._models_py3 import PrivateLinkHub -from ._models_py3 import PrivateLinkHubInfoListResult -from ._models_py3 import PrivateLinkHubPatchInfo -from ._models_py3 import PrivateLinkResource -from ._models_py3 import PrivateLinkResourceListResult -from ._models_py3 import PrivateLinkResourceProperties -from ._models_py3 import PrivateLinkResources -from ._models_py3 import PrivateLinkServiceConnectionState -from ._models_py3 import ProxyResource -from ._models_py3 import PurviewConfiguration -from ._models_py3 import QueryInterval -from ._models_py3 import QueryMetric -from ._models_py3 import QueryStatistic -from ._models_py3 import ReadOnlyFollowingDatabase -from ._models_py3 import ReadWriteDatabase -from ._models_py3 import RecommendedSensitivityLabelUpdate -from ._models_py3 import RecommendedSensitivityLabelUpdateList -from ._models_py3 import RecoverableSqlPool -from ._models_py3 import RecoverableSqlPoolListResult -from ._models_py3 import ReplaceAllFirewallRulesOperationResponse -from ._models_py3 import ReplaceAllIpFirewallRulesRequest -from ._models_py3 import ReplicationLink -from ._models_py3 import ReplicationLinkListResult -from ._models_py3 import Resource -from ._models_py3 import ResourceMoveDefinition -from ._models_py3 import RestorableDroppedSqlPool -from ._models_py3 import RestorableDroppedSqlPoolListResult -from ._models_py3 import RestorePoint -from ._models_py3 import RestorePointListResult -from ._models_py3 import SecretBase -from ._models_py3 import SecureString -from ._models_py3 import SelfHostedIntegrationRuntime -from ._models_py3 import SelfHostedIntegrationRuntimeNode -from ._models_py3 import SelfHostedIntegrationRuntimeStatus -from ._models_py3 import SensitivityLabel -from ._models_py3 import SensitivityLabelListResult -from ._models_py3 import SensitivityLabelUpdate -from ._models_py3 import SensitivityLabelUpdateList -from ._models_py3 import ServerBlobAuditingPolicy -from ._models_py3 import ServerBlobAuditingPolicyListResult -from ._models_py3 import ServerSecurityAlertPolicy -from ._models_py3 import ServerSecurityAlertPolicyListResult -from ._models_py3 import ServerUsage -from ._models_py3 import ServerUsageListResult -from ._models_py3 import ServerVulnerabilityAssessment -from ._models_py3 import ServerVulnerabilityAssessmentListResult -from ._models_py3 import Sku -from ._models_py3 import SkuDescription -from ._models_py3 import SkuDescriptionList -from ._models_py3 import SkuLocationInfoItem -from ._models_py3 import SparkConfigProperties -from ._models_py3 import SparkConfigurationListResponse -from ._models_py3 import SparkConfigurationResource -from ._models_py3 import SqlPool -from ._models_py3 import SqlPoolBlobAuditingPolicy -from ._models_py3 import SqlPoolBlobAuditingPolicyListResult -from ._models_py3 import SqlPoolBlobAuditingPolicySqlPoolOperationListResult -from ._models_py3 import SqlPoolColumn -from ._models_py3 import SqlPoolColumnListResult -from ._models_py3 import SqlPoolConnectionPolicy -from ._models_py3 import SqlPoolInfoListResult -from ._models_py3 import SqlPoolOperation -from ._models_py3 import SqlPoolPatchInfo -from ._models_py3 import SqlPoolSchema -from ._models_py3 import SqlPoolSchemaListResult -from ._models_py3 import SqlPoolSecurityAlertPolicy -from ._models_py3 import SqlPoolTable -from ._models_py3 import SqlPoolTableListResult -from ._models_py3 import SqlPoolUsage -from ._models_py3 import SqlPoolUsageListResult -from ._models_py3 import SqlPoolVulnerabilityAssessment -from ._models_py3 import SqlPoolVulnerabilityAssessmentListResult -from ._models_py3 import SqlPoolVulnerabilityAssessmentRuleBaseline -from ._models_py3 import SqlPoolVulnerabilityAssessmentRuleBaselineItem -from ._models_py3 import SqlPoolVulnerabilityAssessmentScansExport -from ._models_py3 import SsisEnvironment -from ._models_py3 import SsisEnvironmentReference -from ._models_py3 import SsisFolder -from ._models_py3 import SsisObjectMetadata -from ._models_py3 import SsisObjectMetadataListResponse -from ._models_py3 import SsisObjectMetadataStatusResponse -from ._models_py3 import SsisPackage -from ._models_py3 import SsisParameter -from ._models_py3 import SsisProject -from ._models_py3 import SsisVariable -from ._models_py3 import SubResource -from ._models_py3 import SystemData -from ._models_py3 import TableLevelSharingProperties -from ._models_py3 import TopQueries -from ._models_py3 import TopQueriesListResult -from ._models_py3 import TrackedResource -from ._models_py3 import TransparentDataEncryption -from ._models_py3 import TransparentDataEncryptionListResult -from ._models_py3 import UpdateIntegrationRuntimeNodeRequest -from ._models_py3 import UpdateIntegrationRuntimeRequest -from ._models_py3 import UserAssignedManagedIdentity -from ._models_py3 import VirtualNetworkProfile -from ._models_py3 import VulnerabilityAssessmentRecurringScansProperties -from ._models_py3 import VulnerabilityAssessmentScanError -from ._models_py3 import VulnerabilityAssessmentScanRecord -from ._models_py3 import VulnerabilityAssessmentScanRecordListResult -from ._models_py3 import WorkloadClassifier -from ._models_py3 import WorkloadClassifierListResult -from ._models_py3 import WorkloadGroup -from ._models_py3 import WorkloadGroupListResult -from ._models_py3 import Workspace -from ._models_py3 import WorkspaceAadAdminInfo -from ._models_py3 import WorkspaceInfoListResult -from ._models_py3 import WorkspaceKeyDetails -from ._models_py3 import WorkspacePatchInfo -from ._models_py3 import WorkspaceRepositoryConfiguration +from typing import TYPE_CHECKING -from ._synapse_management_client_enums import ActualState -from ._synapse_management_client_enums import AzureADOnlyAuthenticationName -from ._synapse_management_client_enums import AzureScaleType -from ._synapse_management_client_enums import BlobAuditingPolicyName -from ._synapse_management_client_enums import BlobAuditingPolicyState -from ._synapse_management_client_enums import BlobStorageEventType -from ._synapse_management_client_enums import ClusterPrincipalRole -from ._synapse_management_client_enums import ColumnDataType -from ._synapse_management_client_enums import Compression -from ._synapse_management_client_enums import ConfigurationType -from ._synapse_management_client_enums import ConnectionPolicyName -from ._synapse_management_client_enums import CreateMode -from ._synapse_management_client_enums import CreatedByType -from ._synapse_management_client_enums import DataConnectionKind -from ._synapse_management_client_enums import DataFlowComputeType -from ._synapse_management_client_enums import DataMaskingFunction -from ._synapse_management_client_enums import DataMaskingRuleState -from ._synapse_management_client_enums import DataMaskingState -from ._synapse_management_client_enums import DataWarehouseUserActivityName -from ._synapse_management_client_enums import DatabasePrincipalRole -from ._synapse_management_client_enums import DayOfWeek -from ._synapse_management_client_enums import DedicatedSQLMinimalTlsSettingsName -from ._synapse_management_client_enums import DefaultPrincipalsModificationKind -from ._synapse_management_client_enums import DesiredState -from ._synapse_management_client_enums import EncryptionProtectorName -from ._synapse_management_client_enums import EventGridDataFormat -from ._synapse_management_client_enums import EventHubDataFormat -from ._synapse_management_client_enums import GeoBackupPolicyName -from ._synapse_management_client_enums import GeoBackupPolicyState -from ._synapse_management_client_enums import IntegrationRuntimeAuthKeyName -from ._synapse_management_client_enums import IntegrationRuntimeAutoUpdate -from ._synapse_management_client_enums import IntegrationRuntimeEdition -from ._synapse_management_client_enums import IntegrationRuntimeEntityReferenceType -from ._synapse_management_client_enums import IntegrationRuntimeInternalChannelEncryptionMode -from ._synapse_management_client_enums import IntegrationRuntimeLicenseType -from ._synapse_management_client_enums import IntegrationRuntimeSsisCatalogPricingTier -from ._synapse_management_client_enums import IntegrationRuntimeState -from ._synapse_management_client_enums import IntegrationRuntimeType -from ._synapse_management_client_enums import IntegrationRuntimeUpdateResult -from ._synapse_management_client_enums import IotHubDataFormat -from ._synapse_management_client_enums import Kind -from ._synapse_management_client_enums import LanguageExtensionName -from ._synapse_management_client_enums import ManagedIntegrationRuntimeNodeStatus -from ._synapse_management_client_enums import ManagementOperationState -from ._synapse_management_client_enums import NodeSize -from ._synapse_management_client_enums import NodeSizeFamily -from ._synapse_management_client_enums import OperationStatus -from ._synapse_management_client_enums import PrincipalType -from ._synapse_management_client_enums import PrincipalsModificationKind -from ._synapse_management_client_enums import ProvisioningState -from ._synapse_management_client_enums import QueryAggregationFunction -from ._synapse_management_client_enums import QueryExecutionType -from ._synapse_management_client_enums import QueryMetricUnit -from ._synapse_management_client_enums import QueryObservedMetricType -from ._synapse_management_client_enums import Reason -from ._synapse_management_client_enums import RecommendedSensitivityLabelUpdateKind -from ._synapse_management_client_enums import ReplicationRole -from ._synapse_management_client_enums import ReplicationState -from ._synapse_management_client_enums import ResourceIdentityType -from ._synapse_management_client_enums import ResourceProvisioningState -from ._synapse_management_client_enums import RestorePointType -from ._synapse_management_client_enums import SecurityAlertPolicyName -from ._synapse_management_client_enums import SecurityAlertPolicyNameAutoGenerated -from ._synapse_management_client_enums import SecurityAlertPolicyState -from ._synapse_management_client_enums import SelfHostedIntegrationRuntimeNodeStatus -from ._synapse_management_client_enums import SensitivityLabelRank -from ._synapse_management_client_enums import SensitivityLabelSource -from ._synapse_management_client_enums import SensitivityLabelUpdateKind -from ._synapse_management_client_enums import ServerKeyType -from ._synapse_management_client_enums import SkuName -from ._synapse_management_client_enums import SkuSize -from ._synapse_management_client_enums import SsisObjectMetadataType -from ._synapse_management_client_enums import State -from ._synapse_management_client_enums import StateValue -from ._synapse_management_client_enums import StorageAccountType -from ._synapse_management_client_enums import TransparentDataEncryptionName -from ._synapse_management_client_enums import TransparentDataEncryptionStatus -from ._synapse_management_client_enums import Type -from ._synapse_management_client_enums import VulnerabilityAssessmentName -from ._synapse_management_client_enums import VulnerabilityAssessmentPolicyBaselineName -from ._synapse_management_client_enums import VulnerabilityAssessmentScanState -from ._synapse_management_client_enums import VulnerabilityAssessmentScanTriggerType -from ._synapse_management_client_enums import WorkspacePublicNetworkAccess -from ._synapse_management_client_enums import WorkspaceStatus +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models_py3 import ( # type: ignore + AttachedDatabaseConfiguration, + AttachedDatabaseConfigurationListResult, + AutoPauseProperties, + AutoScaleProperties, + AvailableRpOperation, + AvailableRpOperationDisplayInfo, + AzureADOnlyAuthentication, + AzureADOnlyAuthenticationListResult, + AzureCapacity, + AzureEntityResource, + AzureResourceSku, + AzureSku, + BigDataPoolPatchInfo, + BigDataPoolResourceInfo, + BigDataPoolResourceInfoListResult, + CheckNameAvailabilityRequest, + CheckNameAvailabilityResponse, + CheckNameResult, + ClusterPrincipalAssignment, + ClusterPrincipalAssignmentCheckNameRequest, + ClusterPrincipalAssignmentListResult, + CmdkeySetup, + ComponentSetup, + CopyComputeScaleProperties, + CreateSqlPoolRestorePointDefinition, + CspWorkspaceAdminProperties, + CustomSetupBase, + CustomerManagedKeyDetails, + DataConnection, + DataConnectionCheckNameRequest, + DataConnectionListResult, + DataConnectionValidation, + DataConnectionValidationListResult, + DataConnectionValidationResult, + DataLakeStorageAccountDetails, + DataMaskingPolicy, + DataMaskingRule, + DataMaskingRuleListResult, + DataWarehouseUserActivities, + Database, + DatabaseCheckNameRequest, + DatabaseListResult, + DatabasePrincipalAssignment, + DatabasePrincipalAssignmentCheckNameRequest, + DatabasePrincipalAssignmentListResult, + DatabaseStatistics, + DedicatedSQLminimalTlsSettings, + DedicatedSQLminimalTlsSettingsListResult, + DedicatedSQLminimalTlsSettingsPatchInfo, + DynamicExecutorAllocation, + EncryptionDetails, + EncryptionProtector, + EncryptionProtectorListResult, + EntityReference, + EnvironmentVariableSetup, + ErrorAdditionalInfo, + ErrorDetail, + ErrorResponse, + ErrorResponseAutoGenerated, + EventGridDataConnection, + EventHubDataConnection, + ExtendedServerBlobAuditingPolicy, + ExtendedServerBlobAuditingPolicyListResult, + ExtendedSqlPoolBlobAuditingPolicy, + ExtendedSqlPoolBlobAuditingPolicyListResult, + FollowerDatabaseDefinition, + FollowerDatabaseListResult, + GeoBackupPolicy, + GeoBackupPolicyListResult, + GetSsisObjectMetadataRequest, + IntegrationRuntime, + IntegrationRuntimeAuthKeys, + IntegrationRuntimeComputeProperties, + IntegrationRuntimeConnectionInfo, + IntegrationRuntimeCustomSetupScriptProperties, + IntegrationRuntimeDataFlowProperties, + IntegrationRuntimeDataProxyProperties, + IntegrationRuntimeEnableinteractivequery, + IntegrationRuntimeListResponse, + IntegrationRuntimeMonitoringData, + IntegrationRuntimeNodeIpAddress, + IntegrationRuntimeNodeMonitoringData, + IntegrationRuntimeOperationStatus, + IntegrationRuntimeOutboundNetworkDependenciesCategoryEndpoint, + IntegrationRuntimeOutboundNetworkDependenciesEndpoint, + IntegrationRuntimeOutboundNetworkDependenciesEndpointDetails, + IntegrationRuntimeOutboundNetworkDependenciesEndpointsResponse, + IntegrationRuntimeRegenerateKeyParameters, + IntegrationRuntimeResource, + IntegrationRuntimeSsisCatalogInfo, + IntegrationRuntimeSsisProperties, + IntegrationRuntimeStatus, + IntegrationRuntimeStatusResponse, + IntegrationRuntimeStopOperationStatus, + IntegrationRuntimeVNetProperties, + IotHubDataConnection, + IpFirewallRuleInfo, + IpFirewallRuleInfoListResult, + IpFirewallRuleProperties, + KekIdentityProperties, + Key, + KeyInfoListResult, + KustoPool, + KustoPoolCheckNameRequest, + KustoPoolListResult, + KustoPoolPrivateLinkResources, + KustoPoolUpdate, + LanguageExtension, + LanguageExtensionsList, + LibraryInfo, + LibraryListResponse, + LibraryRequirements, + LibraryResource, + LinkedIntegrationRuntime, + LinkedIntegrationRuntimeKeyAuthorization, + LinkedIntegrationRuntimeRbacAuthorization, + LinkedIntegrationRuntimeType, + ListResourceSkusResult, + ListSqlPoolSecurityAlertPolicies, + MaintenanceWindowOptions, + MaintenanceWindowTimeRange, + MaintenanceWindows, + ManagedIdentity, + ManagedIdentitySqlControlSettingsModel, + ManagedIdentitySqlControlSettingsModelPropertiesGrantSqlControlToManagedIdentity, + ManagedIntegrationRuntime, + ManagedIntegrationRuntimeError, + ManagedIntegrationRuntimeNode, + ManagedIntegrationRuntimeOperationResult, + ManagedIntegrationRuntimeStatus, + ManagedVirtualNetworkSettings, + MetadataSyncConfig, + Operation, + OperationDisplay, + OperationListResult, + OperationMetaLogSpecification, + OperationMetaMetricDimensionSpecification, + OperationMetaMetricSpecification, + OperationMetaServiceSpecification, + OperationResource, + OptimizedAutoscale, + PipelineExternalComputeScaleProperties, + PrivateEndpoint, + PrivateEndpointConnection, + PrivateEndpointConnectionForPrivateLinkHub, + PrivateEndpointConnectionForPrivateLinkHubBasic, + PrivateEndpointConnectionForPrivateLinkHubBasicAutoGenerated, + PrivateEndpointConnectionForPrivateLinkHubResourceCollectionResponse, + PrivateEndpointConnectionList, + PrivateEndpointConnectionProperties, + PrivateLinkHub, + PrivateLinkHubInfoListResult, + PrivateLinkHubPatchInfo, + PrivateLinkResource, + PrivateLinkResourceListResult, + PrivateLinkResourceProperties, + PrivateLinkResources, + PrivateLinkServiceConnectionState, + ProxyResource, + PurviewConfiguration, + QueryInterval, + QueryMetric, + QueryStatistic, + ReadOnlyFollowingDatabase, + ReadWriteDatabase, + RecommendedSensitivityLabelUpdate, + RecommendedSensitivityLabelUpdateList, + RecoverableSqlPool, + RecoverableSqlPoolListResult, + ReplaceAllFirewallRulesOperationResponse, + ReplaceAllIpFirewallRulesRequest, + ReplicationLink, + ReplicationLinkListResult, + Resource, + RestorableDroppedSqlPool, + RestorableDroppedSqlPoolListResult, + RestorePoint, + RestorePointListResult, + SecretBase, + SecureString, + SelfHostedIntegrationRuntime, + SelfHostedIntegrationRuntimeNode, + SelfHostedIntegrationRuntimeStatus, + SensitivityLabel, + SensitivityLabelListResult, + SensitivityLabelUpdate, + SensitivityLabelUpdateList, + ServerBlobAuditingPolicy, + ServerBlobAuditingPolicyListResult, + ServerSecurityAlertPolicy, + ServerSecurityAlertPolicyListResult, + ServerUsage, + ServerUsageListResult, + ServerVulnerabilityAssessment, + ServerVulnerabilityAssessmentListResult, + Sku, + SkuDescription, + SkuDescriptionList, + SkuLocationInfoItem, + SparkConfigProperties, + SparkConfigurationListResponse, + SparkConfigurationResource, + SqlPool, + SqlPoolBlobAuditingPolicy, + SqlPoolBlobAuditingPolicyListResult, + SqlPoolBlobAuditingPolicySqlPoolOperationListResult, + SqlPoolColumn, + SqlPoolColumnListResult, + SqlPoolConnectionPolicy, + SqlPoolInfoListResult, + SqlPoolOperation, + SqlPoolPatchInfo, + SqlPoolSchema, + SqlPoolSchemaListResult, + SqlPoolSecurityAlertPolicy, + SqlPoolTable, + SqlPoolTableListResult, + SqlPoolUsage, + SqlPoolUsageListResult, + SqlPoolVulnerabilityAssessment, + SqlPoolVulnerabilityAssessmentListResult, + SqlPoolVulnerabilityAssessmentRuleBaseline, + SqlPoolVulnerabilityAssessmentRuleBaselineItem, + SqlPoolVulnerabilityAssessmentScansExport, + SsisEnvironment, + SsisEnvironmentReference, + SsisFolder, + SsisObjectMetadata, + SsisObjectMetadataListResponse, + SsisObjectMetadataStatusResponse, + SsisPackage, + SsisParameter, + SsisProject, + SsisVariable, + SubResource, + SystemData, + TableLevelSharingProperties, + TopQueries, + TopQueriesListResult, + TrackedResource, + TransparentDataEncryption, + TransparentDataEncryptionListResult, + UpdateIntegrationRuntimeNodeRequest, + UpdateIntegrationRuntimeRequest, + UserAssignedManagedIdentity, + VirtualNetworkProfile, + VulnerabilityAssessmentRecurringScansProperties, + VulnerabilityAssessmentScanError, + VulnerabilityAssessmentScanRecord, + VulnerabilityAssessmentScanRecordListResult, + WorkloadClassifier, + WorkloadClassifierListResult, + WorkloadGroup, + WorkloadGroupListResult, + Workspace, + WorkspaceAadAdminInfo, + WorkspaceInfoListResult, + WorkspaceKeyDetails, + WorkspacePatchInfo, + WorkspaceRepositoryConfiguration, +) + +from ._synapse_management_client_enums import ( # type: ignore + ActualState, + AzureADOnlyAuthenticationName, + AzureScaleType, + BlobAuditingPolicyName, + BlobAuditingPolicyState, + BlobStorageEventType, + ClusterPrincipalRole, + ColumnDataType, + Compression, + ConfigurationType, + ConnectionPolicyName, + CreateMode, + CreatedByType, + DataConnectionKind, + DataFlowComputeType, + DataMaskingFunction, + DataMaskingRuleState, + DataMaskingState, + DataWarehouseUserActivityName, + DatabasePrincipalRole, + DayOfWeek, + DedicatedSQLMinimalTlsSettingsName, + DefaultPrincipalsModificationKind, + DesiredState, + EncryptionProtectorName, + EventGridDataFormat, + EventHubDataFormat, + GeoBackupPolicyName, + GeoBackupPolicyState, + IntegrationRuntimeAuthKeyName, + IntegrationRuntimeAutoUpdate, + IntegrationRuntimeEdition, + IntegrationRuntimeEntityReferenceType, + IntegrationRuntimeInternalChannelEncryptionMode, + IntegrationRuntimeLicenseType, + IntegrationRuntimeSsisCatalogPricingTier, + IntegrationRuntimeState, + IntegrationRuntimeType, + IntegrationRuntimeUpdateResult, + IotHubDataFormat, + Kind, + LanguageExtensionName, + ManagedIntegrationRuntimeNodeStatus, + ManagementOperationState, + NodeSize, + NodeSizeFamily, + OperationStatus, + PrincipalType, + PrincipalsModificationKind, + ProvisioningState, + QueryAggregationFunction, + QueryExecutionType, + QueryMetricUnit, + QueryObservedMetricType, + Reason, + RecommendedSensitivityLabelUpdateKind, + ReplicationRole, + ReplicationState, + ResourceIdentityType, + ResourceProvisioningState, + RestorePointType, + SecurityAlertPolicyName, + SecurityAlertPolicyNameAutoGenerated, + SecurityAlertPolicyState, + SelfContainedInteractiveAuthoringState, + SelfHostedIntegrationRuntimeNodeStatus, + SensitivityLabelRank, + SensitivityLabelSource, + SensitivityLabelUpdateKind, + ServerKeyType, + SkuName, + SkuSize, + SsisObjectMetadataType, + State, + StateValue, + StorageAccountType, + TransparentDataEncryptionName, + TransparentDataEncryptionStatus, + Type, + VulnerabilityAssessmentName, + VulnerabilityAssessmentPolicyBaselineName, + VulnerabilityAssessmentScanState, + VulnerabilityAssessmentScanTriggerType, + WorkspacePublicNetworkAccess, + WorkspaceStatus, +) from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -378,6 +391,7 @@ "ClusterPrincipalAssignmentListResult", "CmdkeySetup", "ComponentSetup", + "CopyComputeScaleProperties", "CreateSqlPoolRestorePointDefinition", "CspWorkspaceAdminProperties", "CustomSetupBase", @@ -495,6 +509,7 @@ "OperationMetaServiceSpecification", "OperationResource", "OptimizedAutoscale", + "PipelineExternalComputeScaleProperties", "PrivateEndpoint", "PrivateEndpointConnection", "PrivateEndpointConnectionForPrivateLinkHub", @@ -527,7 +542,6 @@ "ReplicationLink", "ReplicationLinkListResult", "Resource", - "ResourceMoveDefinition", "RestorableDroppedSqlPool", "RestorableDroppedSqlPoolListResult", "RestorePoint", @@ -678,6 +692,7 @@ "SecurityAlertPolicyName", "SecurityAlertPolicyNameAutoGenerated", "SecurityAlertPolicyState", + "SelfContainedInteractiveAuthoringState", "SelfHostedIntegrationRuntimeNodeStatus", "SensitivityLabelRank", "SensitivityLabelSource", @@ -699,5 +714,5 @@ "WorkspacePublicNetworkAccess", "WorkspaceStatus", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/models/_models_py3.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/models/_models_py3.py index d5d582833209..e848891b2f20 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/models/_models_py3.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/models/_models_py3.py @@ -1,5 +1,5 @@ -# coding=utf-8 # pylint: disable=too-many-lines +# 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. @@ -16,10 +16,9 @@ if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from .. import models as _models JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object @@ -30,7 +29,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 @@ -66,7 +65,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 @@ -75,30 +74,14 @@ 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 AttachedDatabaseConfiguration(ProxyResource): """Class representing an attached database configuration. 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 @@ -391,7 +374,7 @@ class AzureADOnlyAuthentication(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 @@ -466,7 +449,7 @@ def __init__(self, **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.synapse.models.AzureScaleType @@ -524,7 +507,7 @@ class AzureEntityResource(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 @@ -597,7 +580,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: "Compute optimized" and "Storage optimized". :vartype name: str or ~azure.mgmt.synapse.models.SkuName @@ -669,10 +652,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 @@ -712,15 +695,15 @@ def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kw self.location = location -class BigDataPoolResourceInfo(TrackedResource): # pylint: disable=too-many-instance-attributes +class BigDataPoolResourceInfo(TrackedResource): """A Big Data pool. 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 @@ -1054,13 +1037,13 @@ def __init__( self.reason = reason -class ClusterPrincipalAssignment(ProxyResource): # pylint: disable=too-many-instance-attributes +class ClusterPrincipalAssignment(ProxyResource): """Class representing a cluster principal assignment. 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 @@ -1150,12 +1133,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 @@ -1211,7 +1194,7 @@ class CustomSetupBase(_serialization.Model): You probably want to use the sub-classes and not this class directly. Known sub-classes are: CmdkeySetup, ComponentSetup, EnvironmentVariableSetup - 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 type: The type of custom setup. Required. :vartype type: str @@ -1242,7 +1225,7 @@ def __init__(self, **kwargs: Any) -> None: class CmdkeySetup(CustomSetupBase): """The custom setup of running cmdkey commands. - 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 type: The type of custom setup. Required. :vartype type: str @@ -1287,7 +1270,7 @@ def __init__(self, *, target_name: JSON, user_name: JSON, password: "_models.Sec class ComponentSetup(CustomSetupBase): """The custom setup of installing 3rd party components. - 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 type: The type of custom setup. Required. :vartype type: str @@ -1323,10 +1306,47 @@ def __init__( self.license_key = license_key +class CopyComputeScaleProperties(_serialization.Model): + """CopyComputeScale properties for managed integration runtime. + + :ivar data_integration_unit: DIU number setting reserved for copy activity execution. Supported + values are multiples of 4 in range 4-256. + :vartype data_integration_unit: int + :ivar time_to_live: Time to live (in minutes) setting of integration runtime which will execute + copy activity. + :vartype time_to_live: int + """ + + _validation = { + "data_integration_unit": {"minimum": 4}, + "time_to_live": {"minimum": 5}, + } + + _attribute_map = { + "data_integration_unit": {"key": "dataIntegrationUnit", "type": "int"}, + "time_to_live": {"key": "timeToLive", "type": "int"}, + } + + def __init__( + self, *, data_integration_unit: Optional[int] = None, time_to_live: Optional[int] = None, **kwargs: Any + ) -> None: + """ + :keyword data_integration_unit: DIU number setting reserved for copy activity execution. + Supported values are multiples of 4 in range 4-256. + :paramtype data_integration_unit: int + :keyword time_to_live: Time to live (in minutes) setting of integration runtime which will + execute copy activity. + :paramtype time_to_live: int + """ + super().__init__(**kwargs) + self.data_integration_unit = data_integration_unit + self.time_to_live = time_to_live + + class CreateSqlPoolRestorePointDefinition(_serialization.Model): """Contains the information necessary to perform a create Sql pool restore point operation. - 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 restore_point_label: The restore point label to apply. Required. :vartype restore_point_label: str @@ -1419,10 +1439,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 @@ -1472,7 +1492,7 @@ def __init__(self, *, location: Optional[str] = None, **kwargs: Any) -> None: class DatabaseCheckNameRequest(_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 @@ -1528,13 +1548,13 @@ def __init__(self, *, value: Optional[List["_models.Database"]] = None, **kwargs self.value = value -class DatabasePrincipalAssignment(ProxyResource): # pylint: disable=too-many-instance-attributes +class DatabasePrincipalAssignment(ProxyResource): """Class representing a database principal assignment. 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 @@ -1624,12 +1644,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 @@ -1708,10 +1728,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 @@ -1769,7 +1789,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 @@ -1948,7 +1968,7 @@ class DataMaskingPolicy(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 @@ -2025,13 +2045,13 @@ def __init__( self.masking_level = None -class DataMaskingRule(ProxyResource): # pylint: disable=too-many-instance-attributes +class DataMaskingRule(ProxyResource): """Represents a Sql pool data masking rule. 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 @@ -2200,7 +2220,7 @@ class DataWarehouseUserActivities(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 @@ -2237,7 +2257,7 @@ class DedicatedSQLminimalTlsSettings(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 @@ -2398,7 +2418,7 @@ class EncryptionProtector(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 @@ -2536,7 +2556,7 @@ def __init__( class EnvironmentVariableSetup(CustomSetupBase): """The custom setup of setting environment variable. - 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 type: The type of custom setup. Required. :vartype type: str @@ -2707,15 +2727,15 @@ def __init__(self, **kwargs: Any) -> None: self.additional_info = None -class EventGridDataConnection(DataConnection): # pylint: disable=too-many-instance-attributes +class EventGridDataConnection(DataConnection): """Class representing an Event Grid data connection. Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + 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 @@ -2840,15 +2860,15 @@ def __init__( self.provisioning_state = None -class EventHubDataConnection(DataConnection): # pylint: disable=too-many-instance-attributes +class EventHubDataConnection(DataConnection): """Class representing an event hub data connection. Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + 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 @@ -2972,13 +2992,13 @@ def __init__( self.managed_identity_resource_id = managed_identity_resource_id -class ExtendedServerBlobAuditingPolicy(ProxyResource): # pylint: disable=too-many-instance-attributes +class ExtendedServerBlobAuditingPolicy(ProxyResource): """An extended server blob auditing policy. 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 @@ -3052,7 +3072,7 @@ class ExtendedServerBlobAuditingPolicy(ProxyResource): # pylint: disable=too-ma duplicate audit logs. For more information, see `Database-Level Audit Action Groups - `_. + `_. # pylint: disable=line-too-long For Database auditing policy, specific Actions can also be specified (note that Actions cannot be specified for Server auditing policy). The supported actions to audit are: @@ -3077,7 +3097,7 @@ class ExtendedServerBlobAuditingPolicy(ProxyResource): # pylint: disable=too-ma SELECT on SCHEMA::mySchema by public For more information, see `Database-Level Audit Actions - `_. + `_. # pylint: disable=line-too-long :vartype audit_actions_and_groups: list[str] :ivar storage_account_subscription_id: Specifies the blob storage subscription Id. :vartype storage_account_subscription_id: str @@ -3095,7 +3115,7 @@ class ExtendedServerBlobAuditingPolicy(ProxyResource): # pylint: disable=too-ma Diagnostic Settings URI format: PUT - https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview # pylint: disable=line-too-long For more information, see `Diagnostic Settings REST API `_ @@ -3115,7 +3135,7 @@ class ExtendedServerBlobAuditingPolicy(ProxyResource): # pylint: disable=too-ma Diagnostic Settings URI format: PUT - https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/master/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/master/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview # pylint: disable=line-too-long For more information, see `Diagnostic Settings REST API `_ @@ -3231,7 +3251,7 @@ def __init__( duplicate audit logs. For more information, see `Database-Level Audit Action Groups - `_. + `_. # pylint: disable=line-too-long For Database auditing policy, specific Actions can also be specified (note that Actions cannot be specified for Server auditing policy). The supported actions to audit are: @@ -3256,7 +3276,7 @@ def __init__( SELECT on SCHEMA::mySchema by public For more information, see `Database-Level Audit Actions - `_. + `_. # pylint: disable=line-too-long :paramtype audit_actions_and_groups: list[str] :keyword storage_account_subscription_id: Specifies the blob storage subscription Id. :paramtype storage_account_subscription_id: str @@ -3274,7 +3294,7 @@ def __init__( Diagnostic Settings URI format: PUT - https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview # pylint: disable=line-too-long For more information, see `Diagnostic Settings REST API `_ @@ -3294,7 +3314,7 @@ def __init__( Diagnostic Settings URI format: PUT - https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/master/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/master/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview # pylint: disable=line-too-long For more information, see `Diagnostic Settings REST API `_ @@ -3315,7 +3335,7 @@ def __init__( self.is_devops_audit_enabled = is_devops_audit_enabled -class ExtendedServerBlobAuditingPolicyListResult(_serialization.Model): +class ExtendedServerBlobAuditingPolicyListResult(_serialization.Model): # pylint: disable=name-too-long """A list of server extended auditing settings. Variables are only populated by the server, and will be ignored when sending a request. @@ -3343,13 +3363,13 @@ def __init__(self, **kwargs: Any) -> None: self.next_link = None -class ExtendedSqlPoolBlobAuditingPolicy(ProxyResource): # pylint: disable=too-many-instance-attributes +class ExtendedSqlPoolBlobAuditingPolicy(ProxyResource): """An extended Sql pool blob auditing policy. 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 @@ -3423,7 +3443,7 @@ class ExtendedSqlPoolBlobAuditingPolicy(ProxyResource): # pylint: disable=too-m duplicate audit logs. For more information, see `Database-Level Audit Action Groups - `_. + `_. # pylint: disable=line-too-long For Database auditing policy, specific Actions can also be specified (note that Actions cannot be specified for Server auditing policy). The supported actions to audit are: @@ -3448,7 +3468,7 @@ class ExtendedSqlPoolBlobAuditingPolicy(ProxyResource): # pylint: disable=too-m SELECT on SCHEMA::mySchema by public For more information, see `Database-Level Audit Actions - `_. + `_. # pylint: disable=line-too-long :vartype audit_actions_and_groups: list[str] :ivar storage_account_subscription_id: Specifies the blob storage subscription Id. :vartype storage_account_subscription_id: str @@ -3466,7 +3486,7 @@ class ExtendedSqlPoolBlobAuditingPolicy(ProxyResource): # pylint: disable=too-m Diagnostic Settings URI format: PUT - https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview # pylint: disable=line-too-long For more information, see `Diagnostic Settings REST API `_ @@ -3584,7 +3604,7 @@ def __init__( duplicate audit logs. For more information, see `Database-Level Audit Action Groups - `_. + `_. # pylint: disable=line-too-long For Database auditing policy, specific Actions can also be specified (note that Actions cannot be specified for Server auditing policy). The supported actions to audit are: @@ -3609,7 +3629,7 @@ def __init__( SELECT on SCHEMA::mySchema by public For more information, see `Database-Level Audit Actions - `_. + `_. # pylint: disable=line-too-long :paramtype audit_actions_and_groups: list[str] :keyword storage_account_subscription_id: Specifies the blob storage subscription Id. :paramtype storage_account_subscription_id: str @@ -3627,7 +3647,7 @@ def __init__( Diagnostic Settings URI format: PUT - https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview # pylint: disable=line-too-long For more information, see `Diagnostic Settings REST API `_ @@ -3651,7 +3671,7 @@ def __init__( self.queue_delay_ms = queue_delay_ms -class ExtendedSqlPoolBlobAuditingPolicyListResult(_serialization.Model): +class ExtendedSqlPoolBlobAuditingPolicyListResult(_serialization.Model): # pylint: disable=name-too-long """A list of sql pool extended auditing settings. Variables are only populated by the server, and will be ignored when sending a request. @@ -3684,7 +3704,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 kusto_pool_resource_id: Resource id of the cluster that follows a database owned by this cluster. Required. @@ -3751,10 +3771,10 @@ class GeoBackupPolicy(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 @@ -3851,7 +3871,7 @@ class IntegrationRuntime(_serialization.Model): You probably want to use the sub-classes and not this class directly. Known sub-classes are: ManagedIntegrationRuntime, SelfHostedIntegrationRuntime - 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 additional_properties: Unmatched properties from the message are deserialized to this collection. @@ -3942,6 +3962,13 @@ class IntegrationRuntimeComputeProperties(_serialization.Model): :vartype data_flow_properties: ~azure.mgmt.synapse.models.IntegrationRuntimeDataFlowProperties :ivar v_net_properties: VNet properties for managed integration runtime. :vartype v_net_properties: ~azure.mgmt.synapse.models.IntegrationRuntimeVNetProperties + :ivar copy_compute_scale_properties: CopyComputeScale properties for managed integration + runtime. + :vartype copy_compute_scale_properties: ~azure.mgmt.synapse.models.CopyComputeScaleProperties + :ivar pipeline_external_compute_scale_properties: PipelineExternalComputeScale properties for + managed integration runtime. + :vartype pipeline_external_compute_scale_properties: + ~azure.mgmt.synapse.models.PipelineExternalComputeScaleProperties """ _validation = { @@ -3957,6 +3984,11 @@ class IntegrationRuntimeComputeProperties(_serialization.Model): "max_parallel_executions_per_node": {"key": "maxParallelExecutionsPerNode", "type": "int"}, "data_flow_properties": {"key": "dataFlowProperties", "type": "IntegrationRuntimeDataFlowProperties"}, "v_net_properties": {"key": "vNetProperties", "type": "IntegrationRuntimeVNetProperties"}, + "copy_compute_scale_properties": {"key": "copyComputeScaleProperties", "type": "CopyComputeScaleProperties"}, + "pipeline_external_compute_scale_properties": { + "key": "pipelineExternalComputeScaleProperties", + "type": "PipelineExternalComputeScaleProperties", + }, } def __init__( @@ -3969,6 +4001,8 @@ def __init__( max_parallel_executions_per_node: Optional[int] = None, data_flow_properties: Optional["_models.IntegrationRuntimeDataFlowProperties"] = None, v_net_properties: Optional["_models.IntegrationRuntimeVNetProperties"] = None, + copy_compute_scale_properties: Optional["_models.CopyComputeScaleProperties"] = None, + pipeline_external_compute_scale_properties: Optional["_models.PipelineExternalComputeScaleProperties"] = None, **kwargs: Any ) -> None: """ @@ -3991,6 +4025,13 @@ def __init__( ~azure.mgmt.synapse.models.IntegrationRuntimeDataFlowProperties :keyword v_net_properties: VNet properties for managed integration runtime. :paramtype v_net_properties: ~azure.mgmt.synapse.models.IntegrationRuntimeVNetProperties + :keyword copy_compute_scale_properties: CopyComputeScale properties for managed integration + runtime. + :paramtype copy_compute_scale_properties: ~azure.mgmt.synapse.models.CopyComputeScaleProperties + :keyword pipeline_external_compute_scale_properties: PipelineExternalComputeScale properties + for managed integration runtime. + :paramtype pipeline_external_compute_scale_properties: + ~azure.mgmt.synapse.models.PipelineExternalComputeScaleProperties """ super().__init__(**kwargs) self.additional_properties = additional_properties @@ -4000,6 +4041,8 @@ def __init__( self.max_parallel_executions_per_node = max_parallel_executions_per_node self.data_flow_properties = data_flow_properties self.v_net_properties = v_net_properties + self.copy_compute_scale_properties = copy_compute_scale_properties + self.pipeline_external_compute_scale_properties = pipeline_external_compute_scale_properties class IntegrationRuntimeConnectionInfo(_serialization.Model): @@ -4062,7 +4105,7 @@ def __init__(self, *, additional_properties: Optional[Dict[str, JSON]] = None, * self.is_identity_cert_exprired = None -class IntegrationRuntimeCustomSetupScriptProperties(_serialization.Model): +class IntegrationRuntimeCustomSetupScriptProperties(_serialization.Model): # pylint: disable=name-too-long """Custom setup script properties for a managed dedicated integration runtime. :ivar blob_container_uri: The URI of the Azure blob container that contains the custom setup @@ -4253,7 +4296,7 @@ def __init__( class IntegrationRuntimeListResponse(_serialization.Model): """A list of integration runtime resources. - 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: List of integration runtimes. Required. :vartype value: list[~azure.mgmt.synapse.models.IntegrationRuntimeResource] @@ -4455,7 +4498,9 @@ def __init__( self.error = error -class IntegrationRuntimeOutboundNetworkDependenciesCategoryEndpoint(_serialization.Model): +class IntegrationRuntimeOutboundNetworkDependenciesCategoryEndpoint( + _serialization.Model +): # pylint: disable=name-too-long """Azure-SSIS integration runtime outbound network dependency endpoints for one category. :ivar category: The category of outbound network dependency. @@ -4489,7 +4534,7 @@ def __init__( self.endpoints = endpoints -class IntegrationRuntimeOutboundNetworkDependenciesEndpoint(_serialization.Model): +class IntegrationRuntimeOutboundNetworkDependenciesEndpoint(_serialization.Model): # pylint: disable=name-too-long """The endpoint for Azure-SSIS integration runtime outbound network dependency. :ivar domain_name: The domain name of endpoint. @@ -4526,7 +4571,9 @@ def __init__( self.endpoint_details = endpoint_details -class IntegrationRuntimeOutboundNetworkDependenciesEndpointDetails(_serialization.Model): +class IntegrationRuntimeOutboundNetworkDependenciesEndpointDetails( + _serialization.Model +): # pylint: disable=name-too-long """The details of Azure-SSIS integration runtime outbound network dependency endpoint. :ivar port: The port of endpoint. @@ -4546,7 +4593,9 @@ def __init__(self, *, port: Optional[int] = None, **kwargs: Any) -> None: self.port = port -class IntegrationRuntimeOutboundNetworkDependenciesEndpointsResponse(_serialization.Model): +class IntegrationRuntimeOutboundNetworkDependenciesEndpointsResponse( + _serialization.Model +): # pylint: disable=name-too-long """Azure-SSIS integration runtime outbound network dependency endpoints. :ivar value: The list of outbound network dependency endpoints. @@ -4573,7 +4622,7 @@ def __init__( self.value = value -class IntegrationRuntimeRegenerateKeyParameters(_serialization.Model): +class IntegrationRuntimeRegenerateKeyParameters(_serialization.Model): # pylint: disable=name-too-long """Parameters to regenerate the authentication key. :ivar key_name: The name of the authentication key to regenerate. Known values are: "authKey1" @@ -4603,7 +4652,7 @@ class SubResource(AzureEntityResource): 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 @@ -4614,34 +4663,16 @@ class SubResource(AzureEntityResource): :vartype etag: str """ - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "etag": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "etag": {"key": "etag", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - class IntegrationRuntimeResource(SubResource): """Integration runtime resource type. 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 @@ -4844,7 +4875,7 @@ class IntegrationRuntimeStatus(_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 additional_properties: Unmatched properties from the message are deserialized to this collection. @@ -4895,7 +4926,7 @@ class IntegrationRuntimeStatusResponse(_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: The integration runtime name. :vartype name: str @@ -5039,15 +5070,15 @@ def __init__( self.subnet_id = subnet_id -class IotHubDataConnection(DataConnection): # pylint: disable=too-many-instance-attributes +class IotHubDataConnection(DataConnection): """Class representing an iot hub data connection. Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + 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 @@ -5166,7 +5197,7 @@ class IpFirewallRuleInfo(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 @@ -5328,7 +5359,7 @@ class Key(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 @@ -5398,15 +5429,15 @@ def __init__( self.value = value -class KustoPool(TrackedResource): # pylint: disable=too-many-instance-attributes +class KustoPool(TrackedResource): """Class representing a Kusto kusto pool. 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 @@ -5536,7 +5567,7 @@ class KustoPoolCheckNameRequest(_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: Kusto Pool name. Required. :vartype name: str @@ -5592,7 +5623,7 @@ class KustoPoolPrivateLinkResources(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 @@ -5645,13 +5676,13 @@ def __init__(self, **kwargs: Any) -> None: self.provisioning_state = None -class KustoPoolUpdate(Resource): # pylint: disable=too-many-instance-attributes +class KustoPoolUpdate(Resource): """Class representing an update to a Kusto kusto pool. 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 @@ -5823,6 +5854,7 @@ class LibraryInfo(_serialization.Model): """ _validation = { + "uploaded_timestamp": {"readonly": True}, "provisioning_status": {"readonly": True}, "creator_id": {"readonly": True}, } @@ -5843,7 +5875,6 @@ def __init__( name: Optional[str] = None, path: Optional[str] = None, container_name: Optional[str] = None, - uploaded_timestamp: Optional[datetime.datetime] = None, type: Optional[str] = None, **kwargs: Any ) -> None: @@ -5854,8 +5885,6 @@ def __init__( :paramtype path: str :keyword container_name: Storage blob container name. :paramtype container_name: str - :keyword uploaded_timestamp: The last update time of the library. - :paramtype uploaded_timestamp: ~datetime.datetime :keyword type: Type of the library. :paramtype type: str """ @@ -5863,7 +5892,7 @@ def __init__( self.name = name self.path = path self.container_name = container_name - self.uploaded_timestamp = uploaded_timestamp + self.uploaded_timestamp = None self.type = type self.provisioning_status = None self.creator_id = None @@ -5872,7 +5901,7 @@ def __init__( class LibraryListResponse(_serialization.Model): """A list of Library resources. - 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: List of Library. Required. :vartype value: list[~azure.mgmt.synapse.models.LibraryResource] @@ -5939,13 +5968,13 @@ def __init__(self, *, content: Optional[str] = None, filename: Optional[str] = N self.filename = filename -class LibraryResource(SubResource): # pylint: disable=too-many-instance-attributes +class LibraryResource(SubResource): """Library response details. 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 @@ -5975,6 +6004,7 @@ class LibraryResource(SubResource): # pylint: disable=too-many-instance-attribu "name": {"readonly": True}, "type": {"readonly": True}, "etag": {"readonly": True}, + "uploaded_timestamp": {"readonly": True}, "provisioning_status": {"readonly": True}, "creator_id": {"readonly": True}, } @@ -5999,7 +6029,6 @@ def __init__( name_properties_name: Optional[str] = None, path: Optional[str] = None, container_name: Optional[str] = None, - uploaded_timestamp: Optional[datetime.datetime] = None, type_properties_type: Optional[str] = None, **kwargs: Any ) -> None: @@ -6010,8 +6039,6 @@ def __init__( :paramtype path: str :keyword container_name: Storage blob container name. :paramtype container_name: str - :keyword uploaded_timestamp: The last update time of the library. - :paramtype uploaded_timestamp: ~datetime.datetime :keyword type_properties_type: Type of the library. :paramtype type_properties_type: str """ @@ -6019,7 +6046,7 @@ def __init__( self.name_properties_name = name_properties_name self.path = path self.container_name = container_name - self.uploaded_timestamp = uploaded_timestamp + self.uploaded_timestamp = None self.type_properties_type = type_properties_type self.provisioning_status = None self.creator_id = None @@ -6076,7 +6103,7 @@ class LinkedIntegrationRuntimeType(_serialization.Model): You probably want to use the sub-classes and not this class directly. Known sub-classes are: LinkedIntegrationRuntimeKeyAuthorization, LinkedIntegrationRuntimeRbacAuthorization - 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 authorization_type: The authorization type for integration runtime sharing. Required. :vartype authorization_type: str @@ -6106,7 +6133,7 @@ def __init__(self, **kwargs: Any) -> None: class LinkedIntegrationRuntimeKeyAuthorization(LinkedIntegrationRuntimeType): """The key authorization type integration runtime. - 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 authorization_type: The authorization type for integration runtime sharing. Required. :vartype authorization_type: str @@ -6134,10 +6161,10 @@ def __init__(self, *, key: "_models.SecureString", **kwargs: Any) -> None: self.key = key -class LinkedIntegrationRuntimeRbacAuthorization(LinkedIntegrationRuntimeType): +class LinkedIntegrationRuntimeRbacAuthorization(LinkedIntegrationRuntimeType): # pylint: disable=name-too-long """The role based access control (RBAC) authorization type integration runtime. - 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 authorization_type: The authorization type for integration runtime sharing. Required. :vartype authorization_type: str @@ -6220,7 +6247,7 @@ class MaintenanceWindowOptions(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 @@ -6229,8 +6256,8 @@ class MaintenanceWindowOptions(ProxyResource): :vartype type: str :ivar is_enabled: Whether maintenance windows are enabled for the database. :vartype is_enabled: bool - :ivar maintenance_window_cycles: Available maintenance cycles e.g. {Saturday, 0, 48\ *60}, - {Wednesday, 0, 24*\ 60}. + :ivar maintenance_window_cycles: Available maintenance cycles e.g. {Saturday, 0, 48\\ *60}, + {Wednesday, 0, 24*\\ 60}. :vartype maintenance_window_cycles: list[~azure.mgmt.synapse.models.MaintenanceWindowTimeRange] :ivar min_duration_in_minutes: Minimum duration of maintenance window. :vartype min_duration_in_minutes: int @@ -6285,8 +6312,8 @@ def __init__( """ :keyword is_enabled: Whether maintenance windows are enabled for the database. :paramtype is_enabled: bool - :keyword maintenance_window_cycles: Available maintenance cycles e.g. {Saturday, 0, 48\ *60}, - {Wednesday, 0, 24*\ 60}. + :keyword maintenance_window_cycles: Available maintenance cycles e.g. {Saturday, 0, 48\\ *60}, + {Wednesday, 0, 24*\\ 60}. :paramtype maintenance_window_cycles: list[~azure.mgmt.synapse.models.MaintenanceWindowTimeRange] :keyword min_duration_in_minutes: Minimum duration of maintenance window. @@ -6317,7 +6344,7 @@ class MaintenanceWindows(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 @@ -6450,7 +6477,7 @@ class ManagedIdentitySqlControlSettingsModel(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 @@ -6495,7 +6522,9 @@ def __init__( self.grant_sql_control_to_managed_identity = grant_sql_control_to_managed_identity -class ManagedIdentitySqlControlSettingsModelPropertiesGrantSqlControlToManagedIdentity(_serialization.Model): +class ManagedIdentitySqlControlSettingsModelPropertiesGrantSqlControlToManagedIdentity( + _serialization.Model +): # pylint: disable=name-too-long """Grant sql control to managed identity. Variables are only populated by the server, and will be ignored when sending a request. @@ -6532,7 +6561,7 @@ class ManagedIntegrationRuntime(IntegrationRuntime): 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 additional_properties: Unmatched properties from the message are deserialized to this collection. @@ -6776,7 +6805,7 @@ class ManagedIntegrationRuntimeStatus(IntegrationRuntimeStatus): 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 additional_properties: Unmatched properties from the message are deserialized to this collection. @@ -6880,7 +6909,7 @@ class MetadataSyncConfig(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 @@ -7083,7 +7112,7 @@ def __init__( self.name = name -class OperationMetaMetricDimensionSpecification(_serialization.Model): +class OperationMetaMetricDimensionSpecification(_serialization.Model): # pylint: disable=name-too-long """What is this?. :ivar display_name: Dimension display name. @@ -7122,7 +7151,7 @@ def __init__( self.to_be_exported_for_shoebox = to_be_exported_for_shoebox -class OperationMetaMetricSpecification(_serialization.Model): # pylint: disable=too-many-instance-attributes +class OperationMetaMetricSpecification(_serialization.Model): """What is this?. :ivar source_mdm_namespace: The source MDM namespace. @@ -7333,7 +7362,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 @@ -7379,6 +7408,57 @@ def __init__(self, *, version: int, is_enabled: bool, minimum: int, maximum: int self.maximum = maximum +class PipelineExternalComputeScaleProperties(_serialization.Model): + """PipelineExternalComputeScale properties for managed integration runtime. + + :ivar time_to_live: Time to live (in minutes) setting of integration runtime which will execute + pipeline and external activity. + :vartype time_to_live: int + :ivar number_of_pipeline_nodes: Number of the pipeline nodes, which should be greater than 0 + and less than 11. + :vartype number_of_pipeline_nodes: int + :ivar number_of_external_nodes: Number of the the external nodes, which should be greater than + 0 and less than 11. + :vartype number_of_external_nodes: int + """ + + _validation = { + "time_to_live": {"minimum": 5}, + "number_of_pipeline_nodes": {"maximum": 10, "minimum": 1}, + "number_of_external_nodes": {"maximum": 10, "minimum": 1}, + } + + _attribute_map = { + "time_to_live": {"key": "timeToLive", "type": "int"}, + "number_of_pipeline_nodes": {"key": "numberOfPipelineNodes", "type": "int"}, + "number_of_external_nodes": {"key": "numberOfExternalNodes", "type": "int"}, + } + + def __init__( + self, + *, + time_to_live: Optional[int] = None, + number_of_pipeline_nodes: Optional[int] = None, + number_of_external_nodes: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword time_to_live: Time to live (in minutes) setting of integration runtime which will + execute pipeline and external activity. + :paramtype time_to_live: int + :keyword number_of_pipeline_nodes: Number of the pipeline nodes, which should be greater than 0 + and less than 11. + :paramtype number_of_pipeline_nodes: int + :keyword number_of_external_nodes: Number of the the external nodes, which should be greater + than 0 and less than 11. + :paramtype number_of_external_nodes: int + """ + super().__init__(**kwargs) + self.time_to_live = time_to_live + self.number_of_pipeline_nodes = number_of_pipeline_nodes + self.number_of_external_nodes = number_of_external_nodes + + class PrivateEndpoint(_serialization.Model): """Private endpoint details. @@ -7408,7 +7488,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 @@ -7465,7 +7545,9 @@ def __init__( self.provisioning_state = None -class PrivateEndpointConnectionForPrivateLinkHubBasicAutoGenerated(_serialization.Model): +class PrivateEndpointConnectionForPrivateLinkHubBasicAutoGenerated( + _serialization.Model +): # pylint: disable=name-too-long """PrivateEndpointConnectionForPrivateLinkHubBasicAutoGenerated. :ivar id: @@ -7497,7 +7579,9 @@ def __init__( self.properties = properties -class PrivateEndpointConnectionForPrivateLinkHub(PrivateEndpointConnectionForPrivateLinkHubBasicAutoGenerated): +class PrivateEndpointConnectionForPrivateLinkHub( + PrivateEndpointConnectionForPrivateLinkHubBasicAutoGenerated +): # pylint: disable=name-too-long """PrivateEndpointConnectionForPrivateLinkHub. :ivar id: @@ -7541,7 +7625,7 @@ def __init__( self.type = type -class PrivateEndpointConnectionForPrivateLinkHubBasic(_serialization.Model): +class PrivateEndpointConnectionForPrivateLinkHubBasic(_serialization.Model): # pylint: disable=name-too-long """Private Endpoint Connection For Private Link Hub - Basic. Variables are only populated by the server, and will be ignored when sending a request. @@ -7595,7 +7679,9 @@ def __init__( self.provisioning_state = None -class PrivateEndpointConnectionForPrivateLinkHubResourceCollectionResponse(_serialization.Model): +class PrivateEndpointConnectionForPrivateLinkHubResourceCollectionResponse( + _serialization.Model +): # pylint: disable=name-too-long """PrivateEndpointConnectionForPrivateLinkHubResourceCollectionResponse. :ivar value: @@ -7709,10 +7795,10 @@ class PrivateLinkHub(TrackedResource): 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 @@ -7826,7 +7912,7 @@ class PrivateLinkResource(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 @@ -8093,15 +8179,15 @@ def __init__(self, **kwargs: Any) -> None: self.intervals = None -class ReadOnlyFollowingDatabase(Database): # pylint: disable=too-many-instance-attributes +class ReadOnlyFollowingDatabase(Database): """Class representing a read only following database. 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 @@ -8188,15 +8274,15 @@ def __init__( self.principals_modification_kind = None -class ReadWriteDatabase(Database): # pylint: disable=too-many-instance-attributes +class ReadWriteDatabase(Database): """Class representing a read write database. 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 @@ -8283,7 +8369,7 @@ class RecommendedSensitivityLabelUpdate(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 @@ -8370,7 +8456,7 @@ class RecoverableSqlPool(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 @@ -8487,13 +8573,13 @@ def __init__( self.ip_firewall_rules = ip_firewall_rules -class ReplicationLink(ProxyResource): # pylint: disable=too-many-instance-attributes +class ReplicationLink(ProxyResource): """Represents a Sql pool replication link. 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 @@ -8608,39 +8694,13 @@ def __init__(self, *, value: Optional[List["_models.ReplicationLink"]] = None, * self.next_link = None -class ResourceMoveDefinition(_serialization.Model): - """Contains the information necessary to perform a resource move (rename). - - All required parameters must be populated in order to send to Azure. - - :ivar id: The target ID for the resource. Required. - :vartype id: str - """ - - _validation = { - "id": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: str, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: The target ID for the resource. Required. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class RestorableDroppedSqlPool(ProxyResource): # pylint: disable=too-many-instance-attributes +class RestorableDroppedSqlPool(ProxyResource): """A restorable dropped Sql pool. 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 @@ -8714,7 +8774,7 @@ def __init__(self, **kwargs: Any) -> None: class RestorableDroppedSqlPoolListResult(_serialization.Model): """The response to a list restorable dropped Sql pools 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: A list of restorable dropped Sql pools. Required. :vartype value: list[~azure.mgmt.synapse.models.RestorableDroppedSqlPool] @@ -8743,7 +8803,7 @@ class RestorePoint(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 @@ -8829,7 +8889,7 @@ class SecretBase(_serialization.Model): You probably want to use the sub-classes and not this class directly. Known sub-classes are: SecureString - 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 type: Type of the secret. Required. :vartype type: str @@ -8855,7 +8915,7 @@ class SecureString(SecretBase): """Azure Synapse secure string definition. The string value will be masked with asterisks '*' during Get or List API calls. - 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 type: Type of the secret. Required. :vartype type: str @@ -8886,7 +8946,7 @@ def __init__(self, *, value: str, **kwargs: Any) -> None: class SelfHostedIntegrationRuntime(IntegrationRuntime): """Self-hosted integration runtime. - 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 additional_properties: Unmatched properties from the message are deserialized to this collection. @@ -8898,6 +8958,11 @@ class SelfHostedIntegrationRuntime(IntegrationRuntime): :vartype description: str :ivar linked_info: Linked integration runtime type from data factory. :vartype linked_info: ~azure.mgmt.synapse.models.LinkedIntegrationRuntimeType + :ivar self_contained_interactive_authoring_enabled: An alternative option to ensure interactive + authoring function when your self-hosted integration runtime is unable to establish a + connection with Azure Relay. Known values are: True and False. + :vartype self_contained_interactive_authoring_enabled: bool or + ~azure.mgmt.synapse.models.SelfContainedInteractiveAuthoringState """ _validation = { @@ -8909,6 +8974,10 @@ class SelfHostedIntegrationRuntime(IntegrationRuntime): "type": {"key": "type", "type": "str"}, "description": {"key": "description", "type": "str"}, "linked_info": {"key": "typeProperties.linkedInfo", "type": "LinkedIntegrationRuntimeType"}, + "self_contained_interactive_authoring_enabled": { + "key": "typeProperties.selfContainedInteractiveAuthoringEnabled", + "type": "bool", + }, } def __init__( @@ -8917,6 +8986,9 @@ def __init__( additional_properties: Optional[Dict[str, JSON]] = None, description: Optional[str] = None, linked_info: Optional["_models.LinkedIntegrationRuntimeType"] = None, + self_contained_interactive_authoring_enabled: Optional[ + Union[bool, "_models.SelfContainedInteractiveAuthoringState"] + ] = None, **kwargs: Any ) -> None: """ @@ -8927,13 +8999,19 @@ def __init__( :paramtype description: str :keyword linked_info: Linked integration runtime type from data factory. :paramtype linked_info: ~azure.mgmt.synapse.models.LinkedIntegrationRuntimeType + :keyword self_contained_interactive_authoring_enabled: An alternative option to ensure + interactive authoring function when your self-hosted integration runtime is unable to establish + a connection with Azure Relay. Known values are: True and False. + :paramtype self_contained_interactive_authoring_enabled: bool or + ~azure.mgmt.synapse.models.SelfContainedInteractiveAuthoringState """ super().__init__(additional_properties=additional_properties, description=description, **kwargs) self.type: str = "SelfHosted" self.linked_info = linked_info + self.self_contained_interactive_authoring_enabled = self_contained_interactive_authoring_enabled -class SelfHostedIntegrationRuntimeNode(_serialization.Model): # pylint: disable=too-many-instance-attributes +class SelfHostedIntegrationRuntimeNode(_serialization.Model): """Properties of Self-hosted integration runtime node. Variables are only populated by the server, and will be ignored when sending a request. @@ -9055,12 +9133,12 @@ def __init__(self, *, additional_properties: Optional[Dict[str, JSON]] = None, * self.max_concurrent_jobs = None -class SelfHostedIntegrationRuntimeStatus(IntegrationRuntimeStatus): # pylint: disable=too-many-instance-attributes +class SelfHostedIntegrationRuntimeStatus(IntegrationRuntimeStatus): """Self-hosted integration runtime status. 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 additional_properties: Unmatched properties from the message are deserialized to this collection. @@ -9121,6 +9199,15 @@ class SelfHostedIntegrationRuntimeStatus(IntegrationRuntimeStatus): # pylint: d :vartype service_region: str :ivar newer_versions: The newer versions on download center. :vartype newer_versions: list[str] + :ivar os_type: + :vartype os_type: int + :ivar target_framework: + :vartype target_framework: int + :ivar self_contained_interactive_authoring_enabled: An alternative option to ensure interactive + authoring function when your self-hosted integration runtime is unable to establish a + connection with Azure Relay. Known values are: True and False. + :vartype self_contained_interactive_authoring_enabled: bool or + ~azure.mgmt.synapse.models.SelfContainedInteractiveAuthoringState """ _validation = { @@ -9142,6 +9229,9 @@ class SelfHostedIntegrationRuntimeStatus(IntegrationRuntimeStatus): # pylint: d "pushed_version": {"readonly": True}, "latest_version": {"readonly": True}, "auto_update_eta": {"readonly": True}, + "os_type": {"readonly": True}, + "target_framework": {"readonly": True}, + "self_contained_interactive_authoring_enabled": {"readonly": True}, } _attribute_map = { @@ -9171,9 +9261,15 @@ class SelfHostedIntegrationRuntimeStatus(IntegrationRuntimeStatus): # pylint: d "auto_update_eta": {"key": "typeProperties.autoUpdateETA", "type": "iso-8601"}, "service_region": {"key": "typeProperties.serviceRegion", "type": "str"}, "newer_versions": {"key": "typeProperties.newerVersions", "type": "[str]"}, + "os_type": {"key": "typeProperties.osType", "type": "int"}, + "target_framework": {"key": "typeProperties.targetFramework", "type": "int"}, + "self_contained_interactive_authoring_enabled": { + "key": "typeProperties.selfContainedInteractiveAuthoringEnabled", + "type": "bool", + }, } - def __init__( + def __init__( # pylint: disable=too-many-locals self, *, additional_properties: Optional[Dict[str, JSON]] = None, @@ -9218,15 +9314,18 @@ def __init__( self.auto_update_eta = None self.service_region = service_region self.newer_versions = newer_versions + self.os_type = None + self.target_framework = None + self.self_contained_interactive_authoring_enabled = None -class SensitivityLabel(ProxyResource): # pylint: disable=too-many-instance-attributes +class SensitivityLabel(ProxyResource): """A sensitivity label. 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 @@ -9353,7 +9452,7 @@ class SensitivityLabelUpdate(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 @@ -9439,13 +9538,13 @@ def __init__(self, *, operations: Optional[List["_models.SensitivityLabelUpdate" self.operations = operations -class ServerBlobAuditingPolicy(ProxyResource): # pylint: disable=too-many-instance-attributes +class ServerBlobAuditingPolicy(ProxyResource): """A server blob auditing policy. 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 @@ -9517,7 +9616,7 @@ class ServerBlobAuditingPolicy(ProxyResource): # pylint: disable=too-many-insta duplicate audit logs. For more information, see `Database-Level Audit Action Groups - `_. + `_. # pylint: disable=line-too-long For Database auditing policy, specific Actions can also be specified (note that Actions cannot be specified for Server auditing policy). The supported actions to audit are: @@ -9542,7 +9641,7 @@ class ServerBlobAuditingPolicy(ProxyResource): # pylint: disable=too-many-insta SELECT on SCHEMA::mySchema by public For more information, see `Database-Level Audit Actions - `_. + `_. # pylint: disable=line-too-long :vartype audit_actions_and_groups: list[str] :ivar storage_account_subscription_id: Specifies the blob storage subscription Id. :vartype storage_account_subscription_id: str @@ -9560,7 +9659,7 @@ class ServerBlobAuditingPolicy(ProxyResource): # pylint: disable=too-many-insta Diagnostic Settings URI format: PUT - https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview # pylint: disable=line-too-long For more information, see `Diagnostic Settings REST API `_ @@ -9580,7 +9679,7 @@ class ServerBlobAuditingPolicy(ProxyResource): # pylint: disable=too-many-insta Diagnostic Settings URI format: PUT - https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/master/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/master/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview # pylint: disable=line-too-long For more information, see `Diagnostic Settings REST API `_ @@ -9692,7 +9791,7 @@ def __init__( duplicate audit logs. For more information, see `Database-Level Audit Action Groups - `_. + `_. # pylint: disable=line-too-long For Database auditing policy, specific Actions can also be specified (note that Actions cannot be specified for Server auditing policy). The supported actions to audit are: @@ -9717,7 +9816,7 @@ def __init__( SELECT on SCHEMA::mySchema by public For more information, see `Database-Level Audit Actions - `_. + `_. # pylint: disable=line-too-long :paramtype audit_actions_and_groups: list[str] :keyword storage_account_subscription_id: Specifies the blob storage subscription Id. :paramtype storage_account_subscription_id: str @@ -9735,7 +9834,7 @@ def __init__( Diagnostic Settings URI format: PUT - https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview # pylint: disable=line-too-long For more information, see `Diagnostic Settings REST API `_ @@ -9755,7 +9854,7 @@ def __init__( Diagnostic Settings URI format: PUT - https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/master/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/master/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview # pylint: disable=line-too-long For more information, see `Diagnostic Settings REST API `_ @@ -9803,13 +9902,13 @@ def __init__(self, **kwargs: Any) -> None: self.next_link = None -class ServerSecurityAlertPolicy(ProxyResource): # pylint: disable=too-many-instance-attributes +class ServerSecurityAlertPolicy(ProxyResource): """Workspace managed Sql server security alert policy. 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 @@ -9993,7 +10092,7 @@ class ServerUsageListResult(_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 value: The list of server metrics for the server. Required. :vartype value: list[~azure.mgmt.synapse.models.ServerUsage] @@ -10027,7 +10126,7 @@ class ServerVulnerabilityAssessment(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 @@ -10239,7 +10338,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 @@ -10322,7 +10421,7 @@ def __init__( class SparkConfigurationListResponse(_serialization.Model): """A list of SparkConfiguration resources. - 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: List of SparkConfiguration. Required. :vartype value: list[~azure.mgmt.synapse.models.SparkConfigurationResource] @@ -10353,15 +10452,15 @@ def __init__( self.next_link = next_link -class SparkConfigurationResource(SubResource): # pylint: disable=too-many-instance-attributes +class SparkConfigurationResource(SubResource): """SparkConfiguration response details. 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 @@ -10446,15 +10545,15 @@ def __init__( self.config_merge_rule = config_merge_rule -class SqlPool(TrackedResource): # pylint: disable=too-many-instance-attributes +class SqlPool(TrackedResource): """A SQL Analytics pool. 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 @@ -10608,13 +10707,13 @@ def __init__( self.source_database_deletion_date = source_database_deletion_date -class SqlPoolBlobAuditingPolicy(ProxyResource): # pylint: disable=too-many-instance-attributes +class SqlPoolBlobAuditingPolicy(ProxyResource): """A Sql pool blob auditing policy. 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 @@ -10677,7 +10776,7 @@ class SqlPoolBlobAuditingPolicy(ProxyResource): # pylint: disable=too-many-inst duplicate audit logs. For more information, see `Database-Level Audit Action Groups - `_. + `_. # pylint: disable=line-too-long For Database auditing policy, specific Actions can also be specified (note that Actions cannot be specified for Server auditing policy). The supported actions to audit are: @@ -10702,7 +10801,7 @@ class SqlPoolBlobAuditingPolicy(ProxyResource): # pylint: disable=too-many-inst SELECT on SCHEMA::mySchema by public For more information, see `Database-Level Audit Actions - `_. + `_. # pylint: disable=line-too-long :vartype audit_actions_and_groups: list[str] :ivar storage_account_subscription_id: Specifies the blob storage subscription Id. :vartype storage_account_subscription_id: str @@ -10720,7 +10819,7 @@ class SqlPoolBlobAuditingPolicy(ProxyResource): # pylint: disable=too-many-inst Diagnostic Settings URI format: PUT - https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview # pylint: disable=line-too-long For more information, see `Diagnostic Settings REST API `_ @@ -10819,7 +10918,7 @@ def __init__( duplicate audit logs. For more information, see `Database-Level Audit Action Groups - `_. + `_. # pylint: disable=line-too-long For Database auditing policy, specific Actions can also be specified (note that Actions cannot be specified for Server auditing policy). The supported actions to audit are: @@ -10844,7 +10943,7 @@ def __init__( SELECT on SCHEMA::mySchema by public For more information, see `Database-Level Audit Actions - `_. + `_. # pylint: disable=line-too-long :paramtype audit_actions_and_groups: list[str] :keyword storage_account_subscription_id: Specifies the blob storage subscription Id. :paramtype storage_account_subscription_id: str @@ -10862,7 +10961,7 @@ def __init__( Diagnostic Settings URI format: PUT - https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview + https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/providers/microsoft.insights/diagnosticSettings/{settingsName}?api-version=2017-05-01-preview # pylint: disable=line-too-long For more information, see `Diagnostic Settings REST API `_ @@ -10909,7 +11008,7 @@ def __init__(self, **kwargs: Any) -> None: self.next_link = None -class SqlPoolBlobAuditingPolicySqlPoolOperationListResult(_serialization.Model): +class SqlPoolBlobAuditingPolicySqlPoolOperationListResult(_serialization.Model): # pylint: disable=name-too-long """The response to a list Sql pool operations request. Variables are only populated by the server, and will be ignored when sending a request. @@ -10943,7 +11042,7 @@ class SqlPoolColumn(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 @@ -10954,7 +11053,7 @@ class SqlPoolColumn(ProxyResource): "date", "time", "datetime2", "datetimeoffset", "tinyint", "smallint", "int", "smalldatetime", "real", "money", "datetime", "float", "sql_variant", "ntext", "bit", "decimal", "numeric", "smallmoney", "bigint", "hierarchyid", "geometry", "geography", "varbinary", "varchar", - "binary", "char", "timestamp", "nvarchar", "nchar", "xml", and "sysname". + "binary", "char", "timestamp", "nvarchar", "nchar", "xml", "sysname", and "int". :vartype column_type: str or ~azure.mgmt.synapse.models.ColumnDataType :ivar is_computed: Indicates whether column value is computed or not. :vartype is_computed: bool @@ -10981,8 +11080,8 @@ def __init__(self, *, column_type: Optional[Union[str, "_models.ColumnDataType"] "uniqueidentifier", "date", "time", "datetime2", "datetimeoffset", "tinyint", "smallint", "int", "smalldatetime", "real", "money", "datetime", "float", "sql_variant", "ntext", "bit", "decimal", "numeric", "smallmoney", "bigint", "hierarchyid", "geometry", "geography", - "varbinary", "varchar", "binary", "char", "timestamp", "nvarchar", "nchar", "xml", and - "sysname". + "varbinary", "varchar", "binary", "char", "timestamp", "nvarchar", "nchar", "xml", "sysname", + and "int". :paramtype column_type: str or ~azure.mgmt.synapse.models.ColumnDataType """ super().__init__(**kwargs) @@ -11018,13 +11117,13 @@ def __init__(self, **kwargs: Any) -> None: self.next_link = None -class SqlPoolConnectionPolicy(ProxyResource): # pylint: disable=too-many-instance-attributes +class SqlPoolConnectionPolicy(ProxyResource): """A Sql pool connection policy. 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 @@ -11142,13 +11241,13 @@ def __init__( self.value = value -class SqlPoolOperation(ProxyResource): # pylint: disable=too-many-instance-attributes +class SqlPoolOperation(ProxyResource): """A Sql pool operation. 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 @@ -11245,7 +11344,7 @@ def __init__(self, **kwargs: Any) -> None: self.is_cancellable = None -class SqlPoolPatchInfo(_serialization.Model): # pylint: disable=too-many-instance-attributes +class SqlPoolPatchInfo(_serialization.Model): """A SQL Analytics pool patch info. Variables are only populated by the server, and will be ignored when sending a request. @@ -11398,7 +11497,7 @@ class SqlPoolSchema(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 @@ -11407,22 +11506,6 @@ class SqlPoolSchema(ProxyResource): :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 SqlPoolSchemaListResult(_serialization.Model): """A list of Sql pool schemas. @@ -11452,13 +11535,13 @@ def __init__(self, **kwargs: Any) -> None: self.next_link = None -class SqlPoolSecurityAlertPolicy(ProxyResource): # pylint: disable=too-many-instance-attributes +class SqlPoolSecurityAlertPolicy(ProxyResource): """A Sql pool security alert policy. 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 @@ -11562,7 +11645,7 @@ class SqlPoolTable(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 @@ -11571,22 +11654,6 @@ class SqlPoolTable(ProxyResource): :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 SqlPoolTableListResult(_serialization.Model): """A list of Sql pool tables. @@ -11674,7 +11741,7 @@ class SqlPoolUsageListResult(_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 value: The list of usages for the Sql pool. Required. :vartype value: list[~azure.mgmt.synapse.models.SqlPoolUsage] @@ -11708,7 +11775,7 @@ class SqlPoolVulnerabilityAssessment(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 @@ -11812,13 +11879,13 @@ def __init__(self, **kwargs: Any) -> None: self.next_link = None -class SqlPoolVulnerabilityAssessmentRuleBaseline(ProxyResource): +class SqlPoolVulnerabilityAssessmentRuleBaseline(ProxyResource): # pylint: disable=name-too-long """A Sql pool vulnerability assessment rule baseline. 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 @@ -11861,10 +11928,10 @@ def __init__( self.baseline_results = baseline_results -class SqlPoolVulnerabilityAssessmentRuleBaselineItem(_serialization.Model): +class SqlPoolVulnerabilityAssessmentRuleBaselineItem(_serialization.Model): # pylint: disable=name-too-long """Properties for an Sql pool vulnerability assessment rule baseline's result. - 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 result: The rule baseline result. Required. :vartype result: list[str] @@ -11887,13 +11954,13 @@ def __init__(self, *, result: List[str], **kwargs: Any) -> None: self.result = result -class SqlPoolVulnerabilityAssessmentScansExport(ProxyResource): +class SqlPoolVulnerabilityAssessmentScansExport(ProxyResource): # pylint: disable=name-too-long """A Sql pool Vulnerability Assessment scan export 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 @@ -11931,7 +11998,7 @@ class SsisObjectMetadata(_serialization.Model): You probably want to use the sub-classes and not this class directly. Known sub-classes are: SsisEnvironment, SsisFolder, SsisPackage, SsisProject - 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 type: Type of metadata. Required. Known values are: "Folder", "Project", "Package", and "Environment". @@ -11990,7 +12057,7 @@ def __init__( class SsisEnvironment(SsisObjectMetadata): """Ssis environment. - 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 type: Type of metadata. Required. Known values are: "Folder", "Project", "Package", and "Environment". @@ -12097,7 +12164,7 @@ def __init__( class SsisFolder(SsisObjectMetadata): """Ssis folder. - 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 type: Type of metadata. Required. Known values are: "Folder", "Project", "Package", and "Environment". @@ -12222,7 +12289,7 @@ def __init__( class SsisPackage(SsisObjectMetadata): """Ssis Package. - 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 type: Type of metadata. Required. Known values are: "Folder", "Project", "Package", and "Environment". @@ -12294,7 +12361,7 @@ def __init__( self.parameters = parameters -class SsisParameter(_serialization.Model): # pylint: disable=too-many-instance-attributes +class SsisParameter(_serialization.Model): """Ssis parameter. :ivar id: Parameter id. @@ -12399,7 +12466,7 @@ def __init__( class SsisProject(SsisObjectMetadata): """Ssis project. - 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 type: Type of metadata. Required. Known values are: "Folder", "Project", "Package", and "Environment". @@ -12732,7 +12799,7 @@ def __init__(self, **kwargs: Any) -> None: class TopQueriesListResult(_serialization.Model): """Represents the response to a get top queries 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: The list of top queries. Required. :vartype value: list[~azure.mgmt.synapse.models.TopQueries] @@ -12761,7 +12828,7 @@ class TransparentDataEncryption(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 @@ -12942,7 +13009,7 @@ def __init__(self, *, compute_subnet_id: Optional[str] = None, **kwargs: Any) -> self.compute_subnet_id = compute_subnet_id -class VulnerabilityAssessmentRecurringScansProperties(_serialization.Model): +class VulnerabilityAssessmentRecurringScansProperties(_serialization.Model): # pylint: disable=name-too-long """Properties of a Vulnerability Assessment recurring scans. :ivar is_enabled: Recurring scans state. @@ -13011,13 +13078,13 @@ def __init__(self, **kwargs: Any) -> None: self.message = None -class VulnerabilityAssessmentScanRecord(ProxyResource): # pylint: disable=too-many-instance-attributes +class VulnerabilityAssessmentScanRecord(ProxyResource): """A vulnerability assessment scan record. 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 @@ -13084,7 +13151,7 @@ def __init__(self, **kwargs: Any) -> None: self.number_of_failed_security_checks = None -class VulnerabilityAssessmentScanRecordListResult(_serialization.Model): +class VulnerabilityAssessmentScanRecordListResult(_serialization.Model): # pylint: disable=name-too-long """A list of vulnerability assessment scan records. Variables are only populated by the server, and will be ignored when sending a request. @@ -13118,7 +13185,7 @@ class WorkloadClassifier(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 @@ -13225,7 +13292,7 @@ class WorkloadGroup(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 @@ -13326,15 +13393,15 @@ def __init__(self, **kwargs: Any) -> None: self.next_link = None -class Workspace(TrackedResource): # pylint: disable=too-many-instance-attributes +class Workspace(TrackedResource): """A workspace. 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 @@ -13375,7 +13442,7 @@ class Workspace(TrackedResource): # pylint: disable=too-many-instance-attribute :ivar workspace_uid: The workspace unique identifier. :vartype workspace_uid: str :ivar extra_properties: Workspace level configs and feature flags. - :vartype extra_properties: dict[str, JSON] + :vartype extra_properties: JSON :ivar managed_virtual_network_settings: Managed Virtual Network Settings. :vartype managed_virtual_network_settings: ~azure.mgmt.synapse.models.ManagedVirtualNetworkSettings @@ -13407,6 +13474,7 @@ class Workspace(TrackedResource): # pylint: disable=too-many-instance-attribute "type": {"readonly": True}, "location": {"required": True}, "provisioning_state": {"readonly": True}, + "connectivity_endpoints": {"readonly": True}, "workspace_uid": {"readonly": True}, "extra_properties": {"readonly": True}, "adla_resource_id": {"readonly": True}, @@ -13437,7 +13505,7 @@ class Workspace(TrackedResource): # pylint: disable=too-many-instance-attribute }, "encryption": {"key": "properties.encryption", "type": "EncryptionDetails"}, "workspace_uid": {"key": "properties.workspaceUID", "type": "str"}, - "extra_properties": {"key": "properties.extraProperties", "type": "{object}"}, + "extra_properties": {"key": "properties.extraProperties", "type": "object"}, "managed_virtual_network_settings": { "key": "properties.managedVirtualNetworkSettings", "type": "ManagedVirtualNetworkSettings", @@ -13469,7 +13537,6 @@ def __init__( # pylint: disable=too-many-locals managed_resource_group_name: Optional[str] = None, sql_administrator_login: Optional[str] = None, virtual_network_profile: Optional["_models.VirtualNetworkProfile"] = None, - connectivity_endpoints: Optional[Dict[str, str]] = None, managed_virtual_network: Optional[str] = None, private_endpoint_connections: Optional[List["_models.PrivateEndpointConnection"]] = None, encryption: Optional["_models.EncryptionDetails"] = None, @@ -13502,8 +13569,6 @@ def __init__( # pylint: disable=too-many-locals :paramtype sql_administrator_login: str :keyword virtual_network_profile: Virtual Network profile. :paramtype virtual_network_profile: ~azure.mgmt.synapse.models.VirtualNetworkProfile - :keyword connectivity_endpoints: Connectivity endpoints. - :paramtype connectivity_endpoints: dict[str, str] :keyword managed_virtual_network: Setting this to 'default' will ensure that all compute for this workspace is in a virtual network managed on behalf of the user. :paramtype managed_virtual_network: str @@ -13542,7 +13607,7 @@ def __init__( # pylint: disable=too-many-locals self.provisioning_state = None self.sql_administrator_login = sql_administrator_login self.virtual_network_profile = virtual_network_profile - self.connectivity_endpoints = connectivity_endpoints + self.connectivity_endpoints = None self.managed_virtual_network = managed_virtual_network self.private_endpoint_connections = private_endpoint_connections self.encryption = encryption @@ -13565,7 +13630,7 @@ class WorkspaceAadAdminInfo(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 @@ -13781,7 +13846,7 @@ class WorkspaceRepositoryConfiguration(_serialization.Model): :ivar type: Type of workspace repositoryID configuration. Example WorkspaceVSTSConfiguration, WorkspaceGitHubConfiguration. :vartype type: str - :ivar host_name: GitHub Enterprise host name. For example: https://github.mydomain.com. + :ivar host_name: GitHub Enterprise host name. For example: ``https://github.mydomain.com``. :vartype host_name: str :ivar account_name: Account name. :vartype account_name: str @@ -13829,7 +13894,7 @@ def __init__( :keyword type: Type of workspace repositoryID configuration. Example WorkspaceVSTSConfiguration, WorkspaceGitHubConfiguration. :paramtype type: str - :keyword host_name: GitHub Enterprise host name. For example: https://github.mydomain.com. + :keyword host_name: GitHub Enterprise host name. For example: ``https://github.mydomain.com``. :paramtype host_name: str :keyword account_name: Account name. :paramtype account_name: str diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/models/_synapse_management_client_enums.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/models/_synapse_management_client_enums.py index 7377b4791d10..c3c959408584 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/models/_synapse_management_client_enums.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/models/_synapse_management_client_enums.py @@ -100,6 +100,7 @@ class ColumnDataType(str, Enum, metaclass=CaseInsensitiveEnumMeta): NCHAR = "nchar" XML = "xml" SYSNAME = "sysname" + INT_ENUM = "int" class Compression(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -626,6 +627,15 @@ class SecurityAlertPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): DISABLED = "Disabled" +class SelfContainedInteractiveAuthoringState(bool, Enum, metaclass=CaseInsensitiveEnumMeta): + """An alternative option to ensure interactive authoring function when your self-hosted + integration runtime is unable to establish a connection with Azure Relay. + """ + + TRUE = True + FALSE = False + + class SelfHostedIntegrationRuntimeNodeStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Status of the integration runtime node.""" diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/__init__.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/__init__.py index b1719c4e0458..582500f84839 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/__init__.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/__init__.py @@ -5,105 +5,91 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._azure_ad_only_authentications_operations import AzureADOnlyAuthenticationsOperations -from ._operations import Operations -from ._ip_firewall_rules_operations import IpFirewallRulesOperations -from ._keys_operations import KeysOperations -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations -from ._private_link_resources_operations import PrivateLinkResourcesOperations -from ._private_link_hub_private_link_resources_operations import PrivateLinkHubPrivateLinkResourcesOperations -from ._private_link_hubs_operations import PrivateLinkHubsOperations -from ._private_endpoint_connections_private_link_hub_operations import ( - PrivateEndpointConnectionsPrivateLinkHubOperations, -) -from ._sql_pools_operations import SqlPoolsOperations -from ._sql_pool_metadata_sync_configs_operations import SqlPoolMetadataSyncConfigsOperations -from ._sql_pool_operation_results_operations import SqlPoolOperationResultsOperations -from ._sql_pool_geo_backup_policies_operations import SqlPoolGeoBackupPoliciesOperations -from ._sql_pool_data_warehouse_user_activities_operations import SqlPoolDataWarehouseUserActivitiesOperations -from ._sql_pool_restore_points_operations import SqlPoolRestorePointsOperations -from ._sql_pool_replication_links_operations import SqlPoolReplicationLinksOperations -from ._sql_pool_maintenance_windows_operations import SqlPoolMaintenanceWindowsOperations -from ._sql_pool_maintenance_window_options_operations import SqlPoolMaintenanceWindowOptionsOperations -from ._sql_pool_transparent_data_encryptions_operations import SqlPoolTransparentDataEncryptionsOperations -from ._sql_pool_blob_auditing_policies_operations import SqlPoolBlobAuditingPoliciesOperations -from ._sql_pool_operations_operations import SqlPoolOperationsOperations -from ._sql_pool_usages_operations import SqlPoolUsagesOperations -from ._sql_pool_sensitivity_labels_operations import SqlPoolSensitivityLabelsOperations -from ._sql_pool_recommended_sensitivity_labels_operations import SqlPoolRecommendedSensitivityLabelsOperations -from ._sql_pool_schemas_operations import SqlPoolSchemasOperations -from ._sql_pool_tables_operations import SqlPoolTablesOperations -from ._sql_pool_table_columns_operations import SqlPoolTableColumnsOperations -from ._sql_pool_connection_policies_operations import SqlPoolConnectionPoliciesOperations -from ._sql_pool_vulnerability_assessments_operations import SqlPoolVulnerabilityAssessmentsOperations -from ._sql_pool_vulnerability_assessment_scans_operations import SqlPoolVulnerabilityAssessmentScansOperations -from ._sql_pool_security_alert_policies_operations import SqlPoolSecurityAlertPoliciesOperations -from ._sql_pool_vulnerability_assessment_rule_baselines_operations import ( - SqlPoolVulnerabilityAssessmentRuleBaselinesOperations, -) -from ._extended_sql_pool_blob_auditing_policies_operations import ExtendedSqlPoolBlobAuditingPoliciesOperations -from ._data_masking_policies_operations import DataMaskingPoliciesOperations -from ._data_masking_rules_operations import DataMaskingRulesOperations -from ._sql_pool_columns_operations import SqlPoolColumnsOperations -from ._sql_pool_workload_group_operations import SqlPoolWorkloadGroupOperations -from ._sql_pool_workload_classifier_operations import SqlPoolWorkloadClassifierOperations -from ._workspace_managed_sql_server_blob_auditing_policies_operations import ( - WorkspaceManagedSqlServerBlobAuditingPoliciesOperations, -) -from ._workspace_managed_sql_server_extended_blob_auditing_policies_operations import ( - WorkspaceManagedSqlServerExtendedBlobAuditingPoliciesOperations, -) -from ._workspace_managed_sql_server_security_alert_policy_operations import ( - WorkspaceManagedSqlServerSecurityAlertPolicyOperations, -) -from ._workspace_managed_sql_server_vulnerability_assessments_operations import ( - WorkspaceManagedSqlServerVulnerabilityAssessmentsOperations, -) -from ._workspace_managed_sql_server_encryption_protector_operations import ( - WorkspaceManagedSqlServerEncryptionProtectorOperations, -) -from ._workspace_managed_sql_server_usages_operations import WorkspaceManagedSqlServerUsagesOperations -from ._workspace_managed_sql_server_recoverable_sql_pools_operations import ( - WorkspaceManagedSqlServerRecoverableSqlPoolsOperations, -) -from ._workspace_managed_sql_server_dedicated_sql_minimal_tls_settings_operations import ( - WorkspaceManagedSqlServerDedicatedSQLMinimalTlsSettingsOperations, -) -from ._workspaces_operations import WorkspacesOperations -from ._workspace_aad_admins_operations import WorkspaceAadAdminsOperations -from ._workspace_sql_aad_admins_operations import WorkspaceSqlAadAdminsOperations -from ._workspace_managed_identity_sql_control_settings_operations import ( - WorkspaceManagedIdentitySqlControlSettingsOperations, -) -from ._restorable_dropped_sql_pools_operations import RestorableDroppedSqlPoolsOperations -from ._big_data_pools_operations import BigDataPoolsOperations -from ._library_operations import LibraryOperations -from ._libraries_operations import LibrariesOperations -from ._integration_runtimes_operations import IntegrationRuntimesOperations -from ._integration_runtime_node_ip_address_operations import IntegrationRuntimeNodeIpAddressOperations -from ._integration_runtime_object_metadata_operations import IntegrationRuntimeObjectMetadataOperations -from ._integration_runtime_nodes_operations import IntegrationRuntimeNodesOperations -from ._integration_runtime_credentials_operations import IntegrationRuntimeCredentialsOperations -from ._integration_runtime_connection_infos_operations import IntegrationRuntimeConnectionInfosOperations -from ._integration_runtime_auth_keys_operations import IntegrationRuntimeAuthKeysOperations -from ._integration_runtime_monitoring_data_operations import IntegrationRuntimeMonitoringDataOperations -from ._integration_runtime_status_operations import IntegrationRuntimeStatusOperations -from ._get_operations import GetOperations -from ._spark_configuration_operations import SparkConfigurationOperations -from ._spark_configurations_operations import SparkConfigurationsOperations -from ._kusto_operations_operations import KustoOperationsOperations -from ._kusto_pools_operations import KustoPoolsOperations -from ._kusto_pool_child_resource_operations import KustoPoolChildResourceOperations -from ._kusto_pool_attached_database_configurations_operations import KustoPoolAttachedDatabaseConfigurationsOperations -from ._kusto_pool_databases_operations import KustoPoolDatabasesOperations -from ._kusto_pool_data_connections_operations import KustoPoolDataConnectionsOperations -from ._kusto_pool_principal_assignments_operations import KustoPoolPrincipalAssignmentsOperations -from ._kusto_pool_database_principal_assignments_operations import KustoPoolDatabasePrincipalAssignmentsOperations -from ._kusto_pool_private_link_resources_operations import KustoPoolPrivateLinkResourcesOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._azure_ad_only_authentications_operations import AzureADOnlyAuthenticationsOperations # type: ignore +from ._operations import Operations # type: ignore +from ._ip_firewall_rules_operations import IpFirewallRulesOperations # type: ignore +from ._keys_operations import KeysOperations # type: ignore +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore +from ._private_link_resources_operations import PrivateLinkResourcesOperations # type: ignore +from ._private_link_hub_private_link_resources_operations import PrivateLinkHubPrivateLinkResourcesOperations # type: ignore +from ._private_link_hubs_operations import PrivateLinkHubsOperations # type: ignore +from ._private_endpoint_connections_private_link_hub_operations import PrivateEndpointConnectionsPrivateLinkHubOperations # type: ignore +from ._sql_pools_operations import SqlPoolsOperations # type: ignore +from ._sql_pool_metadata_sync_configs_operations import SqlPoolMetadataSyncConfigsOperations # type: ignore +from ._sql_pool_operation_results_operations import SqlPoolOperationResultsOperations # type: ignore +from ._sql_pool_geo_backup_policies_operations import SqlPoolGeoBackupPoliciesOperations # type: ignore +from ._sql_pool_data_warehouse_user_activities_operations import SqlPoolDataWarehouseUserActivitiesOperations # type: ignore +from ._sql_pool_restore_points_operations import SqlPoolRestorePointsOperations # type: ignore +from ._sql_pool_replication_links_operations import SqlPoolReplicationLinksOperations # type: ignore +from ._sql_pool_maintenance_windows_operations import SqlPoolMaintenanceWindowsOperations # type: ignore +from ._sql_pool_maintenance_window_options_operations import SqlPoolMaintenanceWindowOptionsOperations # type: ignore +from ._sql_pool_transparent_data_encryptions_operations import SqlPoolTransparentDataEncryptionsOperations # type: ignore +from ._sql_pool_blob_auditing_policies_operations import SqlPoolBlobAuditingPoliciesOperations # type: ignore +from ._sql_pool_operations_operations import SqlPoolOperationsOperations # type: ignore +from ._sql_pool_usages_operations import SqlPoolUsagesOperations # type: ignore +from ._sql_pool_sensitivity_labels_operations import SqlPoolSensitivityLabelsOperations # type: ignore +from ._sql_pool_recommended_sensitivity_labels_operations import SqlPoolRecommendedSensitivityLabelsOperations # type: ignore +from ._sql_pool_schemas_operations import SqlPoolSchemasOperations # type: ignore +from ._sql_pool_tables_operations import SqlPoolTablesOperations # type: ignore +from ._sql_pool_table_columns_operations import SqlPoolTableColumnsOperations # type: ignore +from ._sql_pool_connection_policies_operations import SqlPoolConnectionPoliciesOperations # type: ignore +from ._sql_pool_vulnerability_assessments_operations import SqlPoolVulnerabilityAssessmentsOperations # type: ignore +from ._sql_pool_vulnerability_assessment_scans_operations import SqlPoolVulnerabilityAssessmentScansOperations # type: ignore +from ._sql_pool_security_alert_policies_operations import SqlPoolSecurityAlertPoliciesOperations # type: ignore +from ._sql_pool_vulnerability_assessment_rule_baselines_operations import SqlPoolVulnerabilityAssessmentRuleBaselinesOperations # type: ignore +from ._extended_sql_pool_blob_auditing_policies_operations import ExtendedSqlPoolBlobAuditingPoliciesOperations # type: ignore +from ._data_masking_policies_operations import DataMaskingPoliciesOperations # type: ignore +from ._data_masking_rules_operations import DataMaskingRulesOperations # type: ignore +from ._sql_pool_columns_operations import SqlPoolColumnsOperations # type: ignore +from ._sql_pool_workload_group_operations import SqlPoolWorkloadGroupOperations # type: ignore +from ._sql_pool_workload_classifier_operations import SqlPoolWorkloadClassifierOperations # type: ignore +from ._workspace_managed_sql_server_blob_auditing_policies_operations import WorkspaceManagedSqlServerBlobAuditingPoliciesOperations # type: ignore +from ._workspace_managed_sql_server_extended_blob_auditing_policies_operations import WorkspaceManagedSqlServerExtendedBlobAuditingPoliciesOperations # type: ignore +from ._workspace_managed_sql_server_security_alert_policy_operations import WorkspaceManagedSqlServerSecurityAlertPolicyOperations # type: ignore +from ._workspace_managed_sql_server_vulnerability_assessments_operations import WorkspaceManagedSqlServerVulnerabilityAssessmentsOperations # type: ignore +from ._workspace_managed_sql_server_encryption_protector_operations import WorkspaceManagedSqlServerEncryptionProtectorOperations # type: ignore +from ._workspace_managed_sql_server_usages_operations import WorkspaceManagedSqlServerUsagesOperations # type: ignore +from ._workspace_managed_sql_server_recoverable_sql_pools_operations import WorkspaceManagedSqlServerRecoverableSqlPoolsOperations # type: ignore +from ._workspace_managed_sql_server_dedicated_sql_minimal_tls_settings_operations import WorkspaceManagedSqlServerDedicatedSQLMinimalTlsSettingsOperations # type: ignore +from ._workspaces_operations import WorkspacesOperations # type: ignore +from ._workspace_aad_admins_operations import WorkspaceAadAdminsOperations # type: ignore +from ._workspace_sql_aad_admins_operations import WorkspaceSqlAadAdminsOperations # type: ignore +from ._workspace_managed_identity_sql_control_settings_operations import WorkspaceManagedIdentitySqlControlSettingsOperations # type: ignore +from ._restorable_dropped_sql_pools_operations import RestorableDroppedSqlPoolsOperations # type: ignore +from ._big_data_pools_operations import BigDataPoolsOperations # type: ignore +from ._library_operations import LibraryOperations # type: ignore +from ._libraries_operations import LibrariesOperations # type: ignore +from ._integration_runtimes_operations import IntegrationRuntimesOperations # type: ignore +from ._integration_runtime_node_ip_address_operations import IntegrationRuntimeNodeIpAddressOperations # type: ignore +from ._integration_runtime_object_metadata_operations import IntegrationRuntimeObjectMetadataOperations # type: ignore +from ._integration_runtime_nodes_operations import IntegrationRuntimeNodesOperations # type: ignore +from ._integration_runtime_credentials_operations import IntegrationRuntimeCredentialsOperations # type: ignore +from ._integration_runtime_connection_infos_operations import IntegrationRuntimeConnectionInfosOperations # type: ignore +from ._integration_runtime_auth_keys_operations import IntegrationRuntimeAuthKeysOperations # type: ignore +from ._integration_runtime_monitoring_data_operations import IntegrationRuntimeMonitoringDataOperations # type: ignore +from ._integration_runtime_status_operations import IntegrationRuntimeStatusOperations # type: ignore +from ._get_operations import GetOperations # type: ignore +from ._spark_configuration_operations import SparkConfigurationOperations # type: ignore +from ._spark_configurations_operations import SparkConfigurationsOperations # type: ignore +from ._kusto_operations_operations import KustoOperationsOperations # type: ignore +from ._kusto_pools_operations import KustoPoolsOperations # type: ignore +from ._kusto_pool_child_resource_operations import KustoPoolChildResourceOperations # type: ignore +from ._kusto_pool_attached_database_configurations_operations import KustoPoolAttachedDatabaseConfigurationsOperations # type: ignore +from ._kusto_pool_databases_operations import KustoPoolDatabasesOperations # type: ignore +from ._kusto_pool_data_connections_operations import KustoPoolDataConnectionsOperations # type: ignore +from ._kusto_pool_principal_assignments_operations import KustoPoolPrincipalAssignmentsOperations # type: ignore +from ._kusto_pool_database_principal_assignments_operations import KustoPoolDatabasePrincipalAssignmentsOperations # type: ignore +from ._kusto_pool_private_link_resources_operations import KustoPoolPrivateLinkResourcesOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -183,5 +169,5 @@ "KustoPoolDatabasePrincipalAssignmentsOperations", "KustoPoolPrivateLinkResourcesOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_azure_ad_only_authentications_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_azure_ad_only_authentications_operations.py index 720c906d3ec5..78d1159dfa38 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_azure_ad_only_authentications_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_azure_ad_only_authentications_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,13 +15,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 @@ -29,12 +30,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +52,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -71,7 +71,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -92,7 +92,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -112,7 +112,7 @@ def build_create_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -131,7 +131,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -147,7 +147,7 @@ def build_list_request( "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -197,12 +197,11 @@ def get( :param azure_ad_only_authentication_name: name of the property. "default" Required. :type azure_ad_only_authentication_name: str or ~azure.mgmt.synapse.models.AzureADOnlyAuthenticationName - :keyword callable cls: A custom type or function that will be passed the direct response :return: AzureADOnlyAuthentication or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.AzureADOnlyAuthentication :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -213,24 +212,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.AzureADOnlyAuthentication] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, azure_ad_only_authentication_name=azure_ad_only_authentication_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -240,26 +238,22 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AzureADOnlyAuthentication", pipeline_response) + deserialized = self._deserialize("AzureADOnlyAuthentication", 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.Synapse/workspaces/{workspaceName}/azureADOnlyAuthentications/{azureADOnlyAuthenticationName}" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, workspace_name: str, azure_ad_only_authentication_name: Union[str, _models.AzureADOnlyAuthenticationName], - azure_ad_only_authentication_info: Union[_models.AzureADOnlyAuthentication, IO], + azure_ad_only_authentication_info: Union[_models.AzureADOnlyAuthentication, IO[bytes]], **kwargs: Any - ) -> Optional[_models.AzureADOnlyAuthentication]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -270,19 +264,19 @@ def _create_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.AzureADOnlyAuthentication]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(azure_ad_only_authentication_info, (IO, bytes)): + if isinstance(azure_ad_only_authentication_info, (IOBase, bytes)): _content = azure_ad_only_authentication_info else: _json = self._serialize.body(azure_ad_only_authentication_info, "AzureADOnlyAuthentication") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, workspace_name=workspace_name, azure_ad_only_authentication_name=azure_ad_only_authentication_name, @@ -291,39 +285,34 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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=False, **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) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("AzureADOnlyAuthentication", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AzureADOnlyAuthentication", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/azureADOnlyAuthentications/{azureADOnlyAuthenticationName}" - } + return deserialized # type: ignore @overload def begin_create( @@ -353,14 +342,6 @@ def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~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 AzureADOnlyAuthentication or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.AzureADOnlyAuthentication] @@ -373,7 +354,7 @@ def begin_create( resource_group_name: str, workspace_name: str, azure_ad_only_authentication_name: Union[str, _models.AzureADOnlyAuthenticationName], - azure_ad_only_authentication_info: IO, + azure_ad_only_authentication_info: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -391,18 +372,10 @@ def begin_create( :type azure_ad_only_authentication_name: str or ~azure.mgmt.synapse.models.AzureADOnlyAuthenticationName :param azure_ad_only_authentication_info: Azure Active Directory Property. Required. - :type azure_ad_only_authentication_info: IO + :type azure_ad_only_authentication_info: 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 AzureADOnlyAuthentication or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.AzureADOnlyAuthentication] @@ -415,7 +388,7 @@ def begin_create( resource_group_name: str, workspace_name: str, azure_ad_only_authentication_name: Union[str, _models.AzureADOnlyAuthenticationName], - azure_ad_only_authentication_info: Union[_models.AzureADOnlyAuthentication, IO], + azure_ad_only_authentication_info: Union[_models.AzureADOnlyAuthentication, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.AzureADOnlyAuthentication]: """Create or Update Azure Active Directory only authentication property. @@ -430,21 +403,10 @@ def begin_create( :param azure_ad_only_authentication_name: name of the property. "default" Required. :type azure_ad_only_authentication_name: str or ~azure.mgmt.synapse.models.AzureADOnlyAuthenticationName - :param azure_ad_only_authentication_info: Azure Active Directory Property. Is either a model - type or a IO type. Required. + :param azure_ad_only_authentication_info: Azure Active Directory Property. Is either a + AzureADOnlyAuthentication type or a IO[bytes] type. Required. :type azure_ad_only_authentication_info: ~azure.mgmt.synapse.models.AzureADOnlyAuthentication - 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 IO[bytes] :return: An instance of LROPoller that returns either AzureADOnlyAuthentication or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.AzureADOnlyAuthentication] @@ -453,7 +415,7 @@ def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AzureADOnlyAuthentication] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -472,12 +434,13 @@ def begin_create( 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("AzureADOnlyAuthentication", pipeline_response) + deserialized = self._deserialize("AzureADOnlyAuthentication", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -489,17 +452,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.AzureADOnlyAuthentication].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/azureADOnlyAuthentications/{azureADOnlyAuthenticationName}" - } + return LROPoller[_models.AzureADOnlyAuthentication]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list( @@ -514,7 +475,6 @@ def list( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AzureADOnlyAuthentication or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.AzureADOnlyAuthentication] @@ -523,10 +483,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.AzureADOnlyAuthenticationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -537,24 +497,21 @@ 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, workspace_name=workspace_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AzureADOnlyAuthenticationListResult", pipeline_response) @@ -564,10 +521,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -579,7 +537,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.Synapse/workspaces/{workspaceName}/azureADOnlyAuthentications" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_big_data_pools_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_big_data_pools_operations.py index 6132d2dd9767..555fb32df2ff 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_big_data_pools_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_big_data_pools_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,13 +15,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 @@ -29,12 +30,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -48,9 +48,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -67,7 +65,7 @@ def build_get_request( "bigDataPoolName": _SERIALIZER.url("big_data_pool_name", big_data_pool_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -84,9 +82,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -104,7 +100,7 @@ def build_update_request( "bigDataPoolName": _SERIALIZER.url("big_data_pool_name", big_data_pool_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -129,9 +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: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -149,7 +143,7 @@ def build_create_or_update_request( "bigDataPoolName": _SERIALIZER.url("big_data_pool_name", big_data_pool_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -170,9 +164,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -189,7 +181,7 @@ def build_delete_request( "bigDataPoolName": _SERIALIZER.url("big_data_pool_name", big_data_pool_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -206,9 +198,7 @@ def build_list_by_workspace_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -224,7 +214,7 @@ def build_list_by_workspace_request( "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -269,12 +259,11 @@ def get( :type workspace_name: str :param big_data_pool_name: Big Data pool name. Required. :type big_data_pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: BigDataPoolResourceInfo or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.BigDataPoolResourceInfo :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -285,26 +274,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.BigDataPoolResourceInfo] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, big_data_pool_name=big_data_pool_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -314,16 +300,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("BigDataPoolResourceInfo", pipeline_response) + deserialized = self._deserialize("BigDataPoolResourceInfo", 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.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}" - } + return deserialized # type: ignore @overload def update( @@ -352,7 +334,6 @@ def 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 :return: BigDataPoolResourceInfo or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.BigDataPoolResourceInfo :raises ~azure.core.exceptions.HttpResponseError: @@ -364,7 +345,7 @@ def update( resource_group_name: str, workspace_name: str, big_data_pool_name: str, - big_data_pool_patch_info: IO, + big_data_pool_patch_info: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -381,11 +362,10 @@ def update( :param big_data_pool_name: Big Data pool name. Required. :type big_data_pool_name: str :param big_data_pool_patch_info: The updated Big Data pool properties. Required. - :type big_data_pool_patch_info: IO + :type big_data_pool_patch_info: 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: BigDataPoolResourceInfo or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.BigDataPoolResourceInfo :raises ~azure.core.exceptions.HttpResponseError: @@ -397,7 +377,7 @@ def update( resource_group_name: str, workspace_name: str, big_data_pool_name: str, - big_data_pool_patch_info: Union[_models.BigDataPoolPatchInfo, IO], + big_data_pool_patch_info: Union[_models.BigDataPoolPatchInfo, IO[bytes]], **kwargs: Any ) -> _models.BigDataPoolResourceInfo: """Update a Big Data pool. @@ -411,18 +391,14 @@ def update( :type workspace_name: str :param big_data_pool_name: Big Data pool name. Required. :type big_data_pool_name: str - :param big_data_pool_patch_info: The updated Big Data pool properties. Is either a model type - or a IO type. Required. - :type big_data_pool_patch_info: ~azure.mgmt.synapse.models.BigDataPoolPatchInfo 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 big_data_pool_patch_info: The updated Big Data pool properties. Is either a + BigDataPoolPatchInfo type or a IO[bytes] type. Required. + :type big_data_pool_patch_info: ~azure.mgmt.synapse.models.BigDataPoolPatchInfo or IO[bytes] :return: BigDataPoolResourceInfo or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.BigDataPoolResourceInfo :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -433,21 +409,19 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.BigDataPoolResourceInfo] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(big_data_pool_patch_info, (IO, bytes)): + if isinstance(big_data_pool_patch_info, (IOBase, bytes)): _content = big_data_pool_patch_info else: _json = self._serialize.body(big_data_pool_patch_info, "BigDataPoolPatchInfo") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, big_data_pool_name=big_data_pool_name, @@ -456,15 +430,14 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -474,27 +447,23 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("BigDataPoolResourceInfo", pipeline_response) + deserialized = self._deserialize("BigDataPoolResourceInfo", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, workspace_name: str, big_data_pool_name: str, - big_data_pool_info: Union[_models.BigDataPoolResourceInfo, IO], + big_data_pool_info: Union[_models.BigDataPoolResourceInfo, IO[bytes]], force: bool = False, **kwargs: Any - ) -> _models.BigDataPoolResourceInfo: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -505,21 +474,19 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.BigDataPoolResourceInfo] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(big_data_pool_info, (IO, bytes)): + if isinstance(big_data_pool_info, (IOBase, bytes)): _content = big_data_pool_info else: _json = self._serialize.body(big_data_pool_info, "BigDataPoolResourceInfo") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, big_data_pool_name=big_data_pool_name, @@ -529,39 +496,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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) - if response.status_code == 200: - deserialized = self._deserialize("BigDataPoolResourceInfo", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("BigDataPoolResourceInfo", 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.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}" - } - @overload def begin_create_or_update( self, @@ -592,14 +555,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 BigDataPoolResourceInfo or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.BigDataPoolResourceInfo] @@ -612,7 +567,7 @@ def begin_create_or_update( resource_group_name: str, workspace_name: str, big_data_pool_name: str, - big_data_pool_info: IO, + big_data_pool_info: IO[bytes], force: bool = False, *, content_type: str = "application/json", @@ -630,20 +585,12 @@ def begin_create_or_update( :param big_data_pool_name: Big Data pool name. Required. :type big_data_pool_name: str :param big_data_pool_info: The Big Data pool to create. Required. - :type big_data_pool_info: IO + :type big_data_pool_info: IO[bytes] :param force: Whether to stop any running jobs in the Big Data pool. Default value is False. :type force: bool :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~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 BigDataPoolResourceInfo or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.BigDataPoolResourceInfo] @@ -656,7 +603,7 @@ def begin_create_or_update( resource_group_name: str, workspace_name: str, big_data_pool_name: str, - big_data_pool_info: Union[_models.BigDataPoolResourceInfo, IO], + big_data_pool_info: Union[_models.BigDataPoolResourceInfo, IO[bytes]], force: bool = False, **kwargs: Any ) -> LROPoller[_models.BigDataPoolResourceInfo]: @@ -671,22 +618,11 @@ def begin_create_or_update( :type workspace_name: str :param big_data_pool_name: Big Data pool name. Required. :type big_data_pool_name: str - :param big_data_pool_info: The Big Data pool to create. Is either a model type or a IO type. - Required. - :type big_data_pool_info: ~azure.mgmt.synapse.models.BigDataPoolResourceInfo or IO + :param big_data_pool_info: The Big Data pool to create. Is either a BigDataPoolResourceInfo + type or a IO[bytes] type. Required. + :type big_data_pool_info: ~azure.mgmt.synapse.models.BigDataPoolResourceInfo or IO[bytes] :param force: Whether to stop any running jobs in the Big Data pool. Default value is False. :type force: bool - :keyword content_type: Body Parameter content-type. Known values are: 'application/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 BigDataPoolResourceInfo or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.BigDataPoolResourceInfo] @@ -695,9 +631,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.BigDataPoolResourceInfo] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -717,12 +651,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("BigDataPoolResourceInfo", pipeline_response) + deserialized = self._deserialize("BigDataPoolResourceInfo", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -734,22 +669,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.BigDataPoolResourceInfo].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.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}" - } + return LROPoller[_models.BigDataPoolResourceInfo]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _delete_initial( self, resource_group_name: str, workspace_name: str, big_data_pool_name: str, **kwargs: Any - ) -> Optional[_models.BigDataPoolResourceInfo]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -760,50 +693,43 @@ def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) - cls: ClsType[Optional[_models.BigDataPoolResourceInfo]] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_name, big_data_pool_name=big_data_pool_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("BigDataPoolResourceInfo", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("BigDataPoolResourceInfo", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -820,14 +746,6 @@ def begin_delete( :type workspace_name: str :param big_data_pool_name: Big Data pool name. Required. :type big_data_pool_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 BigDataPoolResourceInfo or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.BigDataPoolResourceInfo] @@ -836,9 +754,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.BigDataPoolResourceInfo] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -854,12 +770,13 @@ 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): - deserialized = self._deserialize("BigDataPoolResourceInfo", pipeline_response) + deserialized = self._deserialize("BigDataPoolResourceInfo", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -871,17 +788,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.BigDataPoolResourceInfo].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.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}" - } + return LROPoller[_models.BigDataPoolResourceInfo]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list_by_workspace( @@ -896,7 +811,6 @@ def list_by_workspace( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BigDataPoolResourceInfo or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.BigDataPoolResourceInfo] @@ -905,12 +819,10 @@ def list_by_workspace( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.BigDataPoolResourceInfoListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -921,24 +833,21 @@ def list_by_workspace( def prepare_request(next_link=None): if not next_link: - request = build_list_by_workspace_request( + _request = build_list_by_workspace_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_workspace.metadata["url"], 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("BigDataPoolResourceInfoListResult", pipeline_response) @@ -948,10 +857,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -963,7 +873,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_workspace.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_data_masking_policies_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_data_masking_policies_operations.py index 8803fa9ec239..4e604de5906b 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_data_masking_policies_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_data_masking_policies_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,20 +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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +43,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: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) data_masking_policy_name: Literal["Default"] = kwargs.pop("data_masking_policy_name", "Default") content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -65,7 +63,7 @@ def build_create_or_update_request( "dataMaskingPolicyName": _SERIALIZER.url("data_masking_policy_name", data_masking_policy_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -84,7 +82,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) data_masking_policy_name: Literal["Default"] = kwargs.pop("data_masking_policy_name", "Default") accept = _headers.pop("Accept", "application/json") @@ -103,7 +101,7 @@ def build_get_request( "dataMaskingPolicyName": _SERIALIZER.url("data_masking_policy_name", data_masking_policy_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -158,11 +156,6 @@ def 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 data_masking_policy_name: The name of the data masking policy for which the masking - rule applies. Default value is "Default". Note that overriding this default value may result in - unsupported behavior. - :paramtype data_masking_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DataMaskingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.DataMaskingPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -174,7 +167,7 @@ def create_or_update( resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -189,15 +182,10 @@ def create_or_update( :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str :param parameters: Parameters for creating or updating a data masking policy. 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 data_masking_policy_name: The name of the data masking policy for which the masking - rule applies. Default value is "Default". Note that overriding this default value may result in - unsupported behavior. - :paramtype data_masking_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DataMaskingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.DataMaskingPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -209,7 +197,7 @@ def create_or_update( resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: Union[_models.DataMaskingPolicy, IO], + parameters: Union[_models.DataMaskingPolicy, IO[bytes]], **kwargs: Any ) -> _models.DataMaskingPolicy: """Creates or updates a Sql pool data masking policy. @@ -221,22 +209,14 @@ def create_or_update( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param parameters: Parameters for creating or updating a data masking policy. Is either a model - type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.models.DataMaskingPolicy or IO - :keyword data_masking_policy_name: The name of the data masking policy for which the masking - rule applies. Default value is "Default". Note that overriding this default value may result in - unsupported behavior. - :paramtype data_masking_policy_name: 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 + :param parameters: Parameters for creating or updating a data masking policy. Is either a + DataMaskingPolicy type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.DataMaskingPolicy or IO[bytes] :return: DataMaskingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.DataMaskingPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -247,7 +227,7 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) data_masking_policy_name: Literal["Default"] = kwargs.pop("data_masking_policy_name", "Default") content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DataMaskingPolicy] = kwargs.pop("cls", None) @@ -255,12 +235,12 @@ def create_or_update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DataMaskingPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -270,15 +250,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -288,16 +267,12 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DataMaskingPolicy", pipeline_response) + deserialized = self._deserialize("DataMaskingPolicy", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataMaskingPolicies/{dataMaskingPolicyName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -312,16 +287,11 @@ def get( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword data_masking_policy_name: The name of the data masking policy for which the masking - rule applies. Default value is "Default". Note that overriding this default value may result in - unsupported behavior. - :paramtype data_masking_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DataMaskingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.DataMaskingPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -332,26 +302,25 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) data_masking_policy_name: Literal["Default"] = kwargs.pop("data_masking_policy_name", "Default") cls: ClsType[_models.DataMaskingPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, subscription_id=self._config.subscription_id, api_version=api_version, data_masking_policy_name=data_masking_policy_name, - 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -361,13 +330,9 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DataMaskingPolicy", pipeline_response) + deserialized = self._deserialize("DataMaskingPolicy", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataMaskingPolicies/{dataMaskingPolicyName}" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_data_masking_rules_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_data_masking_rules_operations.py index 4884c70e6b05..b9bf7c18ac31 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_data_masking_rules_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_data_masking_rules_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,20 +19,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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +49,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: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) data_masking_policy_name: Literal["Default"] = kwargs.pop("data_masking_policy_name", "Default") content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -72,7 +70,7 @@ def build_create_or_update_request( "dataMaskingRuleName": _SERIALIZER.url("data_masking_rule_name", data_masking_rule_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -96,7 +94,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) data_masking_policy_name: Literal["Default"] = kwargs.pop("data_masking_policy_name", "Default") accept = _headers.pop("Accept", "application/json") @@ -116,7 +114,7 @@ def build_get_request( "dataMaskingRuleName": _SERIALIZER.url("data_masking_rule_name", data_masking_rule_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -133,7 +131,7 @@ def build_list_by_sql_pool_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) data_masking_policy_name: Literal["Default"] = kwargs.pop("data_masking_policy_name", "Default") accept = _headers.pop("Accept", "application/json") @@ -152,7 +150,7 @@ def build_list_by_sql_pool_request( "dataMaskingPolicyName": _SERIALIZER.url("data_masking_policy_name", data_masking_policy_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -211,11 +209,6 @@ def 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 data_masking_policy_name: The name of the data masking policy for which the masking - rule applies. Default value is "Default". Note that overriding this default value may result in - unsupported behavior. - :paramtype data_masking_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DataMaskingRule or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.DataMaskingRule :raises ~azure.core.exceptions.HttpResponseError: @@ -228,7 +221,7 @@ def create_or_update( workspace_name: str, sql_pool_name: str, data_masking_rule_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -246,15 +239,10 @@ def create_or_update( :type data_masking_rule_name: str :param parameters: The required parameters for creating or updating a data masking rule. 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 data_masking_policy_name: The name of the data masking policy for which the masking - rule applies. Default value is "Default". Note that overriding this default value may result in - unsupported behavior. - :paramtype data_masking_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DataMaskingRule or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.DataMaskingRule :raises ~azure.core.exceptions.HttpResponseError: @@ -267,7 +255,7 @@ def create_or_update( workspace_name: str, sql_pool_name: str, data_masking_rule_name: str, - parameters: Union[_models.DataMaskingRule, IO], + parameters: Union[_models.DataMaskingRule, IO[bytes]], **kwargs: Any ) -> _models.DataMaskingRule: """Creates or updates a Sql pool data masking rule. @@ -282,21 +270,13 @@ def create_or_update( :param data_masking_rule_name: The name of the data masking rule. Required. :type data_masking_rule_name: str :param parameters: The required parameters for creating or updating a data masking rule. Is - either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.models.DataMaskingRule or IO - :keyword data_masking_policy_name: The name of the data masking policy for which the masking - rule applies. Default value is "Default". Note that overriding this default value may result in - unsupported behavior. - :paramtype data_masking_policy_name: 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 + either a DataMaskingRule type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.DataMaskingRule or IO[bytes] :return: DataMaskingRule or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.DataMaskingRule :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -307,7 +287,7 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) data_masking_policy_name: Literal["Default"] = kwargs.pop("data_masking_policy_name", "Default") content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DataMaskingRule] = kwargs.pop("cls", None) @@ -315,12 +295,12 @@ def create_or_update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DataMaskingRule") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -331,15 +311,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -349,21 +328,13 @@ def create_or_update( 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("DataMaskingRule", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DataMaskingRule", pipeline_response) + deserialized = self._deserialize("DataMaskingRule", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules/{dataMaskingRuleName}" - } - @distributed_trace def get( self, @@ -384,16 +355,11 @@ def get( :type sql_pool_name: str :param data_masking_rule_name: The name of the data masking rule. Required. :type data_masking_rule_name: str - :keyword data_masking_policy_name: The name of the data masking policy for which the masking - rule applies. Default value is "Default". Note that overriding this default value may result in - unsupported behavior. - :paramtype data_masking_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DataMaskingRule or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.DataMaskingRule :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -404,11 +370,11 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) data_masking_policy_name: Literal["Default"] = kwargs.pop("data_masking_policy_name", "Default") cls: ClsType[_models.DataMaskingRule] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -416,15 +382,14 @@ def get( subscription_id=self._config.subscription_id, api_version=api_version, data_masking_policy_name=data_masking_policy_name, - 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -434,16 +399,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DataMaskingRule", pipeline_response) + deserialized = self._deserialize("DataMaskingRule", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules/{dataMaskingRuleName}" - } + return deserialized # type: ignore @distributed_trace def list_by_sql_pool( @@ -458,11 +419,6 @@ def list_by_sql_pool( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword data_masking_policy_name: The name of the data masking policy for which the masking - rule applies. Default value is "Default". Note that overriding this default value may result in - unsupported behavior. - :paramtype data_masking_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DataMaskingRule or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.DataMaskingRule] :raises ~azure.core.exceptions.HttpResponseError: @@ -470,11 +426,11 @@ def list_by_sql_pool( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) data_masking_policy_name: Literal["Default"] = kwargs.pop("data_masking_policy_name", "Default") cls: ClsType[_models.DataMaskingRuleListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -485,26 +441,23 @@ def list_by_sql_pool( def prepare_request(next_link=None): if not next_link: - request = build_list_by_sql_pool_request( + _request = build_list_by_sql_pool_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, subscription_id=self._config.subscription_id, api_version=api_version, data_masking_policy_name=data_masking_policy_name, - template_url=self.list_by_sql_pool.metadata["url"], 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DataMaskingRuleListResult", pipeline_response) @@ -514,10 +467,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -529,7 +483,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_sql_pool.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_extended_sql_pool_blob_auditing_policies_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_extended_sql_pool_blob_auditing_policies_operations.py index f80f49a53df5..3455b2073b3a 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_extended_sql_pool_blob_auditing_policies_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_extended_sql_pool_blob_auditing_policies_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,20 +19,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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -46,7 +44,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") accept = _headers.pop("Accept", "application/json") @@ -65,7 +63,7 @@ def build_get_request( "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -82,7 +80,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: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -102,7 +100,7 @@ def build_create_or_update_request( "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -121,7 +119,7 @@ def build_list_by_sql_pool_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -138,7 +136,7 @@ def build_list_by_sql_pool_request( "sqlPoolName": _SERIALIZER.url("sql_pool_name", sql_pool_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -149,7 +147,7 @@ def build_list_by_sql_pool_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class ExtendedSqlPoolBlobAuditingPoliciesOperations: +class ExtendedSqlPoolBlobAuditingPoliciesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -181,15 +179,11 @@ def get( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword blob_auditing_policy_name: The name of the blob auditing policy. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype blob_auditing_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ExtendedSqlPoolBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ExtendedSqlPoolBlobAuditingPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -200,26 +194,25 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") cls: ClsType[_models.ExtendedSqlPoolBlobAuditingPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, subscription_id=self._config.subscription_id, api_version=api_version, blob_auditing_policy_name=blob_auditing_policy_name, - 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -228,16 +221,12 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ExtendedSqlPoolBlobAuditingPolicy", pipeline_response) + deserialized = self._deserialize("ExtendedSqlPoolBlobAuditingPolicy", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/extendedAuditingSettings/{blobAuditingPolicyName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -264,10 +253,6 @@ def 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 blob_auditing_policy_name: The name of the blob auditing policy. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype blob_auditing_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ExtendedSqlPoolBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ExtendedSqlPoolBlobAuditingPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -279,7 +264,7 @@ def create_or_update( resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -294,14 +279,10 @@ def create_or_update( :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str :param parameters: The extended Sql pool blob auditing policy. 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 blob_auditing_policy_name: The name of the blob auditing policy. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype blob_auditing_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ExtendedSqlPoolBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ExtendedSqlPoolBlobAuditingPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -313,7 +294,7 @@ def create_or_update( resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: Union[_models.ExtendedSqlPoolBlobAuditingPolicy, IO], + parameters: Union[_models.ExtendedSqlPoolBlobAuditingPolicy, IO[bytes]], **kwargs: Any ) -> _models.ExtendedSqlPoolBlobAuditingPolicy: """Creates or updates an extended Sql pool's blob auditing policy. @@ -325,21 +306,14 @@ def create_or_update( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param parameters: The extended Sql pool blob auditing policy. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.synapse.models.ExtendedSqlPoolBlobAuditingPolicy or IO - :keyword blob_auditing_policy_name: The name of the blob auditing policy. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype blob_auditing_policy_name: 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 + :param parameters: The extended Sql pool blob auditing policy. Is either a + ExtendedSqlPoolBlobAuditingPolicy type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.ExtendedSqlPoolBlobAuditingPolicy or IO[bytes] :return: ExtendedSqlPoolBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ExtendedSqlPoolBlobAuditingPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -350,7 +324,7 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ExtendedSqlPoolBlobAuditingPolicy] = kwargs.pop("cls", None) @@ -358,12 +332,12 @@ def create_or_update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ExtendedSqlPoolBlobAuditingPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -373,15 +347,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -390,21 +363,13 @@ def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ExtendedSqlPoolBlobAuditingPolicy", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ExtendedSqlPoolBlobAuditingPolicy", pipeline_response) + deserialized = self._deserialize("ExtendedSqlPoolBlobAuditingPolicy", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/extendedAuditingSettings/{blobAuditingPolicyName}" - } - @distributed_trace def list_by_sql_pool( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any @@ -418,7 +383,6 @@ def list_by_sql_pool( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ExtendedSqlPoolBlobAuditingPolicy or the result of cls(response) :rtype: @@ -428,10 +392,10 @@ def list_by_sql_pool( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.ExtendedSqlPoolBlobAuditingPolicyListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -442,25 +406,22 @@ def list_by_sql_pool( def prepare_request(next_link=None): if not next_link: - request = build_list_by_sql_pool_request( + _request = build_list_by_sql_pool_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_sql_pool.metadata["url"], 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ExtendedSqlPoolBlobAuditingPolicyListResult", pipeline_response) @@ -470,10 +431,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -484,7 +446,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_sql_pool.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/extendedAuditingSettings" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_get_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_get_operations.py index cc40b5537e06..414663f57cbb 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_get_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_get_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -18,20 +17,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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,9 +47,7 @@ def build_integration_runtime_start_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -72,7 +67,7 @@ def build_integration_runtime_start_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -94,9 +89,7 @@ def build_integration_runtime_stop_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -116,7 +109,7 @@ def build_integration_runtime_stop_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -127,7 +120,7 @@ def build_integration_runtime_stop_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_integration_runtime_enable_interactivequery_request( +def build_integration_runtime_enable_interactivequery_request( # pylint: disable=name-too-long resource_group_name: str, workspace_name: str, integration_runtime_name: str, @@ -138,9 +131,7 @@ def build_integration_runtime_enable_interactivequery_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -160,7 +151,7 @@ def build_integration_runtime_enable_interactivequery_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -212,12 +203,11 @@ def integration_runtime_start( :type integration_runtime_name: str :param integration_runtime_operation_id: Integration runtime Operation Id. Required. :type integration_runtime_operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: IntegrationRuntimeOperationStatus or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeOperationStatus :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -228,27 +218,24 @@ def integration_runtime_start( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.IntegrationRuntimeOperationStatus] = kwargs.pop("cls", None) - request = build_integration_runtime_start_request( + _request = build_integration_runtime_start_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, integration_runtime_operation_id=integration_runtime_operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.integration_runtime_start.metadata["url"], 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -258,16 +245,12 @@ def integration_runtime_start( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("IntegrationRuntimeOperationStatus", pipeline_response) + deserialized = self._deserialize("IntegrationRuntimeOperationStatus", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - integration_runtime_start.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/start/operationstatuses/{integrationRuntimeOperationId}" - } + return deserialized # type: ignore @distributed_trace def integration_runtime_stop( @@ -291,12 +274,11 @@ def integration_runtime_stop( :type integration_runtime_name: str :param integration_runtime_operation_id: Integration runtime Operation Id. Required. :type integration_runtime_operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: IntegrationRuntimeStopOperationStatus or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeStopOperationStatus :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -307,27 +289,24 @@ def integration_runtime_stop( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.IntegrationRuntimeStopOperationStatus] = kwargs.pop("cls", None) - request = build_integration_runtime_stop_request( + _request = build_integration_runtime_stop_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, integration_runtime_operation_id=integration_runtime_operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.integration_runtime_stop.metadata["url"], 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -337,19 +316,15 @@ def integration_runtime_stop( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("IntegrationRuntimeStopOperationStatus", pipeline_response) + deserialized = self._deserialize("IntegrationRuntimeStopOperationStatus", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - integration_runtime_stop.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/stop/operationstatuses/{integrationRuntimeOperationId}" - } + return deserialized # type: ignore @distributed_trace - def integration_runtime_enable_interactivequery( + def integration_runtime_enable_interactivequery( # pylint: disable=name-too-long self, resource_group_name: str, workspace_name: str, @@ -370,12 +345,11 @@ def integration_runtime_enable_interactivequery( :type integration_runtime_name: str :param integration_runtime_operation_id: Integration runtime Operation Id. Required. :type integration_runtime_operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: IntegrationRuntimeEnableinteractivequery or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeEnableinteractivequery :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -386,27 +360,24 @@ def integration_runtime_enable_interactivequery( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.IntegrationRuntimeEnableinteractivequery] = kwargs.pop("cls", None) - request = build_integration_runtime_enable_interactivequery_request( + _request = build_integration_runtime_enable_interactivequery_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, integration_runtime_operation_id=integration_runtime_operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.integration_runtime_enable_interactivequery.metadata["url"], 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -416,13 +387,9 @@ def integration_runtime_enable_interactivequery( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("IntegrationRuntimeEnableinteractivequery", pipeline_response) + deserialized = self._deserialize("IntegrationRuntimeEnableinteractivequery", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - integration_runtime_enable_interactivequery.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/enableinteractivequery/operationstatuses/{integrationRuntimeOperationId}" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_integration_runtime_auth_keys_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_integration_runtime_auth_keys_operations.py index f45a8b125173..00c797a144ef 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_integration_runtime_auth_keys_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_integration_runtime_auth_keys_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload @@ -18,20 +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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,9 +43,7 @@ def build_regenerate_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -65,7 +61,7 @@ def build_regenerate_request( "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -84,9 +80,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -103,7 +97,7 @@ def build_list_request( "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -162,7 +156,6 @@ def regenerate( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. 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: IntegrationRuntimeAuthKeys or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeAuthKeys :raises ~azure.core.exceptions.HttpResponseError: @@ -174,7 +167,7 @@ def regenerate( resource_group_name: str, workspace_name: str, integration_runtime_name: str, - regenerate_key_parameters: IO, + regenerate_key_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -192,11 +185,10 @@ def regenerate( :type integration_runtime_name: str :param regenerate_key_parameters: The parameters for regenerating integration runtime authentication key. Required. - :type regenerate_key_parameters: IO + :type regenerate_key_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: IntegrationRuntimeAuthKeys or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeAuthKeys :raises ~azure.core.exceptions.HttpResponseError: @@ -208,7 +200,7 @@ def regenerate( resource_group_name: str, workspace_name: str, integration_runtime_name: str, - regenerate_key_parameters: Union[_models.IntegrationRuntimeRegenerateKeyParameters, IO], + regenerate_key_parameters: Union[_models.IntegrationRuntimeRegenerateKeyParameters, IO[bytes]], **kwargs: Any ) -> _models.IntegrationRuntimeAuthKeys: """Regenerate integration runtime authentication key. @@ -223,18 +215,15 @@ def regenerate( :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str :param regenerate_key_parameters: The parameters for regenerating integration runtime - authentication key. Is either a model type or a IO type. Required. + authentication key. Is either a IntegrationRuntimeRegenerateKeyParameters type or a IO[bytes] + type. Required. :type regenerate_key_parameters: - ~azure.mgmt.synapse.models.IntegrationRuntimeRegenerateKeyParameters 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.synapse.models.IntegrationRuntimeRegenerateKeyParameters or IO[bytes] :return: IntegrationRuntimeAuthKeys or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeAuthKeys :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -245,21 +234,19 @@ def regenerate( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IntegrationRuntimeAuthKeys] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(regenerate_key_parameters, (IO, bytes)): + if isinstance(regenerate_key_parameters, (IOBase, bytes)): _content = regenerate_key_parameters else: _json = self._serialize.body(regenerate_key_parameters, "IntegrationRuntimeRegenerateKeyParameters") - request = build_regenerate_request( + _request = build_regenerate_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, @@ -268,15 +255,14 @@ def regenerate( content_type=content_type, json=_json, content=_content, - template_url=self.regenerate.metadata["url"], 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -286,16 +272,12 @@ def regenerate( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("IntegrationRuntimeAuthKeys", pipeline_response) + deserialized = self._deserialize("IntegrationRuntimeAuthKeys", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - regenerate.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/regenerateAuthKey" - } + return deserialized # type: ignore @distributed_trace def list( @@ -312,12 +294,11 @@ def list( :type workspace_name: str :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: IntegrationRuntimeAuthKeys or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeAuthKeys :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -328,26 +309,23 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.IntegrationRuntimeAuthKeys] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_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) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -357,13 +335,9 @@ def list( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("IntegrationRuntimeAuthKeys", pipeline_response) + deserialized = self._deserialize("IntegrationRuntimeAuthKeys", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/listAuthKeys" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_integration_runtime_connection_infos_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_integration_runtime_connection_infos_operations.py index 034fa0291dd7..23010ec35531 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_integration_runtime_connection_infos_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_integration_runtime_connection_infos_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -18,20 +17,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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,9 +42,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -64,7 +59,7 @@ def build_get_request( "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -75,7 +70,7 @@ def build_get_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class IntegrationRuntimeConnectionInfosOperations: +class IntegrationRuntimeConnectionInfosOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -109,12 +104,11 @@ def get( :type workspace_name: str :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: IntegrationRuntimeConnectionInfo or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeConnectionInfo :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -125,26 +119,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.IntegrationRuntimeConnectionInfo] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -154,13 +145,9 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("IntegrationRuntimeConnectionInfo", pipeline_response) + deserialized = self._deserialize("IntegrationRuntimeConnectionInfo", 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.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/getConnectionInfo" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_integration_runtime_credentials_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_integration_runtime_credentials_operations.py index 40632556b6fa..9289726f5e48 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_integration_runtime_credentials_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_integration_runtime_credentials_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -18,20 +17,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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,9 +42,7 @@ def build_sync_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -64,7 +59,7 @@ def build_sync_request( "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -112,12 +107,11 @@ def sync( # pylint: disable=inconsistent-return-statements :type workspace_name: str :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -128,26 +122,23 @@ def sync( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_sync_request( + _request = build_sync_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.sync.metadata["url"], 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -158,8 +149,4 @@ def sync( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - sync.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/syncCredentials" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_integration_runtime_monitoring_data_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_integration_runtime_monitoring_data_operations.py index fb59769b1b18..ed2fdcfe5897 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_integration_runtime_monitoring_data_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_integration_runtime_monitoring_data_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -18,20 +17,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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,9 +42,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -64,7 +59,7 @@ def build_list_request( "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -75,7 +70,7 @@ def build_list_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class IntegrationRuntimeMonitoringDataOperations: +class IntegrationRuntimeMonitoringDataOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -109,12 +104,11 @@ def list( :type workspace_name: str :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: IntegrationRuntimeMonitoringData or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeMonitoringData :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -125,26 +119,23 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.IntegrationRuntimeMonitoringData] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_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) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -154,13 +145,9 @@ def list( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("IntegrationRuntimeMonitoringData", pipeline_response) + deserialized = self._deserialize("IntegrationRuntimeMonitoringData", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/monitoringData" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_integration_runtime_node_ip_address_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_integration_runtime_node_ip_address_operations.py index 83e1753bff83..a763d9544947 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_integration_runtime_node_ip_address_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_integration_runtime_node_ip_address_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -18,20 +17,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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,9 +47,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -70,7 +65,7 @@ def build_get_request( "nodeName": _SERIALIZER.url("node_name", node_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -81,7 +76,7 @@ def build_get_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class IntegrationRuntimeNodeIpAddressOperations: +class IntegrationRuntimeNodeIpAddressOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -122,12 +117,11 @@ def get( :type integration_runtime_name: str :param node_name: Integration runtime node name. Required. :type node_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: IntegrationRuntimeNodeIpAddress or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeNodeIpAddress :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -138,27 +132,24 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.IntegrationRuntimeNodeIpAddress] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, node_name=node_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -168,13 +159,9 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("IntegrationRuntimeNodeIpAddress", pipeline_response) + deserialized = self._deserialize("IntegrationRuntimeNodeIpAddress", 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.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/nodes/{nodeName}/ipAddress" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_integration_runtime_nodes_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_integration_runtime_nodes_operations.py index efa90c82256e..a38b269b4435 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_integration_runtime_nodes_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_integration_runtime_nodes_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload @@ -18,20 +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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,9 +48,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -70,7 +66,7 @@ def build_get_request( "nodeName": _SERIALIZER.url("node_name", node_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -92,9 +88,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -113,7 +107,7 @@ def build_update_request( "nodeName": _SERIALIZER.url("node_name", node_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -137,9 +131,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -157,7 +149,7 @@ def build_delete_request( "nodeName": _SERIALIZER.url("node_name", node_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -209,12 +201,11 @@ def get( :type integration_runtime_name: str :param node_name: Integration runtime node name. Required. :type node_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SelfHostedIntegrationRuntimeNode or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SelfHostedIntegrationRuntimeNode :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -225,27 +216,24 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.SelfHostedIntegrationRuntimeNode] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, node_name=node_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -255,16 +243,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SelfHostedIntegrationRuntimeNode", pipeline_response) + deserialized = self._deserialize("SelfHostedIntegrationRuntimeNode", 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.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/nodes/{nodeName}" - } + return deserialized # type: ignore @overload def update( @@ -298,7 +282,6 @@ def 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 :return: SelfHostedIntegrationRuntimeNode or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SelfHostedIntegrationRuntimeNode :raises ~azure.core.exceptions.HttpResponseError: @@ -311,7 +294,7 @@ def update( workspace_name: str, integration_runtime_name: str, node_name: str, - update_integration_runtime_node_request: IO, + update_integration_runtime_node_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -331,11 +314,10 @@ def update( :type node_name: str :param update_integration_runtime_node_request: The parameters for updating an integration runtime node. Required. - :type update_integration_runtime_node_request: IO + :type update_integration_runtime_node_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 :return: SelfHostedIntegrationRuntimeNode or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SelfHostedIntegrationRuntimeNode :raises ~azure.core.exceptions.HttpResponseError: @@ -348,7 +330,7 @@ def update( workspace_name: str, integration_runtime_name: str, node_name: str, - update_integration_runtime_node_request: Union[_models.UpdateIntegrationRuntimeNodeRequest, IO], + update_integration_runtime_node_request: Union[_models.UpdateIntegrationRuntimeNodeRequest, IO[bytes]], **kwargs: Any ) -> _models.SelfHostedIntegrationRuntimeNode: """Create integration runtime node. @@ -365,18 +347,15 @@ def update( :param node_name: Integration runtime node name. Required. :type node_name: str :param update_integration_runtime_node_request: The parameters for updating an integration - runtime node. Is either a model type or a IO type. Required. + runtime node. Is either a UpdateIntegrationRuntimeNodeRequest type or a IO[bytes] type. + Required. :type update_integration_runtime_node_request: - ~azure.mgmt.synapse.models.UpdateIntegrationRuntimeNodeRequest 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.synapse.models.UpdateIntegrationRuntimeNodeRequest or IO[bytes] :return: SelfHostedIntegrationRuntimeNode or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SelfHostedIntegrationRuntimeNode :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -387,21 +366,19 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SelfHostedIntegrationRuntimeNode] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(update_integration_runtime_node_request, (IO, bytes)): + if isinstance(update_integration_runtime_node_request, (IOBase, bytes)): _content = update_integration_runtime_node_request else: _json = self._serialize.body(update_integration_runtime_node_request, "UpdateIntegrationRuntimeNodeRequest") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, @@ -411,15 +388,14 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -429,16 +405,12 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SelfHostedIntegrationRuntimeNode", pipeline_response) + deserialized = self._deserialize("SelfHostedIntegrationRuntimeNode", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/nodes/{nodeName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -462,12 +434,11 @@ def delete( # pylint: disable=inconsistent-return-statements :type integration_runtime_name: str :param node_name: Integration runtime node name. Required. :type node_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -478,27 +449,24 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, node_name=node_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -509,8 +477,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/nodes/{nodeName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_integration_runtime_object_metadata_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_integration_runtime_object_metadata_operations.py index cbcb34f1116b..0863f423f764 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_integration_runtime_object_metadata_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_integration_runtime_object_metadata_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,12 +15,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) 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 @@ -28,12 +29,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,9 +47,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -67,7 +65,7 @@ def build_list_request( "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -86,9 +84,7 @@ def build_refresh_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -105,7 +101,7 @@ def build_refresh_request( "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -116,7 +112,7 @@ def build_refresh_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class IntegrationRuntimeObjectMetadataOperations: +class IntegrationRuntimeObjectMetadataOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -163,7 +159,6 @@ def list( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. 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: SsisObjectMetadataListResponse or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SsisObjectMetadataListResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -175,7 +170,7 @@ def list( resource_group_name: str, workspace_name: str, integration_runtime_name: str, - get_metadata_request: Optional[IO] = None, + get_metadata_request: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -193,11 +188,10 @@ def list( :type integration_runtime_name: str :param get_metadata_request: The parameters for getting a SSIS object metadata. Default value is None. - :type get_metadata_request: IO + :type get_metadata_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 :return: SsisObjectMetadataListResponse or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SsisObjectMetadataListResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -209,7 +203,7 @@ def list( resource_group_name: str, workspace_name: str, integration_runtime_name: str, - get_metadata_request: Optional[Union[_models.GetSsisObjectMetadataRequest, IO]] = None, + get_metadata_request: Optional[Union[_models.GetSsisObjectMetadataRequest, IO[bytes]]] = None, **kwargs: Any ) -> _models.SsisObjectMetadataListResponse: """Get integration runtime object metadata. @@ -224,17 +218,14 @@ def list( :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str :param get_metadata_request: The parameters for getting a SSIS object metadata. Is either a - model type or a IO type. Default value is None. - :type get_metadata_request: ~azure.mgmt.synapse.models.GetSsisObjectMetadataRequest 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 + GetSsisObjectMetadataRequest type or a IO[bytes] type. Default value is None. + :type get_metadata_request: ~azure.mgmt.synapse.models.GetSsisObjectMetadataRequest or + IO[bytes] :return: SsisObjectMetadataListResponse or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SsisObjectMetadataListResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -245,16 +236,14 @@ def list( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SsisObjectMetadataListResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(get_metadata_request, (IO, bytes)): + if isinstance(get_metadata_request, (IOBase, bytes)): _content = get_metadata_request else: if get_metadata_request is not None: @@ -262,7 +251,7 @@ def list( else: _json = None - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, @@ -271,15 +260,14 @@ def list( content_type=content_type, json=_json, content=_content, - 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) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -289,21 +277,17 @@ def list( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SsisObjectMetadataListResponse", pipeline_response) + deserialized = self._deserialize("SsisObjectMetadataListResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/getObjectMetadata" - } + return deserialized # type: ignore def _refresh_initial( self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any - ) -> Optional[_models.SsisObjectMetadataStatusResponse]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -314,47 +298,43 @@ def _refresh_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) - cls: ClsType[Optional[_models.SsisObjectMetadataStatusResponse]] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_refresh_request( + _request = build_refresh_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._refresh_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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 - if response.status_code == 200: - deserialized = self._deserialize("SsisObjectMetadataStatusResponse", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _refresh_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/refreshObjectMetadata" - } + return deserialized # type: ignore @distributed_trace def begin_refresh( @@ -371,14 +351,6 @@ def begin_refresh( :type workspace_name: str :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_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 SsisObjectMetadataStatusResponse or the result of cls(response) :rtype: @@ -388,9 +360,7 @@ def begin_refresh( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.SsisObjectMetadataStatusResponse] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -406,12 +376,13 @@ def begin_refresh( 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("SsisObjectMetadataStatusResponse", pipeline_response) + deserialized = self._deserialize("SsisObjectMetadataStatusResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -423,14 +394,12 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.SsisObjectMetadataStatusResponse].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_refresh.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/refreshObjectMetadata" - } + return LROPoller[_models.SsisObjectMetadataStatusResponse]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_integration_runtime_status_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_integration_runtime_status_operations.py index 88d3bf315112..72f650610c3a 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_integration_runtime_status_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_integration_runtime_status_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -18,20 +17,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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,9 +42,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -64,7 +59,7 @@ def build_get_request( "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -109,12 +104,11 @@ def get( :type workspace_name: str :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: IntegrationRuntimeStatusResponse or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeStatusResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -125,26 +119,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.IntegrationRuntimeStatusResponse] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -154,13 +145,9 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("IntegrationRuntimeStatusResponse", pipeline_response) + deserialized = self._deserialize("IntegrationRuntimeStatusResponse", 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.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/getStatus" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_integration_runtimes_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_integration_runtimes_operations.py index fd3b8ca2d263..4d274dec11a3 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_integration_runtimes_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_integration_runtimes_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,13 +16,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 @@ -29,12 +31,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -48,9 +49,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -68,7 +67,7 @@ def build_update_request( "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -93,9 +92,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -112,7 +109,7 @@ def build_get_request( "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -137,9 +134,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -157,7 +152,7 @@ def build_create_request( "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -178,9 +173,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -197,7 +190,7 @@ def build_delete_request( "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -214,9 +207,7 @@ def build_upgrade_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -233,7 +224,7 @@ def build_upgrade_request( "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -250,9 +241,7 @@ def build_list_by_workspace_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -268,7 +257,7 @@ def build_list_by_workspace_request( "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -285,9 +274,7 @@ def build_start_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -304,7 +291,7 @@ def build_start_request( "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -321,9 +308,7 @@ def build_stop_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -340,7 +325,7 @@ def build_stop_request( "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -351,15 +336,13 @@ def build_stop_request( return HttpRequest(method="POST", 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, workspace_name: str, integration_runtime_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: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -376,7 +359,7 @@ def build_list_outbound_network_dependencies_endpoints_request( "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -393,9 +376,7 @@ def build_enable_interactive_query_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -412,7 +393,7 @@ def build_enable_interactive_query_request( "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -429,9 +410,7 @@ def build_disable_interactive_query_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -448,7 +427,7 @@ def build_disable_interactive_query_request( "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -507,7 +486,6 @@ def 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 :return: IntegrationRuntimeResource or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeResource :raises ~azure.core.exceptions.HttpResponseError: @@ -519,7 +497,7 @@ def update( resource_group_name: str, workspace_name: str, integration_runtime_name: str, - update_integration_runtime_request: IO, + update_integration_runtime_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -537,11 +515,10 @@ def update( :type integration_runtime_name: str :param update_integration_runtime_request: The parameters for updating an integration runtime. Required. - :type update_integration_runtime_request: IO + :type update_integration_runtime_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 :return: IntegrationRuntimeResource or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeResource :raises ~azure.core.exceptions.HttpResponseError: @@ -553,7 +530,7 @@ def update( resource_group_name: str, workspace_name: str, integration_runtime_name: str, - update_integration_runtime_request: Union[_models.UpdateIntegrationRuntimeRequest, IO], + update_integration_runtime_request: Union[_models.UpdateIntegrationRuntimeRequest, IO[bytes]], **kwargs: Any ) -> _models.IntegrationRuntimeResource: """Update integration runtime. @@ -568,18 +545,14 @@ def update( :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str :param update_integration_runtime_request: The parameters for updating an integration runtime. - Is either a model type or a IO type. Required. + Is either a UpdateIntegrationRuntimeRequest type or a IO[bytes] type. Required. :type update_integration_runtime_request: - ~azure.mgmt.synapse.models.UpdateIntegrationRuntimeRequest 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.synapse.models.UpdateIntegrationRuntimeRequest or IO[bytes] :return: IntegrationRuntimeResource or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -590,21 +563,19 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IntegrationRuntimeResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(update_integration_runtime_request, (IO, bytes)): + if isinstance(update_integration_runtime_request, (IOBase, bytes)): _content = update_integration_runtime_request else: _json = self._serialize.body(update_integration_runtime_request, "UpdateIntegrationRuntimeRequest") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, @@ -613,15 +584,14 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -631,16 +601,12 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("IntegrationRuntimeResource", pipeline_response) + deserialized = self._deserialize("IntegrationRuntimeResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}" - } + return deserialized # type: ignore @distributed_trace def get( @@ -666,12 +632,11 @@ def get( If the ETag matches the existing entity tag, or if * was provided, then no content will be returned. Default value is None. :type if_none_match: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: IntegrationRuntimeResource or None or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeResource or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -682,27 +647,24 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[Optional[_models.IntegrationRuntimeResource]] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, subscription_id=self._config.subscription_id, if_none_match=if_none_match, 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -714,27 +676,23 @@ def get( deserialized = None if response.status_code == 200: - deserialized = self._deserialize("IntegrationRuntimeResource", pipeline_response) + deserialized = self._deserialize("IntegrationRuntimeResource", 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.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, - integration_runtime: Union[_models.IntegrationRuntimeResource, IO], + integration_runtime: Union[_models.IntegrationRuntimeResource, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any - ) -> Optional[_models.IntegrationRuntimeResource]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -745,21 +703,19 @@ def _create_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.IntegrationRuntimeResource]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(integration_runtime, (IO, bytes)): + if isinstance(integration_runtime, (IOBase, bytes)): _content = integration_runtime else: _json = self._serialize.body(integration_runtime, "IntegrationRuntimeResource") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, @@ -769,36 +725,34 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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=False, **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 - if response.status_code == 200: - deserialized = self._deserialize("IntegrationRuntimeResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}" - } + return deserialized # type: ignore @overload def begin_create( @@ -832,14 +786,6 @@ def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~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 IntegrationRuntimeResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.IntegrationRuntimeResource] @@ -852,7 +798,7 @@ def begin_create( resource_group_name: str, workspace_name: str, integration_runtime_name: str, - integration_runtime: IO, + integration_runtime: IO[bytes], if_match: Optional[str] = None, *, content_type: str = "application/json", @@ -870,7 +816,7 @@ def begin_create( :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str :param integration_runtime: Integration runtime resource definition. Required. - :type integration_runtime: IO + :type integration_runtime: IO[bytes] :param if_match: ETag of the integration runtime entity. Should only be specified for update, for which it should match existing entity or can be * for unconditional update. Default value is None. @@ -878,14 +824,6 @@ def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~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 IntegrationRuntimeResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.IntegrationRuntimeResource] @@ -898,7 +836,7 @@ def begin_create( resource_group_name: str, workspace_name: str, integration_runtime_name: str, - integration_runtime: Union[_models.IntegrationRuntimeResource, IO], + integration_runtime: Union[_models.IntegrationRuntimeResource, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any ) -> LROPoller[_models.IntegrationRuntimeResource]: @@ -913,24 +851,13 @@ def begin_create( :type workspace_name: str :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :param integration_runtime: Integration runtime resource definition. Is either a model type or - a IO type. Required. - :type integration_runtime: ~azure.mgmt.synapse.models.IntegrationRuntimeResource or IO + :param integration_runtime: Integration runtime resource definition. Is either a + IntegrationRuntimeResource type or a IO[bytes] type. Required. + :type integration_runtime: ~azure.mgmt.synapse.models.IntegrationRuntimeResource or IO[bytes] :param if_match: ETag of the integration runtime entity. Should only be specified for update, for which it should match existing entity or can be * for unconditional update. 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 IntegrationRuntimeResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.IntegrationRuntimeResource] @@ -939,9 +866,7 @@ def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IntegrationRuntimeResource] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -961,12 +886,13 @@ def begin_create( 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("IntegrationRuntimeResource", pipeline_response) + deserialized = self._deserialize("IntegrationRuntimeResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -976,22 +902,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.IntegrationRuntimeResource].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}" - } + return LROPoller[_models.IntegrationRuntimeResource]( + 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, workspace_name: str, integration_runtime_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1002,41 +926,43 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -1053,14 +979,6 @@ def begin_delete( :type workspace_name: str :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_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: @@ -1068,15 +986,13 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, @@ -1086,11 +1002,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)) @@ -1099,17 +1016,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.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def upgrade( # pylint: disable=inconsistent-return-statements @@ -1126,12 +1039,11 @@ def upgrade( # pylint: disable=inconsistent-return-statements :type workspace_name: str :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1142,26 +1054,23 @@ def upgrade( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_upgrade_request( + _request = build_upgrade_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.upgrade.metadata["url"], 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1172,11 +1081,7 @@ def upgrade( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - upgrade.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/upgrade" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list_by_workspace( @@ -1191,7 +1096,6 @@ def list_by_workspace( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either IntegrationRuntimeResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.IntegrationRuntimeResource] @@ -1200,12 +1104,10 @@ def list_by_workspace( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.IntegrationRuntimeListResponse] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1216,24 +1118,21 @@ def list_by_workspace( def prepare_request(next_link=None): if not next_link: - request = build_list_by_workspace_request( + _request = build_list_by_workspace_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_workspace.metadata["url"], 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("IntegrationRuntimeListResponse", pipeline_response) @@ -1243,10 +1142,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1259,14 +1159,10 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_workspace.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes" - } - def _start_initial( self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any - ) -> Optional[_models.IntegrationRuntimeStatusResponse]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1277,47 +1173,43 @@ def _start_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) - cls: ClsType[Optional[_models.IntegrationRuntimeStatusResponse]] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_start_request( + _request = build_start_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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 - if response.status_code == 200: - deserialized = self._deserialize("IntegrationRuntimeStatusResponse", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _start_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/start" - } + return deserialized # type: ignore @distributed_trace def begin_start( @@ -1334,14 +1226,6 @@ def begin_start( :type workspace_name: str :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_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 IntegrationRuntimeStatusResponse or the result of cls(response) :rtype: @@ -1351,9 +1235,7 @@ def begin_start( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.IntegrationRuntimeStatusResponse] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -1369,12 +1251,13 @@ def begin_start( 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("IntegrationRuntimeStatusResponse", pipeline_response) + deserialized = self._deserialize("IntegrationRuntimeStatusResponse", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1386,22 +1269,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.IntegrationRuntimeStatusResponse].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_start.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/start" - } + return LROPoller[_models.IntegrationRuntimeStatusResponse]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _stop_initial( # pylint: disable=inconsistent-return-statements + def _stop_initial( self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1412,41 +1293,43 @@ def _stop_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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 = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _stop_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/stop" - } + return deserialized # type: ignore @distributed_trace def begin_stop( @@ -1463,14 +1346,6 @@ def begin_stop( :type workspace_name: str :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_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: @@ -1478,15 +1353,13 @@ def begin_stop( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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._stop_initial( # type: ignore + raw_result = self._stop_initial( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, @@ -1496,11 +1369,12 @@ def begin_stop( 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)) @@ -1509,20 +1383,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.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/stop" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace - def list_outbound_network_dependencies_endpoints( + def list_outbound_network_dependencies_endpoints( # pylint: disable=name-too-long self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any ) -> _models.IntegrationRuntimeOutboundNetworkDependenciesEndpointsResponse: """Gets list of outbound network dependencies for a given Azure-SSIS integration runtime. @@ -1536,14 +1406,13 @@ def list_outbound_network_dependencies_endpoints( :type workspace_name: str :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: IntegrationRuntimeOutboundNetworkDependenciesEndpointsResponse or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeOutboundNetworkDependenciesEndpointsResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1554,26 +1423,23 @@ def list_outbound_network_dependencies_endpoints( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.IntegrationRuntimeOutboundNetworkDependenciesEndpointsResponse] = kwargs.pop("cls", None) - request = build_list_outbound_network_dependencies_endpoints_request( + _request = build_list_outbound_network_dependencies_endpoints_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_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) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1584,22 +1450,18 @@ def list_outbound_network_dependencies_endpoints( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize( - "IntegrationRuntimeOutboundNetworkDependenciesEndpointsResponse", pipeline_response + "IntegrationRuntimeOutboundNetworkDependenciesEndpointsResponse", pipeline_response.http_response ) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_outbound_network_dependencies_endpoints.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/outboundNetworkDependenciesEndpoints" - } + return deserialized # type: ignore - def _enable_interactive_query_initial( # pylint: disable=inconsistent-return-statements + def _enable_interactive_query_initial( self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1610,41 +1472,43 @@ def _enable_interactive_query_initial( # pylint: disable=inconsistent-return-st _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_enable_interactive_query_request( + _request = build_enable_interactive_query_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._enable_interactive_query_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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 = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _enable_interactive_query_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/enableInteractiveQuery" - } + return deserialized # type: ignore @distributed_trace def begin_enable_interactive_query( @@ -1659,14 +1523,6 @@ def begin_enable_interactive_query( :type workspace_name: str :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_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: @@ -1674,15 +1530,13 @@ def begin_enable_interactive_query( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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._enable_interactive_query_initial( # type: ignore + raw_result = self._enable_interactive_query_initial( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, @@ -1692,11 +1546,12 @@ def begin_enable_interactive_query( 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)) @@ -1705,22 +1560,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_enable_interactive_query.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/enableInteractiveQuery" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _disable_interactive_query_initial( # pylint: disable=inconsistent-return-statements + def _disable_interactive_query_initial( self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1731,41 +1582,43 @@ def _disable_interactive_query_initial( # pylint: disable=inconsistent-return-s _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_disable_interactive_query_request( + _request = build_disable_interactive_query_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._disable_interactive_query_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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 = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _disable_interactive_query_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/disableInteractiveQuery" - } + return deserialized # type: ignore @distributed_trace def begin_disable_interactive_query( @@ -1780,14 +1633,6 @@ def begin_disable_interactive_query( :type workspace_name: str :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_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: @@ -1795,15 +1640,13 @@ def begin_disable_interactive_query( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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._disable_interactive_query_initial( # type: ignore + raw_result = self._disable_interactive_query_initial( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, @@ -1813,11 +1656,12 @@ def begin_disable_interactive_query( 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)) @@ -1826,14 +1670,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_disable_interactive_query.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/disableInteractiveQuery" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_ip_firewall_rules_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_ip_firewall_rules_operations.py index 38aee0ae318d..a880f1cca877 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_ip_firewall_rules_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_ip_firewall_rules_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,13 +15,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 @@ -29,12 +30,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -48,7 +48,7 @@ def build_list_by_workspace_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -64,7 +64,7 @@ def build_list_by_workspace_request( "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -81,7 +81,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: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -99,7 +99,7 @@ def build_create_or_update_request( "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -118,7 +118,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -135,7 +135,7 @@ def build_delete_request( "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -152,7 +152,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -169,7 +169,7 @@ def build_get_request( "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -186,7 +186,7 @@ def build_replace_all_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -203,7 +203,7 @@ def build_replace_all_request( "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -246,7 +246,6 @@ def list_by_workspace( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either IpFirewallRuleInfo or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.IpFirewallRuleInfo] :raises ~azure.core.exceptions.HttpResponseError: @@ -254,10 +253,10 @@ def list_by_workspace( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.IpFirewallRuleInfoListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -268,24 +267,21 @@ def list_by_workspace( def prepare_request(next_link=None): if not next_link: - request = build_list_by_workspace_request( + _request = build_list_by_workspace_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_workspace.metadata["url"], 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("IpFirewallRuleInfoListResult", pipeline_response) @@ -295,10 +291,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -311,19 +308,15 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_workspace.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/firewallRules" - } - def _create_or_update_initial( self, resource_group_name: str, workspace_name: str, rule_name: str, - ip_firewall_rule_info: Union[_models.IpFirewallRuleInfo, IO], + ip_firewall_rule_info: Union[_models.IpFirewallRuleInfo, IO[bytes]], **kwargs: Any - ) -> Optional[_models.IpFirewallRuleInfo]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -334,19 +327,19 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.IpFirewallRuleInfo]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(ip_firewall_rule_info, (IO, bytes)): + if isinstance(ip_firewall_rule_info, (IOBase, bytes)): _content = ip_firewall_rule_info else: _json = self._serialize.body(ip_firewall_rule_info, "IpFirewallRuleInfo") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, rule_name=rule_name, @@ -355,39 +348,34 @@ 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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("IpFirewallRuleInfo", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("IpFirewallRuleInfo", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/firewallRules/{ruleName}" - } + return deserialized # type: ignore @overload def begin_create_or_update( @@ -414,14 +402,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 IpFirewallRuleInfo or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.IpFirewallRuleInfo] @@ -434,7 +414,7 @@ def begin_create_or_update( resource_group_name: str, workspace_name: str, rule_name: str, - ip_firewall_rule_info: IO, + ip_firewall_rule_info: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -449,18 +429,10 @@ def begin_create_or_update( :param rule_name: The IP firewall rule name. Required. :type rule_name: str :param ip_firewall_rule_info: IP firewall rule properties. Required. - :type ip_firewall_rule_info: IO + :type ip_firewall_rule_info: 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 IpFirewallRuleInfo or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.IpFirewallRuleInfo] @@ -473,7 +445,7 @@ def begin_create_or_update( resource_group_name: str, workspace_name: str, rule_name: str, - ip_firewall_rule_info: Union[_models.IpFirewallRuleInfo, IO], + ip_firewall_rule_info: Union[_models.IpFirewallRuleInfo, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.IpFirewallRuleInfo]: """Creates or updates a firewall rule. @@ -485,20 +457,9 @@ def begin_create_or_update( :type workspace_name: str :param rule_name: The IP firewall rule name. Required. :type rule_name: str - :param ip_firewall_rule_info: IP firewall rule properties. Is either a model type or a IO type. - Required. - :type ip_firewall_rule_info: ~azure.mgmt.synapse.models.IpFirewallRuleInfo 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 ip_firewall_rule_info: IP firewall rule properties. Is either a IpFirewallRuleInfo type + or a IO[bytes] type. Required. + :type ip_firewall_rule_info: ~azure.mgmt.synapse.models.IpFirewallRuleInfo or IO[bytes] :return: An instance of LROPoller that returns either IpFirewallRuleInfo or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.IpFirewallRuleInfo] @@ -507,7 +468,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IpFirewallRuleInfo] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -526,12 +487,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("IpFirewallRuleInfo", pipeline_response) + deserialized = self._deserialize("IpFirewallRuleInfo", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -543,22 +505,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.IpFirewallRuleInfo].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.Synapse/workspaces/{workspaceName}/firewallRules/{ruleName}" - } + return LROPoller[_models.IpFirewallRuleInfo]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _delete_initial( self, resource_group_name: str, workspace_name: str, rule_name: str, **kwargs: Any - ) -> Optional[_models.IpFirewallRuleInfo]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -569,45 +529,43 @@ def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - cls: ClsType[Optional[_models.IpFirewallRuleInfo]] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_name, rule_name=rule_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("IpFirewallRuleInfo", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/firewallRules/{ruleName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -622,14 +580,6 @@ def begin_delete( :type workspace_name: str :param rule_name: The IP firewall rule name. Required. :type rule_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 IpFirewallRuleInfo or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.IpFirewallRuleInfo] @@ -638,7 +588,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.IpFirewallRuleInfo] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -654,12 +604,13 @@ 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): - deserialized = self._deserialize("IpFirewallRuleInfo", pipeline_response) + deserialized = self._deserialize("IpFirewallRuleInfo", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -671,17 +622,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.IpFirewallRuleInfo].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.Synapse/workspaces/{workspaceName}/firewallRules/{ruleName}" - } + return LROPoller[_models.IpFirewallRuleInfo]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def get( @@ -696,12 +645,11 @@ def get( :type workspace_name: str :param rule_name: The IP firewall rule name. Required. :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: IpFirewallRuleInfo or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IpFirewallRuleInfo :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -712,24 +660,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.IpFirewallRuleInfo] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, rule_name=rule_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -739,25 +686,21 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("IpFirewallRuleInfo", pipeline_response) + deserialized = self._deserialize("IpFirewallRuleInfo", 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.Synapse/workspaces/{workspaceName}/firewallRules/{ruleName}" - } + return deserialized # type: ignore def _replace_all_initial( self, resource_group_name: str, workspace_name: str, - request: Union[_models.ReplaceAllIpFirewallRulesRequest, IO], + request: Union[_models.ReplaceAllIpFirewallRulesRequest, IO[bytes]], **kwargs: Any - ) -> Optional[_models.ReplaceAllFirewallRulesOperationResponse]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -768,19 +711,19 @@ def _replace_all_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.ReplaceAllFirewallRulesOperationResponse]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(request, (IO, bytes)): + if isinstance(request, (IOBase, bytes)): _content = request else: _json = self._serialize.body(request, "ReplaceAllIpFirewallRulesRequest") - request = build_replace_all_request( + _request = build_replace_all_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, @@ -788,36 +731,34 @@ def _replace_all_initial( content_type=content_type, json=_json, content=_content, - template_url=self._replace_all_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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 - if response.status_code == 200: - deserialized = self._deserialize("ReplaceAllFirewallRulesOperationResponse", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _replace_all_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/replaceAllIpFirewallRules" - } + return deserialized # type: ignore @overload def begin_replace_all( @@ -841,14 +782,6 @@ def begin_replace_all( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~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 ReplaceAllFirewallRulesOperationResponse or the result of cls(response) :rtype: @@ -861,7 +794,7 @@ def begin_replace_all( self, resource_group_name: str, workspace_name: str, - request: IO, + request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -874,18 +807,10 @@ def begin_replace_all( :param workspace_name: The name of the workspace. Required. :type workspace_name: str :param request: Replace all IP firewall rules request. Required. - :type request: IO + :type 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 ReplaceAllFirewallRulesOperationResponse or the result of cls(response) :rtype: @@ -898,7 +823,7 @@ def begin_replace_all( self, resource_group_name: str, workspace_name: str, - request: Union[_models.ReplaceAllIpFirewallRulesRequest, IO], + request: Union[_models.ReplaceAllIpFirewallRulesRequest, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.ReplaceAllFirewallRulesOperationResponse]: """Replaces firewall rules. @@ -908,20 +833,9 @@ def begin_replace_all( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param request: Replace all IP firewall rules request. Is either a model type or a IO type. - Required. - :type request: ~azure.mgmt.synapse.models.ReplaceAllIpFirewallRulesRequest 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 request: Replace all IP firewall rules request. Is either a + ReplaceAllIpFirewallRulesRequest type or a IO[bytes] type. Required. + :type request: ~azure.mgmt.synapse.models.ReplaceAllIpFirewallRulesRequest or IO[bytes] :return: An instance of LROPoller that returns either ReplaceAllFirewallRulesOperationResponse or the result of cls(response) :rtype: @@ -931,7 +845,7 @@ def begin_replace_all( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ReplaceAllFirewallRulesOperationResponse] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -949,12 +863,15 @@ def begin_replace_all( 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("ReplaceAllFirewallRulesOperationResponse", pipeline_response) + deserialized = self._deserialize( + "ReplaceAllFirewallRulesOperationResponse", pipeline_response.http_response + ) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -966,14 +883,12 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.ReplaceAllFirewallRulesOperationResponse].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_replace_all.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/replaceAllIpFirewallRules" - } + return LROPoller[_models.ReplaceAllFirewallRulesOperationResponse]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_keys_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_keys_operations.py index 42bc387ee928..9c6fe992d25e 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_keys_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_keys_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload @@ -19,20 +19,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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -46,7 +44,7 @@ def build_list_by_workspace_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -62,7 +60,7 @@ def build_list_by_workspace_request( "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -79,7 +77,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -96,7 +94,7 @@ def build_get_request( "keyName": _SERIALIZER.url("key_name", key_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -113,7 +111,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: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -131,7 +129,7 @@ def build_create_or_update_request( "keyName": _SERIALIZER.url("key_name", key_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -150,7 +148,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -167,7 +165,7 @@ def build_delete_request( "keyName": _SERIALIZER.url("key_name", key_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -208,7 +206,6 @@ def list_by_workspace( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Key or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.Key] :raises ~azure.core.exceptions.HttpResponseError: @@ -216,10 +213,10 @@ def list_by_workspace( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.KeyInfoListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -230,24 +227,21 @@ def list_by_workspace( def prepare_request(next_link=None): if not next_link: - request = build_list_by_workspace_request( + _request = build_list_by_workspace_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_workspace.metadata["url"], 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("KeyInfoListResult", pipeline_response) @@ -257,10 +251,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -273,10 +268,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_workspace.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/keys" - } - @distributed_trace def get(self, resource_group_name: str, workspace_name: str, key_name: str, **kwargs: Any) -> _models.Key: """Gets a workspace key. @@ -288,12 +279,11 @@ def get(self, resource_group_name: str, workspace_name: str, key_name: str, **kw :type workspace_name: str :param key_name: The name of the workspace key. Required. :type key_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Key or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -304,24 +294,23 @@ def get(self, resource_group_name: str, workspace_name: str, key_name: str, **kw _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.Key] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, key_name=key_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -331,16 +320,12 @@ def get(self, resource_group_name: str, workspace_name: str, key_name: str, **kw error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Key", pipeline_response) + deserialized = self._deserialize("Key", 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.Synapse/workspaces/{workspaceName}/keys/{keyName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -367,7 +352,6 @@ def 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 :return: Key or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.Key :raises ~azure.core.exceptions.HttpResponseError: @@ -379,7 +363,7 @@ def create_or_update( resource_group_name: str, workspace_name: str, key_name: str, - key_properties: IO, + key_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -394,11 +378,10 @@ def create_or_update( :param key_name: The name of the workspace key. Required. :type key_name: str :param key_properties: Key put request properties. Required. - :type key_properties: IO + :type key_properties: 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: Key or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.Key :raises ~azure.core.exceptions.HttpResponseError: @@ -410,7 +393,7 @@ def create_or_update( resource_group_name: str, workspace_name: str, key_name: str, - key_properties: Union[_models.Key, IO], + key_properties: Union[_models.Key, IO[bytes]], **kwargs: Any ) -> _models.Key: """Creates or updates a workspace key. @@ -422,18 +405,14 @@ def create_or_update( :type workspace_name: str :param key_name: The name of the workspace key. Required. :type key_name: str - :param key_properties: Key put request properties. Is either a model type or a IO type. + :param key_properties: Key put request properties. Is either a Key type or a IO[bytes] type. Required. - :type key_properties: ~azure.mgmt.synapse.models.Key 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 key_properties: ~azure.mgmt.synapse.models.Key or IO[bytes] :return: Key or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.Key :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -444,19 +423,19 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Key] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(key_properties, (IO, bytes)): + if isinstance(key_properties, (IOBase, bytes)): _content = key_properties else: _json = self._serialize.body(key_properties, "Key") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, key_name=key_name, @@ -465,15 +444,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -483,16 +461,12 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Key", pipeline_response) + deserialized = self._deserialize("Key", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/keys/{keyName}" - } + return deserialized # type: ignore @distributed_trace def delete( @@ -507,12 +481,11 @@ def delete( :type workspace_name: str :param key_name: The name of the workspace key. Required. :type key_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Key or None or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.Key or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -523,24 +496,23 @@ def delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[Optional[_models.Key]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_name, key_name=key_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -552,13 +524,9 @@ def delete( deserialized = None if response.status_code == 200: - deserialized = self._deserialize("Key", pipeline_response) + deserialized = self._deserialize("Key", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/keys/{keyName}" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_kusto_operations_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_kusto_operations_operations.py index 1b1b444f8097..a4a71bb71400 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_kusto_operations_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_kusto_operations_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -19,20 +18,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, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -44,9 +41,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: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -84,7 +79,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists available operations for the Kusto sub-resources inside Microsoft.Synapse 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.synapse.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -92,12 +86,10 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -108,21 +100,18 @@ 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) @@ -132,10 +121,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -147,5 +137,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Synapse/kustooperations"} diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_kusto_pool_attached_database_configurations_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_kusto_pool_attached_database_configurations_operations.py index 595f27113d10..ac18f576ec20 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_kusto_pool_attached_database_configurations_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_kusto_pool_attached_database_configurations_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,13 +15,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 @@ -29,12 +30,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -48,9 +48,7 @@ def build_list_by_kusto_pool_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -67,7 +65,7 @@ def build_list_by_kusto_pool_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -89,9 +87,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -111,7 +107,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -133,9 +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: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -156,7 +150,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -180,9 +174,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -202,7 +194,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -213,7 +205,7 @@ def build_delete_request( return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -class KustoPoolAttachedDatabaseConfigurationsOperations: +class KustoPoolAttachedDatabaseConfigurationsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -245,7 +237,6 @@ def list_by_kusto_pool( :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 AttachedDatabaseConfiguration or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.AttachedDatabaseConfiguration] @@ -254,12 +245,10 @@ def list_by_kusto_pool( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.AttachedDatabaseConfigurationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -270,25 +259,22 @@ def list_by_kusto_pool( def prepare_request(next_link=None): if not next_link: - request = build_list_by_kusto_pool_request( + _request = build_list_by_kusto_pool_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_kusto_pool.metadata["url"], 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AttachedDatabaseConfigurationListResult", pipeline_response) @@ -298,10 +284,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -314,10 +301,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_kusto_pool.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations" - } - @distributed_trace def get( self, @@ -339,12 +322,11 @@ def get( :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: AttachedDatabaseConfiguration or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.AttachedDatabaseConfiguration :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -355,27 +337,24 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.AttachedDatabaseConfiguration] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, attached_database_configuration_name=attached_database_configuration_name, resource_group_name=resource_group_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -385,16 +364,12 @@ 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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, @@ -402,10 +377,10 @@ def _create_or_update_initial( kusto_pool_name: str, attached_database_configuration_name: str, resource_group_name: str, - parameters: Union[_models.AttachedDatabaseConfiguration, IO], + parameters: Union[_models.AttachedDatabaseConfiguration, IO[bytes]], **kwargs: Any - ) -> _models.AttachedDatabaseConfiguration: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -416,21 +391,19 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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 _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "AttachedDatabaseConfiguration") - request = build_create_or_update_request( + _request = build_create_or_update_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, attached_database_configuration_name=attached_database_configuration_name, @@ -440,42 +413,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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) - 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: - deserialized = self._deserialize("AttachedDatabaseConfiguration", 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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}" - } - @overload def begin_create_or_update( self, @@ -505,14 +471,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.synapse.models.AttachedDatabaseConfiguration] @@ -526,7 +484,7 @@ def begin_create_or_update( kusto_pool_name: str, attached_database_configuration_name: str, resource_group_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -544,18 +502,10 @@ def begin_create_or_update( Required. :type resource_group_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.synapse.models.AttachedDatabaseConfiguration] @@ -569,7 +519,7 @@ def begin_create_or_update( kusto_pool_name: str, attached_database_configuration_name: str, resource_group_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. @@ -585,19 +535,8 @@ def begin_create_or_update( Required. :type resource_group_name: str :param parameters: The database parameters supplied to the CreateOrUpdate operation. Is either - a model type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.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.synapse.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.synapse.models.AttachedDatabaseConfiguration] @@ -606,9 +545,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AttachedDatabaseConfiguration] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -628,12 +565,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: @@ -643,27 +581,25 @@ 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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/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, workspace_name: str, kusto_pool_name: str, attached_database_configuration_name: str, resource_group_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -674,42 +610,44 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, attached_database_configuration_name=attached_database_configuration_name, resource_group_name=resource_group_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -732,14 +670,6 @@ def begin_delete( :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 - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~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: @@ -747,15 +677,13 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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._delete_initial( # type: ignore + raw_result = self._delete_initial( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, attached_database_configuration_name=attached_database_configuration_name, @@ -766,11 +694,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)) @@ -779,14 +708,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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_kusto_pool_child_resource_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_kusto_pool_child_resource_operations.py index 2ca98b9f7d71..306e5fca8aba 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_kusto_pool_child_resource_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_kusto_pool_child_resource_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload @@ -18,20 +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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,9 +43,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: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -65,7 +61,7 @@ def build_check_name_availability_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -122,7 +118,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.synapse.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: @@ -134,7 +129,7 @@ def check_name_availability( workspace_name: str, kusto_pool_name: str, resource_group_name: str, - resource_name: IO, + resource_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -149,11 +144,10 @@ def check_name_availability( Required. :type resource_group_name: str :param resource_name: The name of the Kusto Pool child 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.synapse.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: @@ -165,7 +159,7 @@ def check_name_availability( workspace_name: str, kusto_pool_name: str, resource_group_name: str, - resource_name: Union[_models.DatabaseCheckNameRequest, IO], + resource_name: Union[_models.DatabaseCheckNameRequest, IO[bytes]], **kwargs: Any ) -> _models.CheckNameResult: """Checks that the Kusto Pool child resource name is valid and is not already in use. @@ -177,18 +171,14 @@ def check_name_availability( :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param resource_name: The name of the Kusto Pool child resource. Is either a model type or a IO - type. Required. - :type resource_name: ~azure.mgmt.synapse.models.DatabaseCheckNameRequest 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 Kusto Pool child resource. Is either a + DatabaseCheckNameRequest type or a IO[bytes] type. Required. + :type resource_name: ~azure.mgmt.synapse.models.DatabaseCheckNameRequest or IO[bytes] :return: CheckNameResult or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -199,21 +189,19 @@ def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CheckNameResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(resource_name, (IO, bytes)): + if isinstance(resource_name, (IOBase, bytes)): _content = resource_name else: _json = self._serialize.body(resource_name, "DatabaseCheckNameRequest") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_name, @@ -222,15 +210,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -240,13 +227,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 cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - check_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/checkNameAvailability" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_kusto_pool_data_connections_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_kusto_pool_data_connections_operations.py index c71ea524ff88..1f0d9e83c277 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_kusto_pool_data_connections_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_kusto_pool_data_connections_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,13 +16,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 @@ -29,12 +31,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,9 +54,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: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -74,7 +73,7 @@ def build_check_name_availability_request( "databaseName": _SERIALIZER.url("database_name", database_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -98,9 +97,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: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -119,7 +116,7 @@ def build_data_connection_validation_request( "databaseName": _SERIALIZER.url("database_name", database_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -143,9 +140,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: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -163,7 +158,7 @@ def build_list_by_database_request( "databaseName": _SERIALIZER.url("database_name", database_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -186,9 +181,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -207,7 +200,7 @@ def build_get_request( "dataConnectionName": _SERIALIZER.url("data_connection_name", data_connection_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -230,9 +223,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: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -252,7 +243,7 @@ def build_create_or_update_request( "dataConnectionName": _SERIALIZER.url("data_connection_name", data_connection_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -277,9 +268,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -299,7 +288,7 @@ def build_update_request( "dataConnectionName": _SERIALIZER.url("data_connection_name", data_connection_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -324,9 +313,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -345,7 +332,7 @@ def build_delete_request( "dataConnectionName": _SERIALIZER.url("data_connection_name", data_connection_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -403,7 +390,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.synapse.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: @@ -416,7 +402,7 @@ def check_name_availability( workspace_name: str, kusto_pool_name: str, database_name: str, - data_connection_name: IO, + data_connection_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -433,11 +419,10 @@ def check_name_availability( :param database_name: The name of the database in the Kusto pool. 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.synapse.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: @@ -450,7 +435,7 @@ def check_name_availability( workspace_name: str, kusto_pool_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. @@ -464,18 +449,15 @@ def check_name_availability( :type kusto_pool_name: str :param database_name: The name of the database in the Kusto pool. Required. :type database_name: str - :param data_connection_name: The name of the data connection. Is either a model type or a IO - type. Required. - :type data_connection_name: ~azure.mgmt.synapse.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 + :param data_connection_name: The name of the data connection. Is either a + DataConnectionCheckNameRequest type or a IO[bytes] type. Required. + :type data_connection_name: ~azure.mgmt.synapse.models.DataConnectionCheckNameRequest or + IO[bytes] :return: CheckNameResult or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -486,21 +468,19 @@ def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CheckNameResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(data_connection_name, (IO, bytes)): + if isinstance(data_connection_name, (IOBase, bytes)): _content = data_connection_name 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, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, @@ -510,15 +490,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -528,16 +507,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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/checkNameAvailability" - } + return deserialized # type: ignore def _data_connection_validation_initial( self, @@ -545,10 +520,10 @@ def _data_connection_validation_initial( workspace_name: str, kusto_pool_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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -559,21 +534,19 @@ def _data_connection_validation_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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 _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters 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, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, @@ -583,36 +556,34 @@ 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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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 - if response.status_code == 200: - deserialized = self._deserialize("DataConnectionValidationListResult", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _data_connection_validation_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnectionValidation" - } + return deserialized # type: ignore @overload def begin_data_connection_validation( @@ -643,14 +614,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: @@ -665,7 +628,7 @@ def begin_data_connection_validation( workspace_name: str, kusto_pool_name: str, database_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -683,18 +646,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: @@ -709,7 +664,7 @@ def begin_data_connection_validation( workspace_name: str, kusto_pool_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. @@ -724,19 +679,8 @@ def begin_data_connection_validation( :param database_name: The name of the database in the Kusto pool. Required. :type database_name: str :param parameters: The data connection parameters supplied to the CreateOrUpdate operation. Is - either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.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.synapse.models.DataConnectionValidation or IO[bytes] :return: An instance of LROPoller that returns either DataConnectionValidationListResult or the result of cls(response) :rtype: @@ -746,9 +690,7 @@ def begin_data_connection_validation( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DataConnectionValidationListResult] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -768,12 +710,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: @@ -785,17 +728,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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnectionValidation" - } + return LROPoller[_models.DataConnectionValidationListResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list_by_database( @@ -812,7 +753,6 @@ def list_by_database( :type kusto_pool_name: str :param database_name: The name of the database in the Kusto pool. 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.synapse.models.DataConnection] :raises ~azure.core.exceptions.HttpResponseError: @@ -820,12 +760,10 @@ def list_by_database( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.DataConnectionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -836,26 +774,23 @@ 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, workspace_name=workspace_name, kusto_pool_name=kusto_pool_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DataConnectionListResult", pipeline_response) @@ -865,10 +800,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -881,10 +817,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_database.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections" - } - @distributed_trace def get( self, @@ -908,12 +840,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.synapse.models.DataConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -924,12 +855,10 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.DataConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, @@ -937,15 +866,14 @@ def get( 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -955,16 +883,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 deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, @@ -973,10 +897,10 @@ def _create_or_update_initial( kusto_pool_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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -987,21 +911,19 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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 _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters 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, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, @@ -1012,39 +934,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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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("DataConnection", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DataConnection", 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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}" - } - @overload def begin_create_or_update( self, @@ -1077,14 +995,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.synapse.models.DataConnection] @@ -1099,7 +1009,7 @@ def begin_create_or_update( kusto_pool_name: str, database_name: str, data_connection_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1119,18 +1029,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.synapse.models.DataConnection] @@ -1145,7 +1047,7 @@ def begin_create_or_update( kusto_pool_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. @@ -1162,19 +1064,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 model type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.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.synapse.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.synapse.models.DataConnection] @@ -1183,9 +1074,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DataConnection] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1206,12 +1095,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: @@ -1221,17 +1111,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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}" - } + return LROPoller[_models.DataConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, @@ -1240,10 +1128,10 @@ def _update_initial( kusto_pool_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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1254,21 +1142,19 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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 _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DataConnection") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, @@ -1279,39 +1165,35 @@ 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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) - if response.status_code == 200: - deserialized = self._deserialize("DataConnection", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("DataConnection", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}" - } - @overload def begin_update( self, @@ -1343,14 +1225,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.synapse.models.DataConnection] @@ -1365,7 +1239,7 @@ def begin_update( kusto_pool_name: str, database_name: str, data_connection_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1384,18 +1258,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.synapse.models.DataConnection] @@ -1410,7 +1276,7 @@ def begin_update( kusto_pool_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. @@ -1427,19 +1293,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 - model type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.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.synapse.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.synapse.models.DataConnection] @@ -1448,9 +1303,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DataConnection] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1471,12 +1324,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: @@ -1486,19 +1340,17 @@ 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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/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, workspace_name: str, @@ -1506,8 +1358,8 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements database_name: str, data_connection_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1518,12 +1370,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, @@ -1531,30 +1381,34 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -1579,14 +1433,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: @@ -1594,15 +1440,13 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, @@ -1614,11 +1458,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)) @@ -1627,14 +1472,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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_kusto_pool_database_principal_assignments_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_kusto_pool_database_principal_assignments_operations.py index 63de4ff00998..681f8e8173cd 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_kusto_pool_database_principal_assignments_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_kusto_pool_database_principal_assignments_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,13 +15,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 @@ -29,12 +30,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,9 +53,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: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -74,7 +72,7 @@ def build_check_name_availability_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -98,9 +96,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -118,7 +114,7 @@ def build_list_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -141,9 +137,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -162,7 +156,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -185,9 +179,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: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -207,7 +199,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -232,9 +224,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -253,7 +243,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -264,7 +254,7 @@ def build_delete_request( return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -class KustoPoolDatabasePrincipalAssignmentsOperations: +class KustoPoolDatabasePrincipalAssignmentsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -312,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.synapse.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: @@ -325,7 +314,7 @@ def check_name_availability( kusto_pool_name: str, database_name: str, resource_group_name: str, - principal_assignment_name: IO, + principal_assignment_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -342,11 +331,10 @@ def check_name_availability( Required. :type resource_group_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.synapse.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: @@ -359,7 +347,7 @@ def check_name_availability( kusto_pool_name: str, database_name: str, resource_group_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. @@ -373,19 +361,15 @@ def check_name_availability( :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param principal_assignment_name: The name of the resource. Is either a model type or a IO - type. Required. + :param principal_assignment_name: The name of the resource. Is either a + DatabasePrincipalAssignmentCheckNameRequest type or a IO[bytes] type. Required. :type principal_assignment_name: - ~azure.mgmt.synapse.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.synapse.models.DatabasePrincipalAssignmentCheckNameRequest or IO[bytes] :return: CheckNameResult or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -396,21 +380,19 @@ def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CheckNameResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(principal_assignment_name, (IO, bytes)): + if isinstance(principal_assignment_name, (IOBase, bytes)): _content = principal_assignment_name else: _json = self._serialize.body(principal_assignment_name, "DatabasePrincipalAssignmentCheckNameRequest") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, database_name=database_name, @@ -420,15 +402,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -438,16 +419,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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/checkPrincipalAssignmentNameAvailability" - } + return deserialized # type: ignore @distributed_trace def list( @@ -464,7 +441,6 @@ def list( :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 DatabasePrincipalAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.DatabasePrincipalAssignment] @@ -473,12 +449,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.DatabasePrincipalAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -489,26 +463,23 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, database_name=database_name, resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DatabasePrincipalAssignmentListResult", pipeline_response) @@ -518,10 +489,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -534,10 +506,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments" - } - @distributed_trace def get( self, @@ -561,12 +529,11 @@ def get( :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: DatabasePrincipalAssignment or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.DatabasePrincipalAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -577,12 +544,10 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.DatabasePrincipalAssignment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, database_name=database_name, @@ -590,15 +555,14 @@ def get( resource_group_name=resource_group_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -608,16 +572,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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, @@ -626,10 +586,10 @@ def _create_or_update_initial( database_name: str, principal_assignment_name: str, resource_group_name: str, - parameters: Union[_models.DatabasePrincipalAssignment, IO], + parameters: Union[_models.DatabasePrincipalAssignment, IO[bytes]], **kwargs: Any - ) -> _models.DatabasePrincipalAssignment: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -640,21 +600,19 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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 _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DatabasePrincipalAssignment") - request = build_create_or_update_request( + _request = build_create_or_update_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, database_name=database_name, @@ -665,39 +623,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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}" - } - @overload def begin_create_or_update( self, @@ -730,14 +684,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.synapse.models.DatabasePrincipalAssignment] @@ -752,7 +698,7 @@ def begin_create_or_update( database_name: str, principal_assignment_name: str, resource_group_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -772,18 +718,10 @@ def begin_create_or_update( :type resource_group_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.synapse.models.DatabasePrincipalAssignment] @@ -798,7 +736,7 @@ def begin_create_or_update( database_name: str, principal_assignment_name: str, resource_group_name: str, - parameters: Union[_models.DatabasePrincipalAssignment, IO], + parameters: Union[_models.DatabasePrincipalAssignment, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.DatabasePrincipalAssignment]: """Creates a Kusto pool database principalAssignment. @@ -815,19 +753,8 @@ def begin_create_or_update( Required. :type resource_group_name: str :param parameters: The Kusto principalAssignments parameters supplied for the operation. Is - either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.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.synapse.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.synapse.models.DatabasePrincipalAssignment] @@ -836,9 +763,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DatabasePrincipalAssignment] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -859,12 +784,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: @@ -874,19 +800,17 @@ 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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/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, workspace_name: str, kusto_pool_name: str, @@ -894,8 +818,8 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements principal_assignment_name: str, resource_group_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -906,12 +830,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, database_name=database_name, @@ -919,30 +841,34 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements resource_group_name=resource_group_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -967,14 +893,6 @@ def begin_delete( :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 - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~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: @@ -982,15 +900,13 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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._delete_initial( # type: ignore + raw_result = self._delete_initial( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, database_name=database_name, @@ -1002,11 +918,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)) @@ -1015,14 +932,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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_kusto_pool_databases_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_kusto_pool_databases_operations.py index e21f89f4b798..6cf02e5e7a4f 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_kusto_pool_databases_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_kusto_pool_databases_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,13 +15,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 @@ -29,12 +30,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -48,9 +48,7 @@ def build_list_by_kusto_pool_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -67,7 +65,7 @@ def build_list_by_kusto_pool_request( "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -89,9 +87,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -109,7 +105,7 @@ def build_get_request( "databaseName": _SERIALIZER.url("database_name", database_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -131,9 +127,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: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -152,7 +146,7 @@ def build_create_or_update_request( "databaseName": _SERIALIZER.url("database_name", database_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -176,9 +170,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -197,7 +189,7 @@ def build_update_request( "databaseName": _SERIALIZER.url("database_name", database_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -221,9 +213,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -241,7 +231,7 @@ def build_delete_request( "databaseName": _SERIALIZER.url("database_name", database_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -284,7 +274,6 @@ def list_by_kusto_pool( :type workspace_name: str :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: 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.synapse.models.Database] :raises ~azure.core.exceptions.HttpResponseError: @@ -292,12 +281,10 @@ def list_by_kusto_pool( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.DatabaseListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -308,25 +295,22 @@ def list_by_kusto_pool( def prepare_request(next_link=None): if not next_link: - request = build_list_by_kusto_pool_request( + _request = build_list_by_kusto_pool_request( resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_kusto_pool.metadata["url"], 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DatabaseListResult", pipeline_response) @@ -336,10 +320,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -352,10 +337,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_kusto_pool.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases" - } - @distributed_trace def get( self, resource_group_name: str, workspace_name: str, kusto_pool_name: str, database_name: str, **kwargs: Any @@ -371,12 +352,11 @@ def get( :type kusto_pool_name: str :param database_name: The name of the database in the Kusto pool. 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.synapse.models.Database :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -387,27 +367,24 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.Database] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -417,16 +394,12 @@ 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 deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, @@ -434,10 +407,10 @@ def _create_or_update_initial( workspace_name: str, kusto_pool_name: str, database_name: str, - parameters: Union[_models.Database, IO], + parameters: Union[_models.Database, IO[bytes]], **kwargs: Any - ) -> _models.Database: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -448,21 +421,19 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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 _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters 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, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, @@ -472,39 +443,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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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("Database", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Database", 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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}" - } - @overload def begin_create_or_update( self, @@ -533,14 +500,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.synapse.models.Database] :raises ~azure.core.exceptions.HttpResponseError: @@ -553,7 +512,7 @@ def begin_create_or_update( workspace_name: str, kusto_pool_name: str, database_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -570,18 +529,10 @@ def begin_create_or_update( :param database_name: The name of the database in the Kusto pool. Required. :type database_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 Database or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.Database] :raises ~azure.core.exceptions.HttpResponseError: @@ -594,7 +545,7 @@ def begin_create_or_update( workspace_name: str, kusto_pool_name: str, database_name: str, - parameters: Union[_models.Database, IO], + parameters: Union[_models.Database, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Database]: """Creates or updates a database. @@ -609,19 +560,8 @@ def begin_create_or_update( :param database_name: The name of the database in the Kusto pool. Required. :type database_name: str :param parameters: The database parameters supplied to the CreateOrUpdate operation. Is either - a model type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.models.Database 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 Database type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.Database or IO[bytes] :return: An instance of LROPoller that returns either Database or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.Database] :raises ~azure.core.exceptions.HttpResponseError: @@ -629,9 +569,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Database] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -651,12 +589,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: @@ -666,17 +605,15 @@ 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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}" - } + return LROPoller[_models.Database]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, @@ -684,10 +621,10 @@ def _update_initial( workspace_name: str, kusto_pool_name: str, database_name: str, - parameters: Union[_models.Database, IO], + parameters: Union[_models.Database, IO[bytes]], **kwargs: Any - ) -> _models.Database: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -698,21 +635,19 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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 _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "Database") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, @@ -722,39 +657,35 @@ 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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) - if response.status_code == 200: - deserialized = self._deserialize("Database", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("Database", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}" - } - @overload def begin_update( self, @@ -783,14 +714,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.synapse.models.Database] :raises ~azure.core.exceptions.HttpResponseError: @@ -803,7 +726,7 @@ def begin_update( workspace_name: str, kusto_pool_name: str, database_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -820,18 +743,10 @@ def begin_update( :param database_name: The name of the database in the Kusto pool. Required. :type database_name: str :param parameters: The database 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 Database or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.Database] :raises ~azure.core.exceptions.HttpResponseError: @@ -844,7 +759,7 @@ def begin_update( workspace_name: str, kusto_pool_name: str, database_name: str, - parameters: Union[_models.Database, IO], + parameters: Union[_models.Database, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Database]: """Updates a database. @@ -858,20 +773,9 @@ def begin_update( :type kusto_pool_name: str :param database_name: The name of the database in the Kusto pool. Required. :type database_name: str - :param parameters: The database parameters supplied to the Update operation. Is either a model - type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.models.Database 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: The database parameters supplied to the Update operation. Is either a + Database type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.Database or IO[bytes] :return: An instance of LROPoller that returns either Database or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.Database] :raises ~azure.core.exceptions.HttpResponseError: @@ -879,9 +783,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Database] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -901,12 +803,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: @@ -916,22 +819,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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/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, workspace_name: str, kusto_pool_name: str, database_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -942,42 +843,44 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -994,14 +897,6 @@ def begin_delete( :type kusto_pool_name: str :param database_name: The name of the database in the Kusto pool. 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: @@ -1009,15 +904,13 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, @@ -1028,11 +921,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)) @@ -1041,14 +935,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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_kusto_pool_principal_assignments_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_kusto_pool_principal_assignments_operations.py index c16d1b397384..e418f68af4d4 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_kusto_pool_principal_assignments_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_kusto_pool_principal_assignments_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,13 +15,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 @@ -29,12 +30,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -48,9 +48,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: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -68,7 +66,7 @@ def build_check_name_availability_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -87,9 +85,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -106,7 +102,7 @@ def build_list_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -128,9 +124,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -148,7 +142,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -170,9 +164,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: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -191,7 +183,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -215,9 +207,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -235,7 +225,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -291,7 +281,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.synapse.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: @@ -303,7 +292,7 @@ def check_name_availability( workspace_name: str, kusto_pool_name: str, resource_group_name: str, - principal_assignment_name: IO, + principal_assignment_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -318,11 +307,10 @@ def check_name_availability( Required. :type resource_group_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.synapse.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: @@ -334,7 +322,7 @@ def check_name_availability( workspace_name: str, kusto_pool_name: str, resource_group_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. @@ -346,19 +334,15 @@ def check_name_availability( :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param principal_assignment_name: The name of the principal assignment. Is either a model type - or a IO type. Required. + :param principal_assignment_name: The name of the principal assignment. Is either a + ClusterPrincipalAssignmentCheckNameRequest type or a IO[bytes] type. Required. :type principal_assignment_name: - ~azure.mgmt.synapse.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.synapse.models.ClusterPrincipalAssignmentCheckNameRequest or IO[bytes] :return: CheckNameResult or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -369,21 +353,19 @@ def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CheckNameResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(principal_assignment_name, (IO, bytes)): + if isinstance(principal_assignment_name, (IOBase, bytes)): _content = principal_assignment_name else: _json = self._serialize.body(principal_assignment_name, "ClusterPrincipalAssignmentCheckNameRequest") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_name, @@ -392,15 +374,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -410,16 +391,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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/checkPrincipalAssignmentNameAvailability" - } + return deserialized # type: ignore @distributed_trace def list( @@ -434,7 +411,6 @@ def list( :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 ClusterPrincipalAssignment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.ClusterPrincipalAssignment] @@ -443,12 +419,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.ClusterPrincipalAssignmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -459,25 +433,22 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ClusterPrincipalAssignmentListResult", pipeline_response) @@ -487,10 +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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -503,10 +475,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments" - } - @distributed_trace def get( self, @@ -527,12 +495,11 @@ def get( :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: ClusterPrincipalAssignment or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ClusterPrincipalAssignment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -543,27 +510,24 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.ClusterPrincipalAssignment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, principal_assignment_name=principal_assignment_name, resource_group_name=resource_group_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -573,16 +537,12 @@ 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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments/{principalAssignmentName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, @@ -590,10 +550,10 @@ def _create_or_update_initial( kusto_pool_name: str, principal_assignment_name: str, resource_group_name: str, - parameters: Union[_models.ClusterPrincipalAssignment, IO], + parameters: Union[_models.ClusterPrincipalAssignment, IO[bytes]], **kwargs: Any - ) -> _models.ClusterPrincipalAssignment: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -604,21 +564,19 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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 _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ClusterPrincipalAssignment") - request = build_create_or_update_request( + _request = build_create_or_update_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, principal_assignment_name=principal_assignment_name, @@ -628,39 +586,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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments/{principalAssignmentName}" - } - @overload def begin_create_or_update( self, @@ -690,14 +644,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.synapse.models.ClusterPrincipalAssignment] @@ -711,7 +657,7 @@ def begin_create_or_update( kusto_pool_name: str, principal_assignment_name: str, resource_group_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -729,18 +675,10 @@ def begin_create_or_update( :type resource_group_name: str :param parameters: The Kusto pool 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.synapse.models.ClusterPrincipalAssignment] @@ -754,7 +692,7 @@ def begin_create_or_update( kusto_pool_name: str, principal_assignment_name: str, resource_group_name: str, - parameters: Union[_models.ClusterPrincipalAssignment, IO], + parameters: Union[_models.ClusterPrincipalAssignment, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.ClusterPrincipalAssignment]: """Create a Kusto pool principalAssignment. @@ -769,19 +707,8 @@ def begin_create_or_update( Required. :type resource_group_name: str :param parameters: The Kusto pool principalAssignment's parameters supplied for the operation. - Is either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.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. + Is either a ClusterPrincipalAssignment type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.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.synapse.models.ClusterPrincipalAssignment] @@ -790,9 +717,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ClusterPrincipalAssignment] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -812,12 +737,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: @@ -827,27 +753,25 @@ 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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/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, workspace_name: str, kusto_pool_name: str, principal_assignment_name: str, resource_group_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -858,42 +782,44 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, principal_assignment_name=principal_assignment_name, resource_group_name=resource_group_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments/{principalAssignmentName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -915,14 +841,6 @@ def begin_delete( :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 - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~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: @@ -930,15 +848,13 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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._delete_initial( # type: ignore + raw_result = self._delete_initial( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, principal_assignment_name=principal_assignment_name, @@ -949,11 +865,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)) @@ -962,14 +879,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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments/{principalAssignmentName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_kusto_pool_private_link_resources_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_kusto_pool_private_link_resources_operations.py index d8a4a95f08e0..39882b683e14 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_kusto_pool_private_link_resources_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_kusto_pool_private_link_resources_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -19,20 +18,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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -46,9 +43,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -65,7 +60,7 @@ def build_list_request( "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -108,7 +103,6 @@ def list( :type workspace_name: str :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either KustoPoolPrivateLinkResources or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.KustoPoolPrivateLinkResources] @@ -117,12 +111,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.PrivateLinkResources] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -133,25 +125,22 @@ 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, workspace_name=workspace_name, kusto_pool_name=kusto_pool_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PrivateLinkResources", pipeline_response) @@ -161,10 +150,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -176,7 +166,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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/privateLinkResources" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_kusto_pools_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_kusto_pools_operations.py index 7b6dba03dc2f..be7864f8f9b2 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_kusto_pools_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_kusto_pools_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,13 +16,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 @@ -29,12 +31,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -46,9 +47,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: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -57,7 +56,7 @@ def build_list_skus_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -72,9 +71,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: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -88,7 +85,7 @@ def build_check_name_availability_request(location: str, subscription_id: str, * "location": _SERIALIZER.url("location", location, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -107,9 +104,7 @@ def build_list_by_workspace_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -125,7 +120,7 @@ def build_list_by_workspace_request( "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -142,9 +137,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -161,7 +154,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -185,9 +178,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: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -205,7 +196,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -234,9 +225,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -254,7 +243,7 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -275,9 +264,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -294,7 +281,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -311,9 +298,7 @@ def build_stop_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -330,7 +315,7 @@ def build_stop_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -347,9 +332,7 @@ def build_start_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -366,7 +349,7 @@ def build_start_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -383,9 +366,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: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -402,7 +383,7 @@ def build_list_skus_by_resource_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -419,9 +400,7 @@ def build_list_language_extensions_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -438,7 +417,7 @@ def build_list_language_extensions_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -455,9 +434,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: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -475,7 +452,7 @@ def build_add_language_extensions_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -494,9 +471,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: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -514,7 +489,7 @@ def build_remove_language_extensions_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -533,9 +508,7 @@ def build_list_follower_databases_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -552,7 +525,7 @@ def build_list_follower_databases_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -569,9 +542,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: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -589,7 +560,7 @@ def build_detach_follower_databases_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -625,7 +596,6 @@ def __init__(self, *args, **kwargs): def list_skus(self, **kwargs: Any) -> Iterable["_models.SkuDescription"]: """Lists eligible SKUs for Kusto Pool resource. - :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.synapse.models.SkuDescription] :raises ~azure.core.exceptions.HttpResponseError: @@ -633,12 +603,10 @@ def list_skus(self, **kwargs: Any) -> Iterable["_models.SkuDescription"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.SkuDescriptionList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -649,22 +617,19 @@ 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("SkuDescriptionList", pipeline_response) @@ -674,10 +639,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -690,8 +656,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_skus.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Synapse/skus"} - @overload def check_name_availability( self, @@ -710,7 +674,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.synapse.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: @@ -718,18 +681,17 @@ def check_name_availability( @overload def check_name_availability( - self, location: str, kusto_pool_name: IO, *, content_type: str = "application/json", **kwargs: Any + self, location: str, kusto_pool_name: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameResult: """Checks that the kusto pool name is valid and is not already in use. :param location: The name of Azure region. Required. :type location: str :param kusto_pool_name: The name of the cluster. Required. - :type kusto_pool_name: IO + :type kusto_pool_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.synapse.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: @@ -737,23 +699,20 @@ def check_name_availability( @distributed_trace def check_name_availability( - self, location: str, kusto_pool_name: Union[_models.KustoPoolCheckNameRequest, IO], **kwargs: Any + self, location: str, kusto_pool_name: Union[_models.KustoPoolCheckNameRequest, IO[bytes]], **kwargs: Any ) -> _models.CheckNameResult: """Checks that the kusto pool name is valid and is not already in use. :param location: The name of Azure region. Required. :type location: str - :param kusto_pool_name: The name of the cluster. Is either a model type or a IO type. Required. - :type kusto_pool_name: ~azure.mgmt.synapse.models.KustoPoolCheckNameRequest 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 kusto_pool_name: The name of the cluster. Is either a KustoPoolCheckNameRequest type or + a IO[bytes] type. Required. + :type kusto_pool_name: ~azure.mgmt.synapse.models.KustoPoolCheckNameRequest or IO[bytes] :return: CheckNameResult or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.CheckNameResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -764,36 +723,33 @@ def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CheckNameResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(kusto_pool_name, (IO, bytes)): + if isinstance(kusto_pool_name, (IOBase, bytes)): _content = kusto_pool_name else: _json = self._serialize.body(kusto_pool_name, "KustoPoolCheckNameRequest") - 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -803,16 +759,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.Synapse/locations/{location}/kustoPoolCheckNameAvailability" - } + return deserialized # type: ignore @distributed_trace def list_by_workspace( @@ -827,12 +779,11 @@ def list_by_workspace( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: KustoPoolListResult or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.KustoPoolListResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -843,25 +794,22 @@ def list_by_workspace( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.KustoPoolListResult] = kwargs.pop("cls", None) - request = build_list_by_workspace_request( + _request = build_list_by_workspace_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_workspace.metadata["url"], 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -871,16 +819,12 @@ def list_by_workspace( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("KustoPoolListResult", pipeline_response) + deserialized = self._deserialize("KustoPoolListResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_by_workspace.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools" - } + return deserialized # type: ignore @distributed_trace def get( @@ -895,12 +839,11 @@ def get( :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: KustoPool or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.KustoPool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -911,26 +854,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.KustoPool] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -940,28 +880,24 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("KustoPool", pipeline_response) + deserialized = self._deserialize("KustoPool", 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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, workspace_name: str, resource_group_name: str, kusto_pool_name: str, - parameters: Union[_models.KustoPool, IO], + parameters: Union[_models.KustoPool, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> _models.KustoPool: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -972,21 +908,19 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.KustoPool] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "KustoPool") - request = build_create_or_update_request( + _request = build_create_or_update_request( workspace_name=workspace_name, resource_group_name=resource_group_name, kusto_pool_name=kusto_pool_name, @@ -997,39 +931,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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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("KustoPool", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("KustoPool", 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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}" - } - @overload def begin_create_or_update( self, @@ -1066,14 +996,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 KustoPool or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.KustoPool] :raises ~azure.core.exceptions.HttpResponseError: @@ -1085,7 +1007,7 @@ def begin_create_or_update( workspace_name: str, resource_group_name: str, kusto_pool_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, if_none_match: Optional[str] = None, *, @@ -1103,7 +1025,7 @@ def begin_create_or_update( :type kusto_pool_name: str :param parameters: The Kusto pool parameters supplied to the CreateOrUpdate operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The ETag of the Kusto Pool. Omit this value to always overwrite the current Kusto Pool. Specify the last-seen ETag value to prevent accidentally overwriting concurrent changes. Default value is None. @@ -1115,14 +1037,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 KustoPool or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.KustoPool] :raises ~azure.core.exceptions.HttpResponseError: @@ -1134,7 +1048,7 @@ def begin_create_or_update( workspace_name: str, resource_group_name: str, kusto_pool_name: str, - parameters: Union[_models.KustoPool, IO], + parameters: Union[_models.KustoPool, IO[bytes]], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any @@ -1149,8 +1063,8 @@ def begin_create_or_update( :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str :param parameters: The Kusto pool parameters supplied to the CreateOrUpdate operation. Is - either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.models.KustoPool or IO + either a KustoPool type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.KustoPool or IO[bytes] :param if_match: The ETag of the Kusto Pool. Omit this value to always overwrite the current Kusto Pool. Specify the last-seen ETag value to prevent accidentally overwriting concurrent changes. Default value is None. @@ -1159,17 +1073,6 @@ def begin_create_or_update( updating an existing Kusto Pool. 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 KustoPool or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.KustoPool] :raises ~azure.core.exceptions.HttpResponseError: @@ -1177,9 +1080,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.KustoPool] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1200,12 +1101,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("KustoPool", pipeline_response) + deserialized = self._deserialize("KustoPool", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1215,28 +1117,26 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.KustoPool].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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}" - } + return LROPoller[_models.KustoPool]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, workspace_name: str, resource_group_name: str, kusto_pool_name: str, - parameters: Union[_models.KustoPoolUpdate, IO], + parameters: Union[_models.KustoPoolUpdate, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any - ) -> _models.KustoPool: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1247,21 +1147,19 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.KustoPool] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "KustoPoolUpdate") - request = build_update_request( + _request = build_update_request( workspace_name=workspace_name, resource_group_name=resource_group_name, kusto_pool_name=kusto_pool_name, @@ -1271,39 +1169,35 @@ 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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) - if response.status_code == 200: - deserialized = self._deserialize("KustoPool", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("KustoPool", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}" - } - @overload def begin_update( self, @@ -1334,14 +1228,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 KustoPool or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.KustoPool] :raises ~azure.core.exceptions.HttpResponseError: @@ -1353,7 +1239,7 @@ def begin_update( workspace_name: str, resource_group_name: str, kusto_pool_name: str, - parameters: IO, + parameters: IO[bytes], if_match: Optional[str] = None, *, content_type: str = "application/json", @@ -1369,7 +1255,7 @@ def begin_update( :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str :param parameters: The Kusto pool parameters supplied to the Update operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :param if_match: The ETag of the Kusto Pool. Omit this value to always overwrite the current Kusto Pool. Specify the last-seen ETag value to prevent accidentally overwriting concurrent changes. Default value is None. @@ -1377,14 +1263,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 KustoPool or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.KustoPool] :raises ~azure.core.exceptions.HttpResponseError: @@ -1396,7 +1274,7 @@ def begin_update( workspace_name: str, resource_group_name: str, kusto_pool_name: str, - parameters: Union[_models.KustoPoolUpdate, IO], + parameters: Union[_models.KustoPoolUpdate, IO[bytes]], if_match: Optional[str] = None, **kwargs: Any ) -> LROPoller[_models.KustoPool]: @@ -1410,23 +1288,12 @@ def begin_update( :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str :param parameters: The Kusto pool parameters supplied to the Update operation. Is either a - model type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.models.KustoPoolUpdate or IO + KustoPoolUpdate type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.KustoPoolUpdate or IO[bytes] :param if_match: The ETag of the Kusto Pool. Omit this value to always overwrite the current Kusto Pool. 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 KustoPool or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.KustoPool] :raises ~azure.core.exceptions.HttpResponseError: @@ -1434,9 +1301,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.KustoPool] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1456,12 +1321,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("KustoPool", pipeline_response) + deserialized = self._deserialize("KustoPool", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1471,22 +1337,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.KustoPool].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.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}" - } + return LROPoller[_models.KustoPool]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, workspace_name: str, resource_group_name: str, kusto_pool_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1497,41 +1361,43 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( workspace_name=workspace_name, resource_group_name=resource_group_name, kusto_pool_name=kusto_pool_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -1546,14 +1412,6 @@ def begin_delete( :type resource_group_name: str :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_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: @@ -1561,15 +1419,13 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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._delete_initial( # type: ignore + raw_result = self._delete_initial( workspace_name=workspace_name, resource_group_name=resource_group_name, kusto_pool_name=kusto_pool_name, @@ -1579,11 +1435,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)) @@ -1592,22 +1449,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 + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}" - } - - def _stop_initial( # pylint: disable=inconsistent-return-statements + def _stop_initial( self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1618,41 +1471,43 @@ def _stop_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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 = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _stop_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/stop" - } + return deserialized # type: ignore @distributed_trace def begin_stop( @@ -1667,14 +1522,6 @@ def begin_stop( :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 - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~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: @@ -1682,15 +1529,13 @@ def begin_stop( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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._stop_initial( # type: ignore + raw_result = self._stop_initial( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_name, @@ -1700,11 +1545,12 @@ def begin_stop( 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)) @@ -1713,22 +1559,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 + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_stop.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/stop" - } - - def _start_initial( # pylint: disable=inconsistent-return-statements + def _start_initial( self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1739,41 +1581,43 @@ def _start_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_start_request( + _request = build_start_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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 = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _start_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/start" - } + return deserialized # type: ignore @distributed_trace def begin_start( @@ -1788,14 +1632,6 @@ def begin_start( :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 - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~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: @@ -1803,15 +1639,13 @@ def begin_start( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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._start_initial( # type: ignore + raw_result = self._start_initial( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_name, @@ -1821,11 +1655,12 @@ def begin_start( 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)) @@ -1834,17 +1669,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_start.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/start" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def list_skus_by_resource( @@ -1859,7 +1690,6 @@ def list_skus_by_resource( :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 AzureResourceSku or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.AzureResourceSku] :raises ~azure.core.exceptions.HttpResponseError: @@ -1867,12 +1697,10 @@ def list_skus_by_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.ListResourceSkusResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1883,25 +1711,22 @@ 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( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListResourceSkusResult", pipeline_response) @@ -1911,10 +1736,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1927,10 +1753,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_skus_by_resource.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/skus" - } - @distributed_trace def list_language_extensions( self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, **kwargs: Any @@ -1944,7 +1766,6 @@ def list_language_extensions( :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 LanguageExtension or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.LanguageExtension] :raises ~azure.core.exceptions.HttpResponseError: @@ -1952,12 +1773,10 @@ def list_language_extensions( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.LanguageExtensionsList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1968,25 +1787,22 @@ 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( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("LanguageExtensionsList", pipeline_response) @@ -1996,10 +1812,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2012,19 +1829,15 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_language_extensions.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/listLanguageExtensions" - } - - def _add_language_extensions_initial( # pylint: disable=inconsistent-return-statements + def _add_language_extensions_initial( self, workspace_name: str, kusto_pool_name: str, resource_group_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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2035,21 +1848,19 @@ def _add_language_extensions_initial( # pylint: disable=inconsistent-return-sta _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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 _content = None - if isinstance(language_extensions_to_add, (IO, bytes)): + 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( + _request = build_add_language_extensions_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_name, @@ -2058,30 +1869,34 @@ 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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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 = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _add_language_extensions_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/addLanguageExtensions" - } + return deserialized # type: ignore @overload def begin_add_language_extensions( @@ -2108,14 +1923,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: @@ -2127,7 +1934,7 @@ def begin_add_language_extensions( workspace_name: str, kusto_pool_name: str, resource_group_name: str, - language_extensions_to_add: IO, + language_extensions_to_add: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -2142,18 +1949,10 @@ def begin_add_language_extensions( Required. :type resource_group_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: @@ -2165,7 +1964,7 @@ def begin_add_language_extensions( workspace_name: str, kusto_pool_name: str, resource_group_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. @@ -2177,20 +1976,10 @@ def begin_add_language_extensions( :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param language_extensions_to_add: The language extensions to add. Is either a model type or a - IO type. Required. - :type language_extensions_to_add: ~azure.mgmt.synapse.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. + :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.synapse.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: @@ -2198,16 +1987,14 @@ def begin_add_language_extensions( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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_language_extensions_initial( # type: ignore + raw_result = self._add_language_extensions_initial( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_name, @@ -2219,11 +2006,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)) @@ -2232,27 +2020,23 @@ 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_add_language_extensions.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/addLanguageExtensions" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _remove_language_extensions_initial( # pylint: disable=inconsistent-return-statements + def _remove_language_extensions_initial( self, workspace_name: str, kusto_pool_name: str, resource_group_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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2263,21 +2047,19 @@ def _remove_language_extensions_initial( # pylint: disable=inconsistent-return- _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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 _content = None - if isinstance(language_extensions_to_remove, (IO, bytes)): + 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( + _request = build_remove_language_extensions_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_name, @@ -2286,30 +2068,34 @@ 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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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 = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _remove_language_extensions_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/removeLanguageExtensions" - } + return deserialized # type: ignore @overload def begin_remove_language_extensions( @@ -2336,14 +2122,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: @@ -2355,7 +2133,7 @@ def begin_remove_language_extensions( workspace_name: str, kusto_pool_name: str, resource_group_name: str, - language_extensions_to_remove: IO, + language_extensions_to_remove: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -2370,18 +2148,10 @@ def begin_remove_language_extensions( Required. :type resource_group_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: @@ -2393,7 +2163,7 @@ def begin_remove_language_extensions( workspace_name: str, kusto_pool_name: str, resource_group_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. @@ -2405,20 +2175,10 @@ def begin_remove_language_extensions( :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param language_extensions_to_remove: The language extensions to remove. Is either a model type - or a IO type. Required. - :type language_extensions_to_remove: ~azure.mgmt.synapse.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. + :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.synapse.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: @@ -2426,16 +2186,14 @@ def begin_remove_language_extensions( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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_language_extensions_initial( # type: ignore + raw_result = self._remove_language_extensions_initial( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_name, @@ -2447,11 +2205,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)) @@ -2460,17 +2219,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_remove_language_extensions.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/removeLanguageExtensions" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def list_follower_databases( @@ -2486,7 +2241,6 @@ def list_follower_databases( :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 FollowerDatabaseDefinition or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.FollowerDatabaseDefinition] @@ -2495,12 +2249,10 @@ def list_follower_databases( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.FollowerDatabaseListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2511,25 +2263,22 @@ 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( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("FollowerDatabaseListResult", pipeline_response) @@ -2539,10 +2288,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2555,19 +2305,15 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_follower_databases.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/listFollowerDatabases" - } - - def _detach_follower_databases_initial( # pylint: disable=inconsistent-return-statements + def _detach_follower_databases_initial( self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, - follower_database_to_remove: Union[_models.FollowerDatabaseDefinition, IO], + follower_database_to_remove: Union[_models.FollowerDatabaseDefinition, IO[bytes]], **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2578,21 +2324,19 @@ def _detach_follower_databases_initial( # pylint: disable=inconsistent-return-s _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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 _content = None - if isinstance(follower_database_to_remove, (IO, bytes)): + 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( + _request = build_detach_follower_databases_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_name, @@ -2601,30 +2345,34 @@ def _detach_follower_databases_initial( # pylint: disable=inconsistent-return-s 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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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 = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _detach_follower_databases_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/detachFollowerDatabases" - } + return deserialized # type: ignore @overload def begin_detach_follower_databases( @@ -2651,14 +2399,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: @@ -2670,7 +2410,7 @@ def begin_detach_follower_databases( workspace_name: str, kusto_pool_name: str, resource_group_name: str, - follower_database_to_remove: IO, + follower_database_to_remove: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -2685,18 +2425,10 @@ def begin_detach_follower_databases( Required. :type resource_group_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: @@ -2708,7 +2440,7 @@ def begin_detach_follower_databases( workspace_name: str, kusto_pool_name: str, resource_group_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 Kusto Pool. @@ -2721,19 +2453,9 @@ def begin_detach_follower_databases( Required. :type resource_group_name: str :param follower_database_to_remove: The follower databases properties to remove. Is either a - model type or a IO type. Required. - :type follower_database_to_remove: ~azure.mgmt.synapse.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.synapse.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: @@ -2741,16 +2463,14 @@ def begin_detach_follower_databases( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) 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._detach_follower_databases_initial( # type: ignore + raw_result = self._detach_follower_databases_initial( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_name, @@ -2762,11 +2482,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)) @@ -2775,14 +2496,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_detach_follower_databases.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/detachFollowerDatabases" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_libraries_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_libraries_operations.py index 2f2147a5862b..95c4e15c5c0b 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_libraries_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_libraries_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -19,20 +18,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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -46,9 +43,7 @@ def build_list_by_workspace_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -64,7 +59,7 @@ def build_list_by_workspace_request( "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -107,7 +102,6 @@ def list_by_workspace( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LibraryResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.LibraryResource] :raises ~azure.core.exceptions.HttpResponseError: @@ -115,12 +109,10 @@ def list_by_workspace( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.LibraryListResponse] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -131,24 +123,21 @@ def list_by_workspace( def prepare_request(next_link=None): if not next_link: - request = build_list_by_workspace_request( + _request = build_list_by_workspace_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_workspace.metadata["url"], 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("LibraryListResponse", pipeline_response) @@ -158,10 +147,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -173,7 +163,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_workspace.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/libraries" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_library_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_library_operations.py index f31c95157c35..5469c316e6e1 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_library_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_library_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -18,20 +17,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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,9 +42,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -64,7 +59,7 @@ def build_get_request( "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -109,12 +104,11 @@ def get( :type library_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LibraryResource or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.LibraryResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -125,26 +119,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.LibraryResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, library_name=library_name, workspace_name=workspace_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -154,13 +145,9 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("LibraryResource", pipeline_response) + deserialized = self._deserialize("LibraryResource", 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.Synapse/workspaces/{workspaceName}/libraries/{libraryName}" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_operations.py index 60cace3ec7eb..65959792624d 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, overload @@ -18,20 +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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +41,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -55,7 +53,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -88,7 +86,7 @@ def build_get_location_header_result_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -105,7 +103,7 @@ def build_get_location_header_result_request( "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -116,13 +114,13 @@ def build_get_location_header_result_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_azure_async_header_result_request( +def build_get_azure_async_header_result_request( # pylint: disable=name-too-long resource_group_name: str, workspace_name: str, operation_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -139,7 +137,7 @@ def build_get_azure_async_header_result_request( "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -182,7 +180,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: CheckNameAvailabilityResponse or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.CheckNameAvailabilityResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -190,18 +187,17 @@ def check_name_availability( @overload def check_name_availability( - self, request: IO, *, content_type: str = "application/json", **kwargs: Any + self, request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResponse: """Check name availability. Check whether a workspace name is available. :param request: The check request. Required. - :type request: IO + :type 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 :return: CheckNameAvailabilityResponse or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.CheckNameAvailabilityResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -209,23 +205,20 @@ def check_name_availability( @distributed_trace def check_name_availability( - self, request: Union[_models.CheckNameAvailabilityRequest, IO], **kwargs: Any + self, request: Union[_models.CheckNameAvailabilityRequest, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityResponse: """Check name availability. Check whether a workspace name is available. - :param request: The check request. Is either a model type or a IO type. Required. - :type request: ~azure.mgmt.synapse.models.CheckNameAvailabilityRequest 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 request: The check request. Is either a CheckNameAvailabilityRequest type or a IO[bytes] + type. Required. + :type request: ~azure.mgmt.synapse.models.CheckNameAvailabilityRequest or IO[bytes] :return: CheckNameAvailabilityResponse or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.CheckNameAvailabilityResponse :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -236,33 +229,32 @@ def check_name_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CheckNameAvailabilityResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(request, (IO, bytes)): + if isinstance(request, (IOBase, bytes)): _content = request else: _json = self._serialize.body(request, "CheckNameAvailabilityRequest") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -272,16 +264,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("CheckNameAvailabilityResponse", pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResponse", 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.Synapse/checkNameAvailability" - } + return deserialized # type: ignore @distributed_trace def list(self, **kwargs: Any) -> List[_models.AvailableRpOperation]: @@ -289,12 +277,11 @@ def list(self, **kwargs: Any) -> List[_models.AvailableRpOperation]: Get all available operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: list of AvailableRpOperation or the result of cls(response) :rtype: list[~azure.mgmt.synapse.models.AvailableRpOperation] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -307,16 +294,15 @@ def list(self, **kwargs: Any) -> List[_models.AvailableRpOperation]: cls: ClsType[List[_models.AvailableRpOperation]] = kwargs.pop("cls", None) - request = build_list_request( - template_url=self.list.metadata["url"], + _request = build_list_request( 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -326,14 +312,12 @@ def list(self, **kwargs: Any) -> List[_models.AvailableRpOperation]: error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("[AvailableRpOperation]", pipeline_response) + deserialized = self._deserialize("[AvailableRpOperation]", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list.metadata = {"url": "/providers/Microsoft.Synapse/operations"} + return deserialized # type: ignore @distributed_trace def get_location_header_result( # pylint: disable=inconsistent-return-statements @@ -350,12 +334,11 @@ def get_location_header_result( # pylint: disable=inconsistent-return-statement :type workspace_name: str :param operation_id: Operation ID. Required. :type operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -366,24 +349,23 @@ def get_location_header_result( # pylint: disable=inconsistent-return-statement _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_get_location_header_result_request( + _request = build_get_location_header_result_request( resource_group_name=resource_group_name, workspace_name=workspace_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_location_header_result.metadata["url"], 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -394,11 +376,7 @@ def get_location_header_result( # pylint: disable=inconsistent-return-statement raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - get_location_header_result.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/operationResults/{operationId}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get_azure_async_header_result( @@ -415,12 +393,11 @@ def get_azure_async_header_result( :type workspace_name: str :param operation_id: Operation ID. Required. :type operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: OperationResource or None or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.OperationResource or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -431,24 +408,23 @@ def get_azure_async_header_result( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[Optional[_models.OperationResource]] = kwargs.pop("cls", None) - request = build_get_azure_async_header_result_request( + _request = build_get_azure_async_header_result_request( resource_group_name=resource_group_name, workspace_name=workspace_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_azure_async_header_result.metadata["url"], 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -460,13 +436,9 @@ def get_azure_async_header_result( deserialized = None if response.status_code == 200: - deserialized = self._deserialize("OperationResource", pipeline_response) + deserialized = self._deserialize("OperationResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_azure_async_header_result.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/operationStatuses/{operationId}" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_private_endpoint_connections_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_private_endpoint_connections_operations.py index 965a0805fec6..107ed3c7a66e 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_private_endpoint_connections_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_private_endpoint_connections_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,13 +15,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 @@ -29,12 +30,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +52,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -71,7 +71,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -92,7 +92,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -112,7 +112,7 @@ def build_create_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -135,7 +135,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -154,7 +154,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -171,7 +171,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -187,7 +187,7 @@ def build_list_request( "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -230,12 +230,11 @@ def get( :type workspace_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.synapse.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -246,24 +245,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -273,26 +271,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.Synapse/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, workspace_name: str, private_endpoint_connection_name: str, - request: Union[_models.PrivateEndpointConnection, IO], + request: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any - ) -> _models.PrivateEndpointConnection: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -303,19 +297,19 @@ def _create_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) 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 _content = None - if isinstance(request, (IO, bytes)): + if isinstance(request, (IOBase, bytes)): _content = request else: _json = self._serialize.body(request, "PrivateEndpointConnection") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, workspace_name=workspace_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -324,39 +318,35 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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=False, **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_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } - @overload def begin_create( self, @@ -382,14 +372,6 @@ def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~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.synapse.models.PrivateEndpointConnection] @@ -402,7 +384,7 @@ def begin_create( resource_group_name: str, workspace_name: str, private_endpoint_connection_name: str, - request: IO, + request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -417,18 +399,10 @@ def begin_create( :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param request: Request body of private endpoint connection to create. Required. - :type request: IO + :type 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 PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.PrivateEndpointConnection] @@ -441,7 +415,7 @@ def begin_create( resource_group_name: str, workspace_name: str, private_endpoint_connection_name: str, - request: Union[_models.PrivateEndpointConnection, IO], + request: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.PrivateEndpointConnection]: """Approve or reject a private endpoint connection. @@ -453,20 +427,9 @@ def begin_create( :type workspace_name: str :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :param request: Request body of private endpoint connection to create. Is either a model type - or a IO type. Required. - :type request: ~azure.mgmt.synapse.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 request: Request body of private endpoint connection to create. Is either a + PrivateEndpointConnection type or a IO[bytes] type. Required. + :type request: ~azure.mgmt.synapse.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.synapse.models.PrivateEndpointConnection] @@ -475,7 +438,7 @@ def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -494,12 +457,13 @@ def begin_create( 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: @@ -511,22 +475,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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return LROPoller[_models.PrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _delete_initial( self, resource_group_name: str, workspace_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> Optional[_models.OperationResource]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -537,45 +499,43 @@ def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - cls: ClsType[Optional[_models.OperationResource]] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) - deserialized = None - if response.status_code == 202: - deserialized = self._deserialize("OperationResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -590,14 +550,6 @@ def begin_delete( :type workspace_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 OperationResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.OperationResource] @@ -606,7 +558,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) 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) @@ -622,12 +574,13 @@ 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): - deserialized = self._deserialize("OperationResource", pipeline_response) + deserialized = self._deserialize("OperationResource", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -637,17 +590,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.OperationResource].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.Synapse/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return LROPoller[_models.OperationResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list( @@ -660,7 +611,6 @@ def list( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_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.synapse.models.PrivateEndpointConnection] @@ -669,10 +619,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.PrivateEndpointConnectionList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -683,24 +633,21 @@ 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, workspace_name=workspace_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionList", pipeline_response) @@ -710,10 +657,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -725,7 +673,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.Synapse/workspaces/{workspaceName}/privateEndpointConnections" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_private_endpoint_connections_private_link_hub_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_private_endpoint_connections_private_link_hub_operations.py index 1e71d61140c3..2d6de6b6251c 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_private_endpoint_connections_private_link_hub_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_private_endpoint_connections_private_link_hub_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -19,20 +18,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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -46,7 +43,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -62,7 +59,7 @@ def build_list_request( "privateLinkHubName": _SERIALIZER.url("private_link_hub_name", private_link_hub_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -83,7 +80,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -102,7 +99,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -113,7 +110,7 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class PrivateEndpointConnectionsPrivateLinkHubOperations: +class PrivateEndpointConnectionsPrivateLinkHubOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -143,7 +140,6 @@ def list( :type resource_group_name: str :param private_link_hub_name: Name of the privateLinkHub. Required. :type private_link_hub_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PrivateEndpointConnectionForPrivateLinkHub or the result of cls(response) :rtype: @@ -153,12 +149,12 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.PrivateEndpointConnectionForPrivateLinkHubResourceCollectionResponse] = kwargs.pop( "cls", None ) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -169,24 +165,21 @@ 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, private_link_hub_name=private_link_hub_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize( @@ -198,10 +191,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -214,10 +208,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}/privateEndpointConnections" - } - @distributed_trace def get( self, resource_group_name: str, private_link_hub_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -231,12 +221,11 @@ def get( :type private_link_hub_name: str :param private_endpoint_connection_name: Name of the privateEndpointConnection. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnectionForPrivateLinkHub or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.PrivateEndpointConnectionForPrivateLinkHub :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -247,24 +236,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.PrivateEndpointConnectionForPrivateLinkHub] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, private_link_hub_name=private_link_hub_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -274,13 +262,9 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateEndpointConnectionForPrivateLinkHub", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnectionForPrivateLinkHub", 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.Synapse/privateLinkHubs/{privateLinkHubName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_private_link_hub_private_link_resources_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_private_link_hub_private_link_resources_operations.py index 6ea219e125b9..c86a17ac52b6 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_private_link_hub_private_link_resources_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_private_link_hub_private_link_resources_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -19,20 +18,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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -46,7 +43,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -62,7 +59,7 @@ def build_list_request( "privateLinkHubName": _SERIALIZER.url("private_link_hub_name", private_link_hub_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -83,7 +80,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -100,7 +97,7 @@ def build_get_request( "privateLinkResourceName": _SERIALIZER.url("private_link_resource_name", private_link_resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -111,7 +108,7 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class PrivateLinkHubPrivateLinkResourcesOperations: +class PrivateLinkHubPrivateLinkResourcesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -143,7 +140,6 @@ def list( :type resource_group_name: str :param private_link_hub_name: The name of the private link hub. Required. :type private_link_hub_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.synapse.models.PrivateLinkResource] :raises ~azure.core.exceptions.HttpResponseError: @@ -151,10 +147,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -165,24 +161,21 @@ 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, private_link_hub_name=private_link_hub_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) @@ -192,10 +185,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -208,10 +202,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}/privateLinkResources" - } - @distributed_trace def get( self, resource_group_name: str, private_link_hub_name: str, private_link_resource_name: str, **kwargs: Any @@ -227,12 +217,11 @@ def get( :type private_link_hub_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.synapse.models.PrivateLinkResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -243,24 +232,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, private_link_hub_name=private_link_hub_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -270,13 +258,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.Synapse/privateLinkHubs/{privateLinkHubName}/privateLinkResources/{privateLinkResourceName}" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_private_link_hubs_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_private_link_hubs_operations.py index 2fd92872f7fa..fd0acda3320b 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_private_link_hubs_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_private_link_hubs_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,13 +15,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 @@ -29,12 +30,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -46,7 +46,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: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,7 +61,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,7 +78,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -94,7 +94,7 @@ def build_get_request( "privateLinkHubName": _SERIALIZER.url("private_link_hub_name", private_link_hub_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -111,7 +111,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -128,7 +128,7 @@ def build_update_request( "privateLinkHubName": _SERIALIZER.url("private_link_hub_name", private_link_hub_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -147,7 +147,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: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -164,7 +164,7 @@ def build_create_or_update_request( "privateLinkHubName": _SERIALIZER.url("private_link_hub_name", private_link_hub_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -183,7 +183,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -199,7 +199,7 @@ def build_delete_request( "privateLinkHubName": _SERIALIZER.url("private_link_hub_name", private_link_hub_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -214,7 +214,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: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -223,7 +223,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -260,7 +260,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 PrivateLinkHub or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.PrivateLinkHub] :raises ~azure.core.exceptions.HttpResponseError: @@ -268,10 +267,10 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.PrivateLinkHubInfoListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -282,23 +281,20 @@ 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PrivateLinkHubInfoListResult", pipeline_response) @@ -308,10 +304,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -324,10 +321,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs" - } - @distributed_trace def get(self, resource_group_name: str, private_link_hub_name: str, **kwargs: Any) -> _models.PrivateLinkHub: """Gets a privateLinkHub. @@ -337,12 +330,11 @@ def get(self, resource_group_name: str, private_link_hub_name: str, **kwargs: An :type resource_group_name: str :param private_link_hub_name: Name of the privateLinkHub. Required. :type private_link_hub_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateLinkHub or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.PrivateLinkHub :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -353,23 +345,22 @@ def get(self, resource_group_name: str, private_link_hub_name: str, **kwargs: An _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.PrivateLinkHub] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, private_link_hub_name=private_link_hub_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -379,16 +370,12 @@ def get(self, resource_group_name: str, private_link_hub_name: str, **kwargs: An error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateLinkHub", pipeline_response) + deserialized = self._deserialize("PrivateLinkHub", 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.Synapse/privateLinkHubs/{privateLinkHubName}" - } + return deserialized # type: ignore @overload def update( @@ -412,7 +399,6 @@ def 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 :return: PrivateLinkHub or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.PrivateLinkHub :raises ~azure.core.exceptions.HttpResponseError: @@ -423,7 +409,7 @@ def update( self, resource_group_name: str, private_link_hub_name: str, - private_link_hub_patch_info: IO, + private_link_hub_patch_info: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -436,11 +422,10 @@ def update( :param private_link_hub_name: Name of the privateLinkHub. Required. :type private_link_hub_name: str :param private_link_hub_patch_info: PrivateLinkHub patch request properties. Required. - :type private_link_hub_patch_info: IO + :type private_link_hub_patch_info: 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: PrivateLinkHub or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.PrivateLinkHub :raises ~azure.core.exceptions.HttpResponseError: @@ -451,7 +436,7 @@ def update( self, resource_group_name: str, private_link_hub_name: str, - private_link_hub_patch_info: Union[_models.PrivateLinkHubPatchInfo, IO], + private_link_hub_patch_info: Union[_models.PrivateLinkHubPatchInfo, IO[bytes]], **kwargs: Any ) -> _models.PrivateLinkHub: """Updates a privateLinkHub. @@ -461,18 +446,15 @@ def update( :type resource_group_name: str :param private_link_hub_name: Name of the privateLinkHub. Required. :type private_link_hub_name: str - :param private_link_hub_patch_info: PrivateLinkHub patch request properties. Is either a model - type or a IO type. Required. - :type private_link_hub_patch_info: ~azure.mgmt.synapse.models.PrivateLinkHubPatchInfo 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 private_link_hub_patch_info: PrivateLinkHub patch request properties. Is either a + PrivateLinkHubPatchInfo type or a IO[bytes] type. Required. + :type private_link_hub_patch_info: ~azure.mgmt.synapse.models.PrivateLinkHubPatchInfo or + IO[bytes] :return: PrivateLinkHub or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.PrivateLinkHub :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -483,19 +465,19 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateLinkHub] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(private_link_hub_patch_info, (IO, bytes)): + if isinstance(private_link_hub_patch_info, (IOBase, bytes)): _content = private_link_hub_patch_info else: _json = self._serialize.body(private_link_hub_patch_info, "PrivateLinkHubPatchInfo") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, private_link_hub_name=private_link_hub_name, subscription_id=self._config.subscription_id, @@ -503,15 +485,14 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -521,21 +502,13 @@ def update( 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("PrivateLinkHub", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("PrivateLinkHub", pipeline_response) + deserialized = self._deserialize("PrivateLinkHub", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}" - } - @overload def create_or_update( self, @@ -558,7 +531,6 @@ def 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 :return: PrivateLinkHub or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.PrivateLinkHub :raises ~azure.core.exceptions.HttpResponseError: @@ -569,7 +541,7 @@ def create_or_update( self, resource_group_name: str, private_link_hub_name: str, - private_link_hub_info: IO, + private_link_hub_info: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -582,11 +554,10 @@ def create_or_update( :param private_link_hub_name: Name of the privateLinkHub. Required. :type private_link_hub_name: str :param private_link_hub_info: PrivateLinkHub create or update request properties. Required. - :type private_link_hub_info: IO + :type private_link_hub_info: 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: PrivateLinkHub or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.PrivateLinkHub :raises ~azure.core.exceptions.HttpResponseError: @@ -597,7 +568,7 @@ def create_or_update( self, resource_group_name: str, private_link_hub_name: str, - private_link_hub_info: Union[_models.PrivateLinkHub, IO], + private_link_hub_info: Union[_models.PrivateLinkHub, IO[bytes]], **kwargs: Any ) -> _models.PrivateLinkHub: """Creates or updates a privateLinkHub. @@ -608,17 +579,13 @@ def create_or_update( :param private_link_hub_name: Name of the privateLinkHub. Required. :type private_link_hub_name: str :param private_link_hub_info: PrivateLinkHub create or update request properties. Is either a - model type or a IO type. Required. - :type private_link_hub_info: ~azure.mgmt.synapse.models.PrivateLinkHub 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 + PrivateLinkHub type or a IO[bytes] type. Required. + :type private_link_hub_info: ~azure.mgmt.synapse.models.PrivateLinkHub or IO[bytes] :return: PrivateLinkHub or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.PrivateLinkHub :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -629,19 +596,19 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.PrivateLinkHub] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(private_link_hub_info, (IO, bytes)): + if isinstance(private_link_hub_info, (IOBase, bytes)): _content = private_link_hub_info else: _json = self._serialize.body(private_link_hub_info, "PrivateLinkHub") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, private_link_hub_name=private_link_hub_name, subscription_id=self._config.subscription_id, @@ -649,15 +616,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -667,25 +633,15 @@ def create_or_update( 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("PrivateLinkHub", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("PrivateLinkHub", pipeline_response) + deserialized = self._deserialize("PrivateLinkHub", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}" - } - - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, private_link_hub_name: str, **kwargs: Any - ) -> None: - error_map = { + def _delete_initial(self, resource_group_name: str, private_link_hub_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -696,38 +652,42 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, private_link_hub_name=private_link_hub_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete(self, resource_group_name: str, private_link_hub_name: str, **kwargs: Any) -> LROPoller[None]: @@ -738,14 +698,6 @@ def begin_delete(self, resource_group_name: str, private_link_hub_name: str, **k :type resource_group_name: str :param private_link_hub_name: Name of the privateLinkHub. Required. :type private_link_hub_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: @@ -753,13 +705,13 @@ def begin_delete(self, resource_group_name: str, private_link_hub_name: str, **k _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) 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._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, private_link_hub_name=private_link_hub_name, api_version=api_version, @@ -768,36 +720,34 @@ def begin_delete(self, resource_group_name: str, private_link_hub_name: str, **k 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)) + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) 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.Synapse/privateLinkHubs/{privateLinkHubName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.PrivateLinkHub"]: """Returns a list of privateLinkHubs in a subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PrivateLinkHub or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.PrivateLinkHub] :raises ~azure.core.exceptions.HttpResponseError: @@ -805,10 +755,10 @@ def list(self, **kwargs: Any) -> Iterable["_models.PrivateLinkHub"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.PrivateLinkHubInfoListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -819,22 +769,19 @@ def list(self, **kwargs: Any) -> Iterable["_models.PrivateLinkHub"]: 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PrivateLinkHubInfoListResult", pipeline_response) @@ -844,10 +791,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -859,5 +807,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Synapse/privateLinkHubs"} diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_private_link_resources_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_private_link_resources_operations.py index 38687304521a..c52580998c80 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_private_link_resources_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_private_link_resources_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -19,20 +18,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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -46,7 +43,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -62,7 +59,7 @@ def build_list_request( "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -79,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: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -96,7 +93,7 @@ def build_get_request( "privateLinkResourceName": _SERIALIZER.url("private_link_resource_name", private_link_resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -139,7 +136,6 @@ def list( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_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.synapse.models.PrivateLinkResource] :raises ~azure.core.exceptions.HttpResponseError: @@ -147,10 +143,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -161,24 +157,21 @@ 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, workspace_name=workspace_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) @@ -188,10 +181,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -204,10 +198,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateLinkResources" - } - @distributed_trace def get( self, resource_group_name: str, workspace_name: str, private_link_resource_name: str, **kwargs: Any @@ -223,12 +213,11 @@ def get( :type workspace_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.synapse.models.PrivateLinkResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -239,24 +228,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -266,13 +254,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.Synapse/workspaces/{workspaceName}/privateLinkResources/{privateLinkResourceName}" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_restorable_dropped_sql_pools_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_restorable_dropped_sql_pools_operations.py index 63fbd86249d8..1f8611df1135 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_restorable_dropped_sql_pools_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_restorable_dropped_sql_pools_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -19,20 +18,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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +47,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -69,7 +66,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -86,7 +83,7 @@ def build_list_by_workspace_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -102,7 +99,7 @@ def build_list_by_workspace_request( "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -146,12 +143,11 @@ def get( :param restorable_dropped_sql_pool_id: The id of the deleted Sql Pool in the form of sqlPoolName,deletionTimeInFileTimeFormat. Required. :type restorable_dropped_sql_pool_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RestorableDroppedSqlPool or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.RestorableDroppedSqlPool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -162,24 +158,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.RestorableDroppedSqlPool] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, restorable_dropped_sql_pool_id=restorable_dropped_sql_pool_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -189,16 +184,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RestorableDroppedSqlPool", pipeline_response) + deserialized = self._deserialize("RestorableDroppedSqlPool", 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.Synapse/workspaces/{workspaceName}/restorableDroppedSqlPools/{restorableDroppedSqlPoolId}" - } + return deserialized # type: ignore @distributed_trace def list_by_workspace( @@ -211,7 +202,6 @@ def list_by_workspace( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RestorableDroppedSqlPool or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.RestorableDroppedSqlPool] @@ -220,10 +210,10 @@ def list_by_workspace( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.RestorableDroppedSqlPoolListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -234,24 +224,21 @@ def list_by_workspace( def prepare_request(next_link=None): if not next_link: - request = build_list_by_workspace_request( + _request = build_list_by_workspace_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_workspace.metadata["url"], 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RestorableDroppedSqlPoolListResult", pipeline_response) @@ -261,10 +248,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -276,7 +264,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_workspace.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/restorableDroppedSqlPools" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_spark_configuration_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_spark_configuration_operations.py index 7fc563835cb8..67b02f4e3337 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_spark_configuration_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_spark_configuration_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -18,20 +17,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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,9 +42,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -64,7 +59,7 @@ def build_get_request( "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -109,12 +104,11 @@ def get( :type spark_configuration_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SparkConfigurationResource or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SparkConfigurationResource :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -125,26 +119,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.SparkConfigurationResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, spark_configuration_name=spark_configuration_name, workspace_name=workspace_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -154,13 +145,9 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SparkConfigurationResource", pipeline_response) + deserialized = self._deserialize("SparkConfigurationResource", 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.Synapse/workspaces/{workspaceName}/sparkconfigurations/{sparkConfigurationName}" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_spark_configurations_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_spark_configurations_operations.py index 36d9dd86c788..87a1d23c097e 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_spark_configurations_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_spark_configurations_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -19,20 +18,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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -46,9 +43,7 @@ def build_list_by_workspace_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -64,7 +59,7 @@ def build_list_by_workspace_request( "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -107,7 +102,6 @@ def list_by_workspace( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SparkConfigurationResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.SparkConfigurationResource] @@ -116,12 +110,10 @@ def list_by_workspace( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2021-06-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) cls: ClsType[_models.SparkConfigurationListResponse] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -132,24 +124,21 @@ def list_by_workspace( def prepare_request(next_link=None): if not next_link: - request = build_list_by_workspace_request( + _request = build_list_by_workspace_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_workspace.metadata["url"], 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("SparkConfigurationListResponse", pipeline_response) @@ -159,10 +148,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -174,7 +164,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_workspace.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sparkconfigurations" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_blob_auditing_policies_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_blob_auditing_policies_operations.py index daa525383132..f8b1250d3c01 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_blob_auditing_policies_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_blob_auditing_policies_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,20 +19,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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -46,7 +44,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") accept = _headers.pop("Accept", "application/json") @@ -65,7 +63,7 @@ def build_get_request( "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -82,7 +80,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: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -102,7 +100,7 @@ def build_create_or_update_request( "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -121,7 +119,7 @@ def build_list_by_sql_pool_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -138,7 +136,7 @@ def build_list_by_sql_pool_request( "sqlPoolName": _SERIALIZER.url("sql_pool_name", sql_pool_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -183,15 +181,11 @@ def get( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword blob_auditing_policy_name: The name of the blob auditing policy. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype blob_auditing_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SqlPoolBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolBlobAuditingPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -202,26 +196,25 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") cls: ClsType[_models.SqlPoolBlobAuditingPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, subscription_id=self._config.subscription_id, api_version=api_version, blob_auditing_policy_name=blob_auditing_policy_name, - 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -230,16 +223,12 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("SqlPoolBlobAuditingPolicy", pipeline_response) + deserialized = self._deserialize("SqlPoolBlobAuditingPolicy", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/auditingSettings/{blobAuditingPolicyName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -268,10 +257,6 @@ def 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 blob_auditing_policy_name: The name of the blob auditing policy. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype blob_auditing_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SqlPoolBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolBlobAuditingPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -283,7 +268,7 @@ def create_or_update( resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -300,14 +285,10 @@ def create_or_update( :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str :param parameters: The database blob auditing policy. 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 blob_auditing_policy_name: The name of the blob auditing policy. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype blob_auditing_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SqlPoolBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolBlobAuditingPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -319,7 +300,7 @@ def create_or_update( resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: Union[_models.SqlPoolBlobAuditingPolicy, IO], + parameters: Union[_models.SqlPoolBlobAuditingPolicy, IO[bytes]], **kwargs: Any ) -> _models.SqlPoolBlobAuditingPolicy: """Creates or updates a SQL pool's blob auditing policy. @@ -333,21 +314,14 @@ def create_or_update( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param parameters: The database blob auditing policy. Is either a model type or a IO type. - Required. - :type parameters: ~azure.mgmt.synapse.models.SqlPoolBlobAuditingPolicy or IO - :keyword blob_auditing_policy_name: The name of the blob auditing policy. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype blob_auditing_policy_name: 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 + :param parameters: The database blob auditing policy. Is either a SqlPoolBlobAuditingPolicy + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.SqlPoolBlobAuditingPolicy or IO[bytes] :return: SqlPoolBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolBlobAuditingPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -358,7 +332,7 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) blob_auditing_policy_name: Literal["default"] = kwargs.pop("blob_auditing_policy_name", "default") content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SqlPoolBlobAuditingPolicy] = kwargs.pop("cls", None) @@ -366,12 +340,12 @@ def create_or_update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "SqlPoolBlobAuditingPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -381,15 +355,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -398,21 +371,13 @@ def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("SqlPoolBlobAuditingPolicy", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SqlPoolBlobAuditingPolicy", pipeline_response) + deserialized = self._deserialize("SqlPoolBlobAuditingPolicy", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/auditingSettings/{blobAuditingPolicyName}" - } - @distributed_trace def list_by_sql_pool( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any @@ -426,7 +391,6 @@ def list_by_sql_pool( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SqlPoolBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.SqlPoolBlobAuditingPolicy] @@ -435,10 +399,10 @@ def list_by_sql_pool( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPoolBlobAuditingPolicyListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -449,25 +413,22 @@ def list_by_sql_pool( def prepare_request(next_link=None): if not next_link: - request = build_list_by_sql_pool_request( + _request = build_list_by_sql_pool_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_sql_pool.metadata["url"], 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("SqlPoolBlobAuditingPolicyListResult", pipeline_response) @@ -477,10 +438,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -491,7 +453,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_sql_pool.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/auditingSettings" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_columns_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_columns_operations.py index 483c4678eb7f..2c4123171329 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_columns_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_columns_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -18,20 +17,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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +49,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -72,7 +69,7 @@ def build_get_request( "columnName": _SERIALIZER.url("column_name", column_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -128,12 +125,11 @@ def get( :type table_name: str :param column_name: The name of the column. Required. :type column_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SqlPoolColumn or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolColumn :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -144,10 +140,10 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPoolColumn] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -156,15 +152,14 @@ def get( column_name=column_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -173,13 +168,9 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("SqlPoolColumn", pipeline_response) + deserialized = self._deserialize("SqlPoolColumn", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_connection_policies_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_connection_policies_operations.py index 4b52bb8cd852..04534ffc6931 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_connection_policies_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_connection_policies_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -18,20 +17,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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +47,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -68,7 +65,7 @@ def build_get_request( "connectionPolicyName": _SERIALIZER.url("connection_policy_name", connection_policy_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -120,12 +117,11 @@ def get( :type sql_pool_name: str :param connection_policy_name: The name of the connection policy. "default" Required. :type connection_policy_name: str or ~azure.mgmt.synapse.models.ConnectionPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: SqlPoolConnectionPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolConnectionPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -136,25 +132,24 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPoolConnectionPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, connection_policy_name=connection_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -164,13 +159,9 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SqlPoolConnectionPolicy", pipeline_response) + deserialized = self._deserialize("SqlPoolConnectionPolicy", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/connectionPolicies/{connectionPolicyName}" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_data_warehouse_user_activities_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_data_warehouse_user_activities_operations.py index 67126c3e6a1e..6a37ffea5f50 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_data_warehouse_user_activities_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_data_warehouse_user_activities_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -18,20 +17,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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +47,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -70,7 +67,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -81,7 +78,7 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class SqlPoolDataWarehouseUserActivitiesOperations: +class SqlPoolDataWarehouseUserActivitiesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -124,12 +121,11 @@ def get( Required. :type data_warehouse_user_activity_name: str or ~azure.mgmt.synapse.models.DataWarehouseUserActivityName - :keyword callable cls: A custom type or function that will be passed the direct response :return: DataWarehouseUserActivities or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.DataWarehouseUserActivities :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -140,25 +136,24 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.DataWarehouseUserActivities] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, data_warehouse_user_activity_name=data_warehouse_user_activity_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -167,13 +162,9 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("DataWarehouseUserActivities", pipeline_response) + deserialized = self._deserialize("DataWarehouseUserActivities", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataWarehouseUserActivities/{dataWarehouseUserActivityName}" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_geo_backup_policies_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_geo_backup_policies_operations.py index d75196c59e8a..dadbfff57e98 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_geo_backup_policies_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_geo_backup_policies_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload @@ -19,20 +19,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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -46,7 +44,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -63,7 +61,7 @@ def build_list_request( "sqlPoolName": _SERIALIZER.url("sql_pool_name", sql_pool_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -85,7 +83,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: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -104,7 +102,7 @@ def build_create_or_update_request( "geoBackupPolicyName": _SERIALIZER.url("geo_backup_policy_name", geo_backup_policy_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -128,7 +126,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -146,7 +144,7 @@ def build_get_request( "geoBackupPolicyName": _SERIALIZER.url("geo_backup_policy_name", geo_backup_policy_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -191,7 +189,6 @@ def list( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either GeoBackupPolicy or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.GeoBackupPolicy] :raises ~azure.core.exceptions.HttpResponseError: @@ -199,10 +196,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.GeoBackupPolicyListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -213,25 +210,22 @@ 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, workspace_name=workspace_name, sql_pool_name=sql_pool_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("GeoBackupPolicyListResult", pipeline_response) @@ -241,10 +235,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -257,10 +252,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/geoBackupPolicies" - } - @overload def create_or_update( self, @@ -290,7 +281,6 @@ def 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 :return: GeoBackupPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.GeoBackupPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -303,7 +293,7 @@ def create_or_update( workspace_name: str, sql_pool_name: str, geo_backup_policy_name: Union[str, _models.GeoBackupPolicyName], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -321,11 +311,10 @@ def create_or_update( :type geo_backup_policy_name: str or ~azure.mgmt.synapse.models.GeoBackupPolicyName :param parameters: The required parameters for creating or updating the geo backup policy. 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: GeoBackupPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.GeoBackupPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -338,7 +327,7 @@ def create_or_update( workspace_name: str, sql_pool_name: str, geo_backup_policy_name: Union[str, _models.GeoBackupPolicyName], - parameters: Union[_models.GeoBackupPolicy, IO], + parameters: Union[_models.GeoBackupPolicy, IO[bytes]], **kwargs: Any ) -> _models.GeoBackupPolicy: """Updates a SQL Pool geo backup policy. @@ -353,17 +342,13 @@ def create_or_update( :param geo_backup_policy_name: The name of the geo backup policy. "Default" Required. :type geo_backup_policy_name: str or ~azure.mgmt.synapse.models.GeoBackupPolicyName :param parameters: The required parameters for creating or updating the geo backup policy. Is - either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.models.GeoBackupPolicy 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 + either a GeoBackupPolicy type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.GeoBackupPolicy or IO[bytes] :return: GeoBackupPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.GeoBackupPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -374,19 +359,19 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.GeoBackupPolicy] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "GeoBackupPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -396,15 +381,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -414,21 +398,13 @@ def create_or_update( 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("GeoBackupPolicy", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("GeoBackupPolicy", pipeline_response) + deserialized = self._deserialize("GeoBackupPolicy", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/geoBackupPolicies/{geoBackupPolicyName}" - } - @distributed_trace def get( self, @@ -451,12 +427,11 @@ def get( :type sql_pool_name: str :param geo_backup_policy_name: The name of the geo backup policy. "Default" Required. :type geo_backup_policy_name: str or ~azure.mgmt.synapse.models.GeoBackupPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: GeoBackupPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.GeoBackupPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -467,25 +442,24 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.GeoBackupPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, geo_backup_policy_name=geo_backup_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -495,13 +469,9 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GeoBackupPolicy", pipeline_response) + deserialized = self._deserialize("GeoBackupPolicy", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/geoBackupPolicies/{geoBackupPolicyName}" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_maintenance_window_options_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_maintenance_window_options_operations.py index 29b4f0a77476..f1bcbd70fa1e 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_maintenance_window_options_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_maintenance_window_options_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -18,20 +17,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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +48,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -68,7 +65,7 @@ def build_get_request( "sqlPoolName": _SERIALIZER.url("sql_pool_name", sql_pool_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -82,7 +79,7 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class SqlPoolMaintenanceWindowOptionsOperations: +class SqlPoolMaintenanceWindowOptionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -123,12 +120,11 @@ def get( :type sql_pool_name: str :param maintenance_window_options_name: Maintenance window options name. Required. :type maintenance_window_options_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: MaintenanceWindowOptions or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.MaintenanceWindowOptions :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -139,25 +135,24 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.MaintenanceWindowOptions] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, subscription_id=self._config.subscription_id, maintenance_window_options_name=maintenance_window_options_name, 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -166,13 +161,9 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("MaintenanceWindowOptions", pipeline_response) + deserialized = self._deserialize("MaintenanceWindowOptions", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/maintenanceWindowOptions/current" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_maintenance_windows_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_maintenance_windows_operations.py index d47844f786c4..a1af4f21eb4d 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_maintenance_windows_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_maintenance_windows_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload @@ -18,20 +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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +49,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -68,7 +66,7 @@ def build_get_request( "sqlPoolName": _SERIALIZER.url("sql_pool_name", sql_pool_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -92,7 +90,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: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # Construct URL _url = kwargs.pop( @@ -108,7 +106,7 @@ def build_create_or_update_request( "sqlPoolName": _SERIALIZER.url("sql_pool_name", sql_pool_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -162,12 +160,11 @@ def get( :type sql_pool_name: str :param maintenance_window_name: Maintenance window name. Required. :type maintenance_window_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: MaintenanceWindows or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.MaintenanceWindows :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -178,25 +175,24 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.MaintenanceWindows] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, subscription_id=self._config.subscription_id, maintenance_window_name=maintenance_window_name, 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -206,19 +202,15 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("MaintenanceWindows", pipeline_response) + deserialized = self._deserialize("MaintenanceWindows", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/maintenancewindows/current" - } + return deserialized # type: ignore @overload - def create_or_update( # pylint: disable=inconsistent-return-statements + def create_or_update( self, resource_group_name: str, workspace_name: str, @@ -248,20 +240,19 @@ def create_or_update( # pylint: disable=inconsistent-return-statements :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. 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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create_or_update( # pylint: disable=inconsistent-return-statements + def create_or_update( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, maintenance_window_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -281,11 +272,10 @@ def create_or_update( # pylint: disable=inconsistent-return-statements :type maintenance_window_name: str :param parameters: The required parameters for creating or updating Maintenance Windows settings. 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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -298,7 +288,7 @@ def create_or_update( # pylint: disable=inconsistent-return-statements workspace_name: str, sql_pool_name: str, maintenance_window_name: str, - parameters: Union[_models.MaintenanceWindows, IO], + parameters: Union[_models.MaintenanceWindows, IO[bytes]], **kwargs: Any ) -> None: """Creates or updates a Sql pool's maintenance windows settings. @@ -315,17 +305,13 @@ def create_or_update( # pylint: disable=inconsistent-return-statements :param maintenance_window_name: Maintenance window name. Required. :type maintenance_window_name: str :param parameters: The required parameters for creating or updating Maintenance Windows - settings. Is either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.models.MaintenanceWindows 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 + settings. Is either a MaintenanceWindows type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.MaintenanceWindows or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -336,19 +322,19 @@ def create_or_update( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "MaintenanceWindows") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -358,15 +344,14 @@ def create_or_update( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -376,8 +361,4 @@ def create_or_update( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/maintenancewindows/current" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_metadata_sync_configs_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_metadata_sync_configs_operations.py index b46547de8446..91955f65a6ba 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_metadata_sync_configs_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_metadata_sync_configs_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload @@ -18,20 +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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +43,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -62,7 +60,7 @@ def build_get_request( "sqlPoolName": _SERIALIZER.url("sql_pool_name", sql_pool_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -79,7 +77,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -97,7 +95,7 @@ def build_create_request( "sqlPoolName": _SERIALIZER.url("sql_pool_name", sql_pool_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -144,40 +142,38 @@ def get( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: MetadataSyncConfig or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.MetadataSyncConfig :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, + 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, - 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.MetadataSyncConfig] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -187,16 +183,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("MetadataSyncConfig", pipeline_response) + deserialized = self._deserialize("MetadataSyncConfig", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/metadataSync/config" - } + return deserialized # type: ignore @overload def create( @@ -225,7 +217,6 @@ def create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. 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: MetadataSyncConfig or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.MetadataSyncConfig :raises ~azure.core.exceptions.HttpResponseError: @@ -237,7 +228,7 @@ def create( resource_group_name: str, workspace_name: str, sql_pool_name: str, - metadata_sync_configuration: IO, + metadata_sync_configuration: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -254,11 +245,10 @@ def create( :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str :param metadata_sync_configuration: Metadata sync configuration. Required. - :type metadata_sync_configuration: IO + :type metadata_sync_configuration: 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: MetadataSyncConfig or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.MetadataSyncConfig :raises ~azure.core.exceptions.HttpResponseError: @@ -270,7 +260,7 @@ def create( resource_group_name: str, workspace_name: str, sql_pool_name: str, - metadata_sync_configuration: Union[_models.MetadataSyncConfig, IO], + metadata_sync_configuration: Union[_models.MetadataSyncConfig, IO[bytes]], **kwargs: Any ) -> _models.MetadataSyncConfig: """Set SQL pool metadata sync config. @@ -284,41 +274,37 @@ def create( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param metadata_sync_configuration: Metadata sync configuration. Is either a model type or a IO - type. Required. - :type metadata_sync_configuration: ~azure.mgmt.synapse.models.MetadataSyncConfig 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 metadata_sync_configuration: Metadata sync configuration. Is either a MetadataSyncConfig + type or a IO[bytes] type. Required. + :type metadata_sync_configuration: ~azure.mgmt.synapse.models.MetadataSyncConfig or IO[bytes] :return: MetadataSyncConfig or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.MetadataSyncConfig :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, + 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, - 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), } 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: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.MetadataSyncConfig] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(metadata_sync_configuration, (IO, bytes)): + if isinstance(metadata_sync_configuration, (IOBase, bytes)): _content = metadata_sync_configuration else: _json = self._serialize.body(metadata_sync_configuration, "MetadataSyncConfig") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -327,15 +313,14 @@ def create( content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -345,13 +330,9 @@ def create( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("MetadataSyncConfig", pipeline_response) + deserialized = self._deserialize("MetadataSyncConfig", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/metadataSync/config" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_operation_results_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_operation_results_operations.py index bc29e86ba0e0..8ad36f9a3949 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_operation_results_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_operation_results_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, TypeVar, Union, cast +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,22 +17,18 @@ map_error, ) 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 -from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +47,7 @@ def build_get_location_header_result_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -70,7 +65,7 @@ def build_get_location_header_result_request( "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -100,10 +95,28 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - def _get_location_header_result_initial( + @distributed_trace + def get_location_header_result( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, operation_id: str, **kwargs: Any ) -> _models.SqlPool: - error_map = { + """Get SQL pool operation status. + + Get the status of a SQL pool operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param sql_pool_name: SQL pool name. Required. + :type sql_pool_name: str + :param operation_id: Operation ID. Required. + :type operation_id: str + :return: SqlPool or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.SqlPool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -114,121 +127,36 @@ def _get_location_header_result_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPool] = kwargs.pop("cls", None) - request = build_get_location_header_result_request( + _request = build_get_location_header_result_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, operation_id=operation_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._get_location_header_result_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 pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("SqlPool", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("SqlPool", pipeline_response) + deserialized = self._deserialize("SqlPool", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - - _get_location_header_result_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/operationResults/{operationId}" - } - - @distributed_trace - def begin_get_location_header_result( - self, resource_group_name: str, workspace_name: str, sql_pool_name: str, operation_id: str, **kwargs: Any - ) -> LROPoller[_models.SqlPool]: - """Get SQL pool operation status. - - Get the status of a SQL pool operation. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param workspace_name: The name of the workspace. Required. - :type workspace_name: str - :param sql_pool_name: SQL pool name. Required. - :type sql_pool_name: str - :param operation_id: Operation ID. Required. - :type operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~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 SqlPool or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.SqlPool] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - cls: ClsType[_models.SqlPool] = 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._get_location_header_result_initial( - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - operation_id=operation_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SqlPool", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - 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.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_get_location_header_result.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/operationResults/{operationId}" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_operations_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_operations_operations.py index 6bf40761f667..1ccb029eb452 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_operations_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_operations_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -19,20 +18,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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -46,7 +43,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -63,7 +60,7 @@ def build_list_request( "sqlPoolName": _SERIALIZER.url("sql_pool_name", sql_pool_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -108,7 +105,6 @@ def list( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SqlPoolOperation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.SqlPoolOperation] :raises ~azure.core.exceptions.HttpResponseError: @@ -116,10 +112,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPoolBlobAuditingPolicySqlPoolOperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -130,25 +126,22 @@ 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, workspace_name=workspace_name, sql_pool_name=sql_pool_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("SqlPoolBlobAuditingPolicySqlPoolOperationListResult", pipeline_response) @@ -158,10 +151,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -172,7 +166,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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/operations" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_recommended_sensitivity_labels_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_recommended_sensitivity_labels_operations.py index 7c165e9f2d43..6da6b2677680 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_recommended_sensitivity_labels_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_recommended_sensitivity_labels_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload @@ -18,20 +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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +43,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # Construct URL _url = kwargs.pop( @@ -61,7 +59,7 @@ def build_update_request( "sqlPoolName": _SERIALIZER.url("sql_pool_name", sql_pool_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -73,7 +71,7 @@ def build_update_request( return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -class SqlPoolRecommendedSensitivityLabelsOperations: +class SqlPoolRecommendedSensitivityLabelsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -93,7 +91,7 @@ def __init__(self, *args, **kwargs): self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @overload - def update( # pylint: disable=inconsistent-return-statements + def update( self, resource_group_name: str, workspace_name: str, @@ -117,19 +115,18 @@ def update( # pylint: disable=inconsistent-return-statements :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. 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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def update( # pylint: disable=inconsistent-return-statements + def update( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -144,11 +141,10 @@ def update( # pylint: disable=inconsistent-return-statements :param sql_pool_name: SQL pool name. Required. :type sql_pool_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 :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -160,7 +156,7 @@ def update( # pylint: disable=inconsistent-return-statements resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: Union[_models.RecommendedSensitivityLabelUpdateList, IO], + parameters: Union[_models.RecommendedSensitivityLabelUpdateList, IO[bytes]], **kwargs: Any ) -> None: """Update recommended sensitivity labels states of a given SQL Pool using an operations batch. @@ -172,17 +168,14 @@ def update( # pylint: disable=inconsistent-return-statements :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param parameters: Is either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.models.RecommendedSensitivityLabelUpdateList 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 parameters: Is either a RecommendedSensitivityLabelUpdateList type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.synapse.models.RecommendedSensitivityLabelUpdateList or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -193,19 +186,19 @@ def update( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RecommendedSensitivityLabelUpdateList") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -214,15 +207,14 @@ def update( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -232,8 +224,4 @@ def update( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/recommendedSensitivityLabels" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_replication_links_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_replication_links_operations.py index f4a88f882acf..fba6e468269d 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_replication_links_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_replication_links_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -19,20 +18,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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -46,7 +43,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -63,7 +60,7 @@ def build_list_request( "sqlPoolName": _SERIALIZER.url("sql_pool_name", sql_pool_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -80,7 +77,7 @@ def build_get_by_name_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -98,7 +95,7 @@ def build_get_by_name_request( "linkId": _SERIALIZER.url("link_id", link_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -143,7 +140,6 @@ def list( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ReplicationLink or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.ReplicationLink] :raises ~azure.core.exceptions.HttpResponseError: @@ -151,10 +147,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.ReplicationLinkListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -165,25 +161,22 @@ 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, workspace_name=workspace_name, sql_pool_name=sql_pool_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ReplicationLinkListResult", pipeline_response) @@ -193,10 +186,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -209,10 +203,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/replicationLinks" - } - @distributed_trace def get_by_name( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, link_id: str, **kwargs: Any @@ -230,12 +220,11 @@ def get_by_name( :type sql_pool_name: str :param link_id: The ID of the replication link. Required. :type link_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ReplicationLink or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ReplicationLink :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -246,25 +235,24 @@ def get_by_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.ReplicationLink] = kwargs.pop("cls", None) - request = build_get_by_name_request( + _request = build_get_by_name_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, link_id=link_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_by_name.metadata["url"], 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -274,13 +262,9 @@ def get_by_name( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ReplicationLink", pipeline_response) + deserialized = self._deserialize("ReplicationLink", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_by_name.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/replicationLinks/{linkId}" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_restore_points_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_restore_points_operations.py index 80fff7458096..693cce320f88 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_restore_points_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_restore_points_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,13 +15,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 @@ -29,12 +30,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -48,7 +48,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -65,7 +65,7 @@ def build_list_request( "sqlPoolName": _SERIALIZER.url("sql_pool_name", sql_pool_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -82,7 +82,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -100,7 +100,7 @@ def build_create_request( "sqlPoolName": _SERIALIZER.url("sql_pool_name", sql_pool_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -124,7 +124,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -142,7 +142,7 @@ def build_get_request( "restorePointName": _SERIALIZER.url("restore_point_name", restore_point_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -163,7 +163,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # Construct URL _url = kwargs.pop( "template_url", @@ -179,7 +179,7 @@ def build_delete_request( "restorePointName": _SERIALIZER.url("restore_point_name", restore_point_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -221,7 +221,6 @@ def list( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RestorePoint or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.RestorePoint] :raises ~azure.core.exceptions.HttpResponseError: @@ -229,10 +228,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.RestorePointListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -243,25 +242,22 @@ 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, workspace_name=workspace_name, sql_pool_name=sql_pool_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RestorePointListResult", pipeline_response) @@ -271,10 +267,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -287,19 +284,15 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints" - } - def _create_initial( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: Union[_models.CreateSqlPoolRestorePointDefinition, IO], + parameters: Union[_models.CreateSqlPoolRestorePointDefinition, IO[bytes]], **kwargs: Any - ) -> Optional[_models.RestorePoint]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -310,19 +303,19 @@ def _create_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.RestorePoint]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "CreateSqlPoolRestorePointDefinition") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -331,38 +324,33 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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=False, **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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("RestorePoint", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("RestorePoint", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints" - } + return deserialized # type: ignore @overload def begin_create( @@ -389,14 +377,6 @@ def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~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 RestorePoint or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.RestorePoint] @@ -409,7 +389,7 @@ def begin_create( resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -424,18 +404,10 @@ def begin_create( :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str :param parameters: The definition for creating the restore point of this Sql pool. 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 RestorePoint or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.RestorePoint] @@ -448,7 +420,7 @@ def begin_create( resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: Union[_models.CreateSqlPoolRestorePointDefinition, IO], + parameters: Union[_models.CreateSqlPoolRestorePointDefinition, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.RestorePoint]: """Creates a restore point for a data warehouse. @@ -461,19 +433,8 @@ def begin_create( :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str :param parameters: The definition for creating the restore point of this Sql pool. Is either a - model type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.models.CreateSqlPoolRestorePointDefinition 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. + CreateSqlPoolRestorePointDefinition type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.CreateSqlPoolRestorePointDefinition or IO[bytes] :return: An instance of LROPoller that returns either RestorePoint or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.RestorePoint] @@ -482,7 +443,7 @@ def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RestorePoint] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -501,12 +462,13 @@ def begin_create( 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("RestorePoint", pipeline_response) + deserialized = self._deserialize("RestorePoint", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -518,17 +480,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.RestorePoint].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints" - } + return LROPoller[_models.RestorePoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def get( @@ -545,12 +505,11 @@ def get( :type sql_pool_name: str :param restore_point_name: The name of the restore point. Required. :type restore_point_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RestorePoint or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.RestorePoint :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -561,25 +520,24 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.RestorePoint] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, restore_point_name=restore_point_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -588,16 +546,12 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RestorePoint", pipeline_response) + deserialized = self._deserialize("RestorePoint", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints/{restorePointName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -614,12 +568,11 @@ def delete( # pylint: disable=inconsistent-return-statements :type sql_pool_name: str :param restore_point_name: The name of the restore point. Required. :type restore_point_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -630,25 +583,24 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, restore_point_name=restore_point_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -658,8 +610,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints/{restorePointName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_schemas_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_schemas_operations.py index e43102252ea1..ad0d269abdae 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_schemas_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_schemas_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -19,20 +18,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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +49,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -69,7 +66,7 @@ def build_list_request( "sqlPoolName": _SERIALIZER.url("sql_pool_name", sql_pool_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -93,7 +90,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -111,7 +108,7 @@ def build_get_request( "schemaName": _SERIALIZER.url("schema_name", schema_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -164,7 +161,6 @@ def list( :param filter: An OData filter expression that filters elements in the collection. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SqlPoolSchema or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.SqlPoolSchema] :raises ~azure.core.exceptions.HttpResponseError: @@ -172,10 +168,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPoolSchemaListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -186,26 +182,23 @@ 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, workspace_name=workspace_name, sql_pool_name=sql_pool_name, subscription_id=self._config.subscription_id, filter=filter, 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("SqlPoolSchemaListResult", pipeline_response) @@ -215,10 +208,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -230,10 +224,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas" - } - @distributed_trace def get( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, schema_name: str, **kwargs: Any @@ -249,12 +239,11 @@ def get( :type sql_pool_name: str :param schema_name: The name of the schema. Required. :type schema_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SqlPoolSchema or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolSchema :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -265,25 +254,24 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPoolSchema] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, schema_name=schema_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -292,13 +280,9 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("SqlPoolSchema", pipeline_response) + deserialized = self._deserialize("SqlPoolSchema", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_security_alert_policies_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_security_alert_policies_operations.py index e6003c6ff571..96284d0aeb26 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_security_alert_policies_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_security_alert_policies_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload @@ -19,20 +19,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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -46,7 +44,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -63,7 +61,7 @@ def build_list_request( "sqlPoolName": _SERIALIZER.url("sql_pool_name", sql_pool_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -85,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: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -103,7 +101,7 @@ def build_get_request( "securityAlertPolicyName": _SERIALIZER.url("security_alert_policy_name", security_alert_policy_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -125,7 +123,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: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -144,7 +142,7 @@ def build_create_or_update_request( "securityAlertPolicyName": _SERIALIZER.url("security_alert_policy_name", security_alert_policy_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -191,7 +189,6 @@ def list( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SqlPoolSecurityAlertPolicy or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.SqlPoolSecurityAlertPolicy] @@ -200,10 +197,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.ListSqlPoolSecurityAlertPolicies] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -214,25 +211,22 @@ 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, workspace_name=workspace_name, sql_pool_name=sql_pool_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListSqlPoolSecurityAlertPolicies", pipeline_response) @@ -242,10 +236,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -257,10 +252,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/securityAlertPolicies" - } - @distributed_trace def get( self, @@ -283,12 +274,11 @@ def get( :type sql_pool_name: str :param security_alert_policy_name: The name of the security alert policy. "default" Required. :type security_alert_policy_name: str or ~azure.mgmt.synapse.models.SecurityAlertPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: SqlPoolSecurityAlertPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolSecurityAlertPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -299,25 +289,24 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPoolSecurityAlertPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, security_alert_policy_name=security_alert_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -326,16 +315,12 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("SqlPoolSecurityAlertPolicy", pipeline_response) + deserialized = self._deserialize("SqlPoolSecurityAlertPolicy", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/securityAlertPolicies/{securityAlertPolicyName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -367,7 +352,6 @@ def 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 :return: SqlPoolSecurityAlertPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolSecurityAlertPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -380,7 +364,7 @@ def create_or_update( workspace_name: str, sql_pool_name: str, security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -399,11 +383,10 @@ def create_or_update( :param security_alert_policy_name: The name of the security alert policy. "default" Required. :type security_alert_policy_name: str or ~azure.mgmt.synapse.models.SecurityAlertPolicyName :param parameters: The Sql pool security alert policy. 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: SqlPoolSecurityAlertPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolSecurityAlertPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -416,7 +399,7 @@ def create_or_update( workspace_name: str, sql_pool_name: str, security_alert_policy_name: Union[str, _models.SecurityAlertPolicyName], - parameters: Union[_models.SqlPoolSecurityAlertPolicy, IO], + parameters: Union[_models.SqlPoolSecurityAlertPolicy, IO[bytes]], **kwargs: Any ) -> _models.SqlPoolSecurityAlertPolicy: """Create or update a Sql pool's security alert policy. @@ -432,18 +415,14 @@ def create_or_update( :type sql_pool_name: str :param security_alert_policy_name: The name of the security alert policy. "default" Required. :type security_alert_policy_name: str or ~azure.mgmt.synapse.models.SecurityAlertPolicyName - :param parameters: The Sql pool security alert policy. Is either a model type or a IO type. - Required. - :type parameters: ~azure.mgmt.synapse.models.SqlPoolSecurityAlertPolicy 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 parameters: The Sql pool security alert policy. Is either a SqlPoolSecurityAlertPolicy + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.SqlPoolSecurityAlertPolicy or IO[bytes] :return: SqlPoolSecurityAlertPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolSecurityAlertPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -454,19 +433,19 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SqlPoolSecurityAlertPolicy] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "SqlPoolSecurityAlertPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -476,15 +455,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -493,17 +471,9 @@ def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("SqlPoolSecurityAlertPolicy", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SqlPoolSecurityAlertPolicy", pipeline_response) + deserialized = self._deserialize("SqlPoolSecurityAlertPolicy", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/securityAlertPolicies/{securityAlertPolicyName}" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_sensitivity_labels_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_sensitivity_labels_operations.py index ab1563a60572..5de4c6b3047d 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_sensitivity_labels_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_sensitivity_labels_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,20 +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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +51,7 @@ def build_list_current_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -69,7 +68,7 @@ def build_list_current_request( "sqlPoolName": _SERIALIZER.url("sql_pool_name", sql_pool_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -88,7 +87,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # Construct URL _url = kwargs.pop( @@ -104,7 +103,7 @@ def build_update_request( "sqlPoolName": _SERIALIZER.url("sql_pool_name", sql_pool_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -130,7 +129,7 @@ def build_list_recommended_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -147,7 +146,7 @@ def build_list_recommended_request( "sqlPoolName": _SERIALIZER.url("sql_pool_name", sql_pool_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -179,7 +178,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: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -202,7 +201,7 @@ def build_create_or_update_request( "sensitivityLabelSource": _SERIALIZER.url("sensitivity_label_source", sensitivity_label_source, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -227,7 +226,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") # Construct URL _url = kwargs.pop( @@ -247,7 +246,7 @@ def build_delete_request( "sensitivityLabelSource": _SERIALIZER.url("sensitivity_label_source", sensitivity_label_source, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -269,7 +268,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -290,7 +289,7 @@ def build_get_request( "sensitivityLabelSource": _SERIALIZER.url("sensitivity_label_source", sensitivity_label_source, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -313,7 +312,7 @@ def build_enable_recommendation_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") # Construct URL _url = kwargs.pop( @@ -333,7 +332,7 @@ def build_enable_recommendation_request( "sensitivityLabelSource": _SERIALIZER.url("sensitivity_label_source", sensitivity_label_source, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -353,7 +352,7 @@ def build_disable_recommendation_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") # Construct URL _url = kwargs.pop( @@ -373,7 +372,7 @@ def build_disable_recommendation_request( "sensitivityLabelSource": _SERIALIZER.url("sensitivity_label_source", sensitivity_label_source, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -423,7 +422,6 @@ def list_current( :param filter: An OData filter expression that filters elements in the collection. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SensitivityLabel or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.SensitivityLabel] :raises ~azure.core.exceptions.HttpResponseError: @@ -431,10 +429,10 @@ def list_current( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SensitivityLabelListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -445,26 +443,23 @@ def list_current( def prepare_request(next_link=None): if not next_link: - request = build_list_current_request( + _request = build_list_current_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list_current.metadata["url"], 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("SensitivityLabelListResult", pipeline_response) @@ -474,10 +469,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -490,12 +486,8 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_current.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/currentSensitivityLabels" - } - @overload - def update( # pylint: disable=inconsistent-return-statements + def update( self, resource_group_name: str, workspace_name: str, @@ -519,19 +511,18 @@ def update( # pylint: disable=inconsistent-return-statements :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. 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: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def update( # pylint: disable=inconsistent-return-statements + def update( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -546,11 +537,10 @@ def update( # pylint: disable=inconsistent-return-statements :param sql_pool_name: SQL pool name. Required. :type sql_pool_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 :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -562,7 +552,7 @@ def update( # pylint: disable=inconsistent-return-statements resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: Union[_models.SensitivityLabelUpdateList, IO], + parameters: Union[_models.SensitivityLabelUpdateList, IO[bytes]], **kwargs: Any ) -> None: """Update sensitivity labels of a given SQL Pool using an operations batch. @@ -574,17 +564,13 @@ def update( # pylint: disable=inconsistent-return-statements :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param parameters: Is either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.models.SensitivityLabelUpdateList 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 parameters: Is either a SensitivityLabelUpdateList type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.SensitivityLabelUpdateList or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -595,19 +581,19 @@ def update( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "SensitivityLabelUpdateList") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -616,15 +602,14 @@ def update( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -634,11 +619,7 @@ def update( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/currentSensitivityLabels" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list_recommended( @@ -671,7 +652,6 @@ def list_recommended( :param filter: An OData filter expression that filters elements in the collection. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SensitivityLabel or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.SensitivityLabel] :raises ~azure.core.exceptions.HttpResponseError: @@ -679,10 +659,10 @@ def list_recommended( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SensitivityLabelListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -693,7 +673,7 @@ def list_recommended( def prepare_request(next_link=None): if not next_link: - request = build_list_recommended_request( + _request = build_list_recommended_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -702,19 +682,16 @@ def prepare_request(next_link=None): skip_token=skip_token, filter=filter, api_version=api_version, - template_url=self.list_recommended.metadata["url"], 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("SensitivityLabelListResult", pipeline_response) @@ -724,10 +701,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -739,10 +717,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_recommended.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/recommendedSensitivityLabels" - } - @overload def create_or_update( self, @@ -777,10 +751,6 @@ def 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 sensitivity_label_source: The source of the sensitivity label. Default value is - "current". Note that overriding this default value may result in unsupported behavior. - :paramtype sensitivity_label_source: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SensitivityLabel or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SensitivityLabel :raises ~azure.core.exceptions.HttpResponseError: @@ -795,7 +765,7 @@ def create_or_update( schema_name: str, table_name: str, column_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -816,14 +786,10 @@ def create_or_update( :param column_name: The name of the column. Required. :type column_name: str :param parameters: The column sensitivity label resource. 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 sensitivity_label_source: The source of the sensitivity label. Default value is - "current". Note that overriding this default value may result in unsupported behavior. - :paramtype sensitivity_label_source: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SensitivityLabel or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SensitivityLabel :raises ~azure.core.exceptions.HttpResponseError: @@ -838,7 +804,7 @@ def create_or_update( schema_name: str, table_name: str, column_name: str, - parameters: Union[_models.SensitivityLabel, IO], + parameters: Union[_models.SensitivityLabel, IO[bytes]], **kwargs: Any ) -> _models.SensitivityLabel: """Creates or updates the sensitivity label of a given column in a Sql pool. @@ -856,21 +822,14 @@ def create_or_update( :type table_name: str :param column_name: The name of the column. Required. :type column_name: str - :param parameters: The column sensitivity label resource. Is either a model type or a IO type. - Required. - :type parameters: ~azure.mgmt.synapse.models.SensitivityLabel or IO - :keyword sensitivity_label_source: The source of the sensitivity label. Default value is - "current". Note that overriding this default value may result in unsupported behavior. - :paramtype sensitivity_label_source: 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 + :param parameters: The column sensitivity label resource. Is either a SensitivityLabel type or + a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.SensitivityLabel or IO[bytes] :return: SensitivityLabel or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SensitivityLabel :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -881,7 +840,7 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SensitivityLabel] = kwargs.pop("cls", None) @@ -889,12 +848,12 @@ def create_or_update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "SensitivityLabel") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -907,15 +866,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -924,21 +882,13 @@ def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("SensitivityLabel", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SensitivityLabel", pipeline_response) + deserialized = self._deserialize("SensitivityLabel", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}" - } - @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, @@ -965,15 +915,11 @@ def delete( # pylint: disable=inconsistent-return-statements :type table_name: str :param column_name: The name of the column. Required. :type column_name: str - :keyword sensitivity_label_source: The source of the sensitivity label. Default value is - "current". Note that overriding this default value may result in unsupported behavior. - :paramtype sensitivity_label_source: 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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -984,11 +930,11 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) sensitivity_label_source: Literal["current"] = kwargs.pop("sensitivity_label_source", "current") cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -998,15 +944,14 @@ def delete( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, sensitivity_label_source=sensitivity_label_source, - template_url=self.delete.metadata["url"], 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1016,11 +961,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get( @@ -1052,12 +993,11 @@ def get( :param sensitivity_label_source: The source of the sensitivity label. Known values are: "current" and "recommended". Required. :type sensitivity_label_source: str or ~azure.mgmt.synapse.models.SensitivityLabelSource - :keyword callable cls: A custom type or function that will be passed the direct response :return: SensitivityLabel or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SensitivityLabel :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1068,10 +1008,10 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SensitivityLabel] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -1081,15 +1021,14 @@ def get( sensitivity_label_source=sensitivity_label_source, 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1098,16 +1037,12 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("SensitivityLabel", pipeline_response) + deserialized = self._deserialize("SensitivityLabel", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}" - } + return deserialized # type: ignore @distributed_trace def enable_recommendation( # pylint: disable=inconsistent-return-statements @@ -1136,15 +1071,11 @@ def enable_recommendation( # pylint: disable=inconsistent-return-statements :type table_name: str :param column_name: The name of the column. Required. :type column_name: str - :keyword sensitivity_label_source: The source of the sensitivity label. Default value is - "recommended". Note that overriding this default value may result in unsupported behavior. - :paramtype sensitivity_label_source: 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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1155,11 +1086,11 @@ def enable_recommendation( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") cls: ClsType[None] = kwargs.pop("cls", None) - request = build_enable_recommendation_request( + _request = build_enable_recommendation_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -1169,15 +1100,14 @@ def enable_recommendation( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, sensitivity_label_source=sensitivity_label_source, - template_url=self.enable_recommendation.metadata["url"], 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1187,11 +1117,7 @@ def enable_recommendation( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - enable_recommendation.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/enable" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def disable_recommendation( # pylint: disable=inconsistent-return-statements @@ -1219,15 +1145,11 @@ def disable_recommendation( # pylint: disable=inconsistent-return-statements :type table_name: str :param column_name: The name of the column. Required. :type column_name: str - :keyword sensitivity_label_source: The source of the sensitivity label. Default value is - "recommended". Note that overriding this default value may result in unsupported behavior. - :paramtype sensitivity_label_source: 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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1238,11 +1160,11 @@ def disable_recommendation( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) sensitivity_label_source: Literal["recommended"] = kwargs.pop("sensitivity_label_source", "recommended") cls: ClsType[None] = kwargs.pop("cls", None) - request = build_disable_recommendation_request( + _request = build_disable_recommendation_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -1252,15 +1174,14 @@ def disable_recommendation( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, sensitivity_label_source=sensitivity_label_source, - template_url=self.disable_recommendation.metadata["url"], 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1270,8 +1191,4 @@ def disable_recommendation( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - disable_recommendation.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/disable" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_table_columns_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_table_columns_operations.py index e02459131e7b..c562f12b0d33 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_table_columns_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_table_columns_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -19,20 +18,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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -54,7 +51,7 @@ def build_list_by_table_name_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -73,7 +70,7 @@ def build_list_by_table_name_request( "tableName": _SERIALIZER.url("table_name", table_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -134,7 +131,6 @@ def list_by_table_name( :param filter: An OData filter expression that filters elements in the collection. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SqlPoolColumn or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.SqlPoolColumn] :raises ~azure.core.exceptions.HttpResponseError: @@ -142,10 +138,10 @@ def list_by_table_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPoolColumnListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -156,7 +152,7 @@ def list_by_table_name( def prepare_request(next_link=None): if not next_link: - request = build_list_by_table_name_request( + _request = build_list_by_table_name_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -165,19 +161,16 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list_by_table_name.metadata["url"], 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("SqlPoolColumnListResult", pipeline_response) @@ -187,10 +180,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -201,7 +195,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_table_name.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_tables_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_tables_operations.py index a2806d65e348..a54cd76f7e59 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_tables_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_tables_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -19,20 +18,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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +50,7 @@ def build_list_by_schema_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -71,7 +68,7 @@ def build_list_by_schema_request( "schemaName": _SERIALIZER.url("schema_name", schema_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -96,7 +93,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -115,7 +112,7 @@ def build_get_request( "tableName": _SERIALIZER.url("table_name", table_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -171,7 +168,6 @@ def list_by_schema( :param filter: An OData filter expression that filters elements in the collection. Default value is None. :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SqlPoolTable or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.SqlPoolTable] :raises ~azure.core.exceptions.HttpResponseError: @@ -179,10 +175,10 @@ def list_by_schema( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPoolTableListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -193,7 +189,7 @@ def list_by_schema( def prepare_request(next_link=None): if not next_link: - request = build_list_by_schema_request( + _request = build_list_by_schema_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -201,19 +197,16 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, filter=filter, api_version=api_version, - template_url=self.list_by_schema.metadata["url"], 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("SqlPoolTableListResult", pipeline_response) @@ -223,10 +216,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -238,10 +232,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_schema.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables" - } - @distributed_trace def get( self, @@ -265,12 +255,11 @@ def get( :type schema_name: str :param table_name: The name of the table. Required. :type table_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SqlPoolTable or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolTable :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -281,10 +270,10 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPoolTable] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -292,15 +281,14 @@ def get( table_name=table_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -309,13 +297,9 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("SqlPoolTable", pipeline_response) + deserialized = self._deserialize("SqlPoolTable", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_transparent_data_encryptions_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_transparent_data_encryptions_operations.py index 6bebfde3bd37..11a1aa6c5670 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_transparent_data_encryptions_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_transparent_data_encryptions_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload @@ -19,20 +19,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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +49,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -71,7 +69,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -93,7 +91,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: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -114,7 +112,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -133,7 +131,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -150,7 +148,7 @@ def build_list_request( "sqlPoolName": _SERIALIZER.url("sql_pool_name", sql_pool_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -161,7 +159,7 @@ def build_list_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class SqlPoolTransparentDataEncryptionsOperations: +class SqlPoolTransparentDataEncryptionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -204,12 +202,11 @@ def get( configuration. "current" Required. :type transparent_data_encryption_name: str or ~azure.mgmt.synapse.models.TransparentDataEncryptionName - :keyword callable cls: A custom type or function that will be passed the direct response :return: TransparentDataEncryption or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.TransparentDataEncryption :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -220,25 +217,24 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.TransparentDataEncryption] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, transparent_data_encryption_name=transparent_data_encryption_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -248,16 +244,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("TransparentDataEncryption", pipeline_response) + deserialized = self._deserialize("TransparentDataEncryption", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/transparentDataEncryption/{transparentDataEncryptionName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -292,7 +284,6 @@ def 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 :return: TransparentDataEncryption or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.TransparentDataEncryption :raises ~azure.core.exceptions.HttpResponseError: @@ -305,7 +296,7 @@ def create_or_update( workspace_name: str, sql_pool_name: str, transparent_data_encryption_name: Union[str, _models.TransparentDataEncryptionName], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -327,11 +318,10 @@ def create_or_update( ~azure.mgmt.synapse.models.TransparentDataEncryptionName :param parameters: The required parameters for creating or updating transparent data encryption. 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: TransparentDataEncryption or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.TransparentDataEncryption :raises ~azure.core.exceptions.HttpResponseError: @@ -344,7 +334,7 @@ def create_or_update( workspace_name: str, sql_pool_name: str, transparent_data_encryption_name: Union[str, _models.TransparentDataEncryptionName], - parameters: Union[_models.TransparentDataEncryption, IO], + parameters: Union[_models.TransparentDataEncryption, IO[bytes]], **kwargs: Any ) -> _models.TransparentDataEncryption: """Creates or updates a Sql pool's transparent data encryption configuration. @@ -363,17 +353,13 @@ def create_or_update( :type transparent_data_encryption_name: str or ~azure.mgmt.synapse.models.TransparentDataEncryptionName :param parameters: The required parameters for creating or updating transparent data - encryption. Is either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.models.TransparentDataEncryption 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 + encryption. Is either a TransparentDataEncryption type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.TransparentDataEncryption or IO[bytes] :return: TransparentDataEncryption or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.TransparentDataEncryption :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -384,19 +370,19 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.TransparentDataEncryption] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "TransparentDataEncryption") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -406,15 +392,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -424,21 +409,13 @@ def create_or_update( 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("TransparentDataEncryption", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("TransparentDataEncryption", pipeline_response) + deserialized = self._deserialize("TransparentDataEncryption", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/transparentDataEncryption/{transparentDataEncryptionName}" - } - @distributed_trace def list( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any @@ -454,7 +431,6 @@ def list( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either TransparentDataEncryption or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.TransparentDataEncryption] @@ -463,10 +439,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.TransparentDataEncryptionListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -477,25 +453,22 @@ 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, workspace_name=workspace_name, sql_pool_name=sql_pool_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("TransparentDataEncryptionListResult", pipeline_response) @@ -505,10 +478,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -519,7 +493,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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/transparentDataEncryption" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_usages_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_usages_operations.py index b3c6480ea762..97fca0265cf8 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_usages_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_usages_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -19,20 +18,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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -46,7 +43,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -63,7 +60,7 @@ def build_list_request( "sqlPoolName": _SERIALIZER.url("sql_pool_name", sql_pool_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -108,7 +105,6 @@ def list( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SqlPoolUsage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.SqlPoolUsage] :raises ~azure.core.exceptions.HttpResponseError: @@ -116,10 +112,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPoolUsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -130,25 +126,22 @@ 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, workspace_name=workspace_name, sql_pool_name=sql_pool_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("SqlPoolUsageListResult", pipeline_response) @@ -158,10 +151,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -173,7 +167,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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/usages" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_vulnerability_assessment_rule_baselines_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_vulnerability_assessment_rule_baselines_operations.py index 256f812cb982..fcdde596dbae 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_vulnerability_assessment_rule_baselines_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_vulnerability_assessment_rule_baselines_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload @@ -18,20 +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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +50,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: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -75,7 +73,7 @@ def build_create_or_update_request( "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -100,7 +98,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # Construct URL _url = kwargs.pop( "template_url", @@ -120,7 +118,7 @@ def build_delete_request( "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -141,7 +139,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -163,7 +161,7 @@ def build_get_request( "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -174,7 +172,7 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class SqlPoolVulnerabilityAssessmentRuleBaselinesOperations: +class SqlPoolVulnerabilityAssessmentRuleBaselinesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -232,7 +230,6 @@ def 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 :return: SqlPoolVulnerabilityAssessmentRuleBaseline or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessmentRuleBaseline :raises ~azure.core.exceptions.HttpResponseError: @@ -247,7 +244,7 @@ def create_or_update( vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], rule_id: str, baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -273,11 +270,10 @@ def create_or_update( :type baseline_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentPolicyBaselineName :param parameters: The requested rule baseline resource. 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: SqlPoolVulnerabilityAssessmentRuleBaseline or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessmentRuleBaseline :raises ~azure.core.exceptions.HttpResponseError: @@ -292,7 +288,7 @@ def create_or_update( vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], rule_id: str, baseline_name: Union[str, _models.VulnerabilityAssessmentPolicyBaselineName], - parameters: Union[_models.SqlPoolVulnerabilityAssessmentRuleBaseline, IO], + parameters: Union[_models.SqlPoolVulnerabilityAssessmentRuleBaseline, IO[bytes]], **kwargs: Any ) -> _models.SqlPoolVulnerabilityAssessmentRuleBaseline: """Creates or updates a Sql pool's vulnerability assessment rule baseline. @@ -315,18 +311,15 @@ def create_or_update( "master" and "default". Required. :type baseline_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentPolicyBaselineName - :param parameters: The requested rule baseline resource. Is either a model type or a IO type. - Required. - :type parameters: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessmentRuleBaseline 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 parameters: The requested rule baseline resource. Is either a + SqlPoolVulnerabilityAssessmentRuleBaseline type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessmentRuleBaseline or + IO[bytes] :return: SqlPoolVulnerabilityAssessmentRuleBaseline or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessmentRuleBaseline :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -337,19 +330,19 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SqlPoolVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "SqlPoolVulnerabilityAssessmentRuleBaseline") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -361,15 +354,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -378,16 +370,12 @@ def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("SqlPoolVulnerabilityAssessmentRuleBaseline", pipeline_response) + deserialized = self._deserialize("SqlPoolVulnerabilityAssessmentRuleBaseline", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -420,12 +408,11 @@ def delete( # pylint: disable=inconsistent-return-statements "master" and "default". Required. :type baseline_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentPolicyBaselineName - :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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -436,10 +423,10 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -448,15 +435,14 @@ def delete( # pylint: disable=inconsistent-return-statements baseline_name=baseline_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -466,11 +452,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get( @@ -503,12 +485,11 @@ def get( and "default". Required. :type baseline_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentPolicyBaselineName - :keyword callable cls: A custom type or function that will be passed the direct response :return: SqlPoolVulnerabilityAssessmentRuleBaseline or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessmentRuleBaseline :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -519,10 +500,10 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPoolVulnerabilityAssessmentRuleBaseline] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -531,15 +512,14 @@ def get( baseline_name=baseline_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -548,13 +528,9 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("SqlPoolVulnerabilityAssessmentRuleBaseline", pipeline_response) + deserialized = self._deserialize("SqlPoolVulnerabilityAssessmentRuleBaseline", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_vulnerability_assessment_scans_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_vulnerability_assessment_scans_operations.py index 8bd49051bdf0..d5ecf95452ce 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_vulnerability_assessment_scans_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_vulnerability_assessment_scans_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast +from typing import Any, Callable, Dict, Iterable, Iterator, Optional, TypeVar, Union, cast from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,13 +14,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 @@ -29,12 +29,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +52,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -73,7 +72,7 @@ def build_list_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -95,7 +94,7 @@ def build_initiate_scan_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # Construct URL _url = kwargs.pop( "template_url", @@ -114,7 +113,7 @@ def build_initiate_scan_request( "scanId": _SERIALIZER.url("scan_id", scan_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -134,7 +133,7 @@ def build_export_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -155,7 +154,7 @@ def build_export_request( "scanId": _SERIALIZER.url("scan_id", scan_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -178,7 +177,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -199,7 +198,7 @@ def build_get_request( "scanId": _SERIALIZER.url("scan_id", scan_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -210,7 +209,7 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class SqlPoolVulnerabilityAssessmentScansOperations: +class SqlPoolVulnerabilityAssessmentScansOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -253,7 +252,6 @@ def list( Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either VulnerabilityAssessmentScanRecord or the result of cls(response) :rtype: @@ -263,10 +261,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.VulnerabilityAssessmentScanRecordListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -277,26 +275,23 @@ 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, workspace_name=workspace_name, sql_pool_name=sql_pool_name, vulnerability_assessment_name=vulnerability_assessment_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("VulnerabilityAssessmentScanRecordListResult", pipeline_response) @@ -306,10 +301,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -321,11 +317,7 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans" - } - - def _initiate_scan_initial( # pylint: disable=inconsistent-return-statements + def _initiate_scan_initial( self, resource_group_name: str, workspace_name: str, @@ -333,8 +325,8 @@ def _initiate_scan_initial( # pylint: disable=inconsistent-return-statements vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], scan_id: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -345,10 +337,10 @@ def _initiate_scan_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_initiate_scan_request( + _request = build_initiate_scan_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -356,29 +348,33 @@ def _initiate_scan_initial( # pylint: disable=inconsistent-return-statements scan_id=scan_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._initiate_scan_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _initiate_scan_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan" - } + return deserialized # type: ignore @distributed_trace def begin_initiate_scan( @@ -405,14 +401,6 @@ def begin_initiate_scan( ~azure.mgmt.synapse.models.VulnerabilityAssessmentName :param scan_id: The vulnerability assessment scan Id of the scan to retrieve. Required. :type scan_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~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: @@ -420,13 +408,13 @@ def begin_initiate_scan( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) 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._initiate_scan_initial( # type: ignore + raw_result = self._initiate_scan_initial( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -438,11 +426,12 @@ def begin_initiate_scan( 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)) @@ -451,17 +440,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_initiate_scan.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def export( @@ -488,12 +473,11 @@ def export( ~azure.mgmt.synapse.models.VulnerabilityAssessmentName :param scan_id: The vulnerability assessment scan Id of the scan to retrieve. Required. :type scan_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SqlPoolVulnerabilityAssessmentScansExport or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessmentScansExport :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -504,10 +488,10 @@ def export( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPoolVulnerabilityAssessmentScansExport] = kwargs.pop("cls", None) - request = build_export_request( + _request = build_export_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -515,15 +499,14 @@ def export( scan_id=scan_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export.metadata["url"], 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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -532,21 +515,13 @@ def export( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("SqlPoolVulnerabilityAssessmentScansExport", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SqlPoolVulnerabilityAssessmentScansExport", pipeline_response) + deserialized = self._deserialize("SqlPoolVulnerabilityAssessmentScansExport", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - export.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/export" - } - @distributed_trace def get( self, @@ -572,12 +547,11 @@ def get( ~azure.mgmt.synapse.models.VulnerabilityAssessmentName :param scan_id: The vulnerability assessment scan Id of the scan to retrieve. Required. :type scan_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: VulnerabilityAssessmentScanRecord or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.VulnerabilityAssessmentScanRecord :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -588,10 +562,10 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.VulnerabilityAssessmentScanRecord] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -599,15 +573,14 @@ def get( scan_id=scan_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -616,13 +589,9 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("VulnerabilityAssessmentScanRecord", pipeline_response) + deserialized = self._deserialize("VulnerabilityAssessmentScanRecord", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_vulnerability_assessments_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_vulnerability_assessments_operations.py index c6fa59c4102a..0944d21eb50f 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_vulnerability_assessments_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_vulnerability_assessments_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload @@ -19,20 +19,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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -46,7 +44,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -63,7 +61,7 @@ def build_list_request( "sqlPoolName": _SERIALIZER.url("sql_pool_name", sql_pool_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -85,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: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -105,7 +103,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -127,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: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -148,7 +146,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -171,7 +169,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # Construct URL _url = kwargs.pop( "template_url", @@ -189,7 +187,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -197,7 +195,7 @@ def build_delete_request( return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -class SqlPoolVulnerabilityAssessmentsOperations: +class SqlPoolVulnerabilityAssessmentsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -231,7 +229,6 @@ def list( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SqlPoolVulnerabilityAssessment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessment] @@ -240,10 +237,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPoolVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -254,25 +251,22 @@ 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, workspace_name=workspace_name, sql_pool_name=sql_pool_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("SqlPoolVulnerabilityAssessmentListResult", pipeline_response) @@ -282,10 +276,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -297,10 +292,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments" - } - @distributed_trace def get( self, @@ -325,12 +316,11 @@ def get( Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :keyword callable cls: A custom type or function that will be passed the direct response :return: SqlPoolVulnerabilityAssessment or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -341,25 +331,24 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPoolVulnerabilityAssessment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, vulnerability_assessment_name=vulnerability_assessment_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -368,16 +357,12 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("SqlPoolVulnerabilityAssessment", pipeline_response) + deserialized = self._deserialize("SqlPoolVulnerabilityAssessment", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -411,7 +396,6 @@ def 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 :return: SqlPoolVulnerabilityAssessment or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessment :raises ~azure.core.exceptions.HttpResponseError: @@ -424,7 +408,7 @@ def create_or_update( workspace_name: str, sql_pool_name: str, vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -445,11 +429,10 @@ def create_or_update( :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName :param parameters: The requested resource. 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: SqlPoolVulnerabilityAssessment or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessment :raises ~azure.core.exceptions.HttpResponseError: @@ -462,7 +445,7 @@ def create_or_update( workspace_name: str, sql_pool_name: str, vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - parameters: Union[_models.SqlPoolVulnerabilityAssessment, IO], + parameters: Union[_models.SqlPoolVulnerabilityAssessment, IO[bytes]], **kwargs: Any ) -> _models.SqlPoolVulnerabilityAssessment: """Creates or updates the Sql pool vulnerability assessment. @@ -480,17 +463,14 @@ def create_or_update( Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :param parameters: The requested resource. Is either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessment 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 parameters: The requested resource. Is either a SqlPoolVulnerabilityAssessment type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessment or IO[bytes] :return: SqlPoolVulnerabilityAssessment or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -501,19 +481,19 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SqlPoolVulnerabilityAssessment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "SqlPoolVulnerabilityAssessment") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -523,15 +503,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -540,21 +519,13 @@ def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("SqlPoolVulnerabilityAssessment", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SqlPoolVulnerabilityAssessment", pipeline_response) + deserialized = self._deserialize("SqlPoolVulnerabilityAssessment", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}" - } - @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, @@ -579,12 +550,11 @@ def delete( # pylint: disable=inconsistent-return-statements Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -595,25 +565,24 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, vulnerability_assessment_name=vulnerability_assessment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -623,8 +592,4 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_workload_classifier_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_workload_classifier_operations.py index 26d539256251..ea3c9cbc0c72 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_workload_classifier_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_workload_classifier_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,13 +15,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 @@ -29,12 +30,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -54,7 +54,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -73,7 +73,7 @@ def build_get_request( "workloadClassifierName": _SERIALIZER.url("workload_classifier_name", workload_classifier_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -96,7 +96,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: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -116,7 +116,7 @@ def build_create_or_update_request( "workloadClassifierName": _SERIALIZER.url("workload_classifier_name", workload_classifier_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -140,7 +140,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # Construct URL _url = kwargs.pop( "template_url", @@ -157,7 +157,7 @@ def build_delete_request( "workloadClassifierName": _SERIALIZER.url("workload_classifier_name", workload_classifier_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -176,7 +176,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -194,7 +194,7 @@ def build_list_request( "workloadGroupName": _SERIALIZER.url("workload_group_name", workload_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -249,12 +249,11 @@ def get( :type workload_group_name: str :param workload_classifier_name: The name of the workload classifier. Required. :type workload_classifier_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: WorkloadClassifier or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.WorkloadClassifier :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -265,10 +264,10 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.WorkloadClassifier] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -276,15 +275,14 @@ def get( workload_classifier_name=workload_classifier_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -293,16 +291,12 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("WorkloadClassifier", pipeline_response) + deserialized = self._deserialize("WorkloadClassifier", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, @@ -311,10 +305,10 @@ def _create_or_update_initial( sql_pool_name: str, workload_group_name: str, workload_classifier_name: str, - parameters: Union[_models.WorkloadClassifier, IO], + parameters: Union[_models.WorkloadClassifier, IO[bytes]], **kwargs: Any - ) -> Optional[_models.WorkloadClassifier]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -325,19 +319,19 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.WorkloadClassifier]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "WorkloadClassifier") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -348,38 +342,33 @@ 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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("WorkloadClassifier", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("WorkloadClassifier", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}" - } + return deserialized # type: ignore @overload def begin_create_or_update( @@ -414,14 +403,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 WorkloadClassifier or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.WorkloadClassifier] @@ -436,7 +417,7 @@ def begin_create_or_update( sql_pool_name: str, workload_group_name: str, workload_classifier_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -457,18 +438,10 @@ def begin_create_or_update( :param workload_classifier_name: The name of the workload classifier. Required. :type workload_classifier_name: str :param parameters: The properties of the workload classifier. 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 WorkloadClassifier or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.WorkloadClassifier] @@ -483,7 +456,7 @@ def begin_create_or_update( sql_pool_name: str, workload_group_name: str, workload_classifier_name: str, - parameters: Union[_models.WorkloadClassifier, IO], + parameters: Union[_models.WorkloadClassifier, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.WorkloadClassifier]: """Create Or Update workload classifier. @@ -501,20 +474,9 @@ def begin_create_or_update( :type workload_group_name: str :param workload_classifier_name: The name of the workload classifier. Required. :type workload_classifier_name: str - :param parameters: The properties of the workload classifier. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.synapse.models.WorkloadClassifier 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: The properties of the workload classifier. Is either a WorkloadClassifier + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.WorkloadClassifier or IO[bytes] :return: An instance of LROPoller that returns either WorkloadClassifier or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.WorkloadClassifier] @@ -523,7 +485,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WorkloadClassifier] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -544,12 +506,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("WorkloadClassifier", pipeline_response) + deserialized = self._deserialize("WorkloadClassifier", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -559,19 +522,17 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.WorkloadClassifier].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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}" - } + return LROPoller[_models.WorkloadClassifier]( + 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, workspace_name: str, @@ -579,8 +540,8 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements workload_group_name: str, workload_classifier_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -591,10 +552,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -602,29 +563,33 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements workload_classifier_name=workload_classifier_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -651,14 +616,6 @@ def begin_delete( :type workload_group_name: str :param workload_classifier_name: The name of the workload classifier. Required. :type workload_classifier_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: @@ -666,13 +623,13 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) 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._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -684,11 +641,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)) @@ -697,17 +655,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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def list( @@ -726,7 +680,6 @@ def list( :type sql_pool_name: str :param workload_group_name: The name of the workload group. Required. :type workload_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 WorkloadClassifier or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.WorkloadClassifier] :raises ~azure.core.exceptions.HttpResponseError: @@ -734,10 +687,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.WorkloadClassifierListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -748,26 +701,23 @@ 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, workspace_name=workspace_name, sql_pool_name=sql_pool_name, workload_group_name=workload_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("WorkloadClassifierListResult", pipeline_response) @@ -777,10 +727,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -791,7 +742,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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_workload_group_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_workload_group_operations.py index efa4858578bb..0cb2b83cc8f0 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_workload_group_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pool_workload_group_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,13 +15,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 @@ -29,12 +30,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +53,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -71,7 +71,7 @@ def build_get_request( "workloadGroupName": _SERIALIZER.url("workload_group_name", workload_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -93,7 +93,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: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -112,7 +112,7 @@ def build_create_or_update_request( "workloadGroupName": _SERIALIZER.url("workload_group_name", workload_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -135,7 +135,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # Construct URL _url = kwargs.pop( "template_url", @@ -151,7 +151,7 @@ def build_delete_request( "workloadGroupName": _SERIALIZER.url("workload_group_name", workload_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -165,7 +165,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -182,7 +182,7 @@ def build_list_request( "sqlPoolName": _SERIALIZER.url("sql_pool_name", sql_pool_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -229,12 +229,11 @@ def get( :type sql_pool_name: str :param workload_group_name: The name of the workload group. Required. :type workload_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: WorkloadGroup or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.WorkloadGroup :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -245,25 +244,24 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.WorkloadGroup] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, workload_group_name=workload_group_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -272,16 +270,12 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("WorkloadGroup", pipeline_response) + deserialized = self._deserialize("WorkloadGroup", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, @@ -289,10 +283,10 @@ def _create_or_update_initial( workspace_name: str, sql_pool_name: str, workload_group_name: str, - parameters: Union[_models.WorkloadGroup, IO], + parameters: Union[_models.WorkloadGroup, IO[bytes]], **kwargs: Any - ) -> Optional[_models.WorkloadGroup]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -303,19 +297,19 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.WorkloadGroup]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "WorkloadGroup") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -325,38 +319,33 @@ 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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("WorkloadGroup", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("WorkloadGroup", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}" - } + return deserialized # type: ignore @overload def begin_create_or_update( @@ -388,14 +377,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 WorkloadGroup or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.WorkloadGroup] @@ -409,7 +390,7 @@ def begin_create_or_update( workspace_name: str, sql_pool_name: str, workload_group_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -428,18 +409,10 @@ def begin_create_or_update( :param workload_group_name: The name of the workload group. Required. :type workload_group_name: str :param parameters: The requested workload group state. 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 WorkloadGroup or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.WorkloadGroup] @@ -453,7 +426,7 @@ def begin_create_or_update( workspace_name: str, sql_pool_name: str, workload_group_name: str, - parameters: Union[_models.WorkloadGroup, IO], + parameters: Union[_models.WorkloadGroup, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.WorkloadGroup]: """Create Or Update workload group. @@ -469,20 +442,9 @@ def begin_create_or_update( :type sql_pool_name: str :param workload_group_name: The name of the workload group. Required. :type workload_group_name: str - :param parameters: The requested workload group state. Is either a model type or a IO type. - Required. - :type parameters: ~azure.mgmt.synapse.models.WorkloadGroup 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: The requested workload group state. Is either a WorkloadGroup type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.WorkloadGroup or IO[bytes] :return: An instance of LROPoller that returns either WorkloadGroup or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.WorkloadGroup] @@ -491,7 +453,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WorkloadGroup] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -511,12 +473,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("WorkloadGroup", pipeline_response) + deserialized = self._deserialize("WorkloadGroup", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -526,22 +489,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.WorkloadGroup].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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}" - } + return LROPoller[_models.WorkloadGroup]( + 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, workspace_name: str, sql_pool_name: str, workload_group_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -552,39 +513,43 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, workload_group_name=workload_group_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -603,14 +568,6 @@ def begin_delete( :type sql_pool_name: str :param workload_group_name: The name of the workload group. Required. :type workload_group_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: @@ -618,13 +575,13 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) 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._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -635,11 +592,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)) @@ -648,17 +606,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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def list( @@ -675,7 +629,6 @@ def list( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WorkloadGroup or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.WorkloadGroup] :raises ~azure.core.exceptions.HttpResponseError: @@ -683,10 +636,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.WorkloadGroupListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -697,25 +650,22 @@ 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, workspace_name=workspace_name, sql_pool_name=sql_pool_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("WorkloadGroupListResult", pipeline_response) @@ -725,10 +675,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -739,7 +690,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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pools_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pools_operations.py index 0cfa9f84ce58..1d6337524d47 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pools_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_sql_pools_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,13 +16,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 @@ -29,12 +31,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -48,7 +49,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -65,7 +66,7 @@ def build_get_request( "sqlPoolName": _SERIALIZER.url("sql_pool_name", sql_pool_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -82,7 +83,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -100,7 +101,7 @@ def build_update_request( "sqlPoolName": _SERIALIZER.url("sql_pool_name", sql_pool_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -119,7 +120,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -137,7 +138,7 @@ def build_create_request( "sqlPoolName": _SERIALIZER.url("sql_pool_name", sql_pool_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -156,7 +157,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -173,7 +174,7 @@ def build_delete_request( "sqlPoolName": _SERIALIZER.url("sql_pool_name", sql_pool_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -190,7 +191,7 @@ def build_list_by_workspace_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -206,7 +207,7 @@ def build_list_by_workspace_request( "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -223,7 +224,7 @@ def build_pause_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -240,7 +241,7 @@ def build_pause_request( "sqlPoolName": _SERIALIZER.url("sql_pool_name", sql_pool_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -257,7 +258,7 @@ def build_resume_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -274,7 +275,7 @@ def build_resume_request( "sqlPoolName": _SERIALIZER.url("sql_pool_name", sql_pool_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -285,40 +286,6 @@ def build_resume_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_rename_request( - resource_group_name: str, workspace_name: str, sql_pool_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/move", - ) # 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 - ), - "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), - "sqlPoolName": _SERIALIZER.url("sql_pool_name", sql_pool_name, "str"), - } - - _url: str = _format_url_section(_url, **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") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - class SqlPoolsOperations: """ .. warning:: @@ -351,12 +318,11 @@ def get(self, resource_group_name: str, workspace_name: str, sql_pool_name: str, :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SqlPool or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -367,24 +333,23 @@ def get(self, resource_group_name: str, workspace_name: str, sql_pool_name: str, _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPool] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -394,26 +359,22 @@ def get(self, resource_group_name: str, workspace_name: str, sql_pool_name: str, error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SqlPool", pipeline_response) + deserialized = self._deserialize("SqlPool", 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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}" - } + return deserialized # type: ignore def _update_initial( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, - sql_pool_info: Union[_models.SqlPoolPatchInfo, IO], + sql_pool_info: Union[_models.SqlPoolPatchInfo, IO[bytes]], **kwargs: Any - ) -> Optional[_models.SqlPool]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -424,19 +385,19 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.SqlPool]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(sql_pool_info, (IO, bytes)): + if isinstance(sql_pool_info, (IOBase, bytes)): _content = sql_pool_info else: _json = self._serialize.body(sql_pool_info, "SqlPoolPatchInfo") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -445,36 +406,34 @@ 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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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 - if response.status_code == 200: - deserialized = self._deserialize("SqlPool", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}" - } + return deserialized # type: ignore @overload def begin_update( @@ -503,14 +462,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 SqlPool or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.SqlPool] :raises ~azure.core.exceptions.HttpResponseError: @@ -522,7 +473,7 @@ def begin_update( resource_group_name: str, workspace_name: str, sql_pool_name: str, - sql_pool_info: IO, + sql_pool_info: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -539,18 +490,10 @@ def begin_update( :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str :param sql_pool_info: The updated SQL pool properties. Required. - :type sql_pool_info: IO + :type sql_pool_info: 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 SqlPool or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.SqlPool] :raises ~azure.core.exceptions.HttpResponseError: @@ -562,7 +505,7 @@ def begin_update( resource_group_name: str, workspace_name: str, sql_pool_name: str, - sql_pool_info: Union[_models.SqlPoolPatchInfo, IO], + sql_pool_info: Union[_models.SqlPoolPatchInfo, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.SqlPool]: """Update SQL pool. @@ -576,20 +519,9 @@ def begin_update( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param sql_pool_info: The updated SQL pool properties. Is either a model type or a IO type. - Required. - :type sql_pool_info: ~azure.mgmt.synapse.models.SqlPoolPatchInfo 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 sql_pool_info: The updated SQL pool properties. Is either a SqlPoolPatchInfo type or a + IO[bytes] type. Required. + :type sql_pool_info: ~azure.mgmt.synapse.models.SqlPoolPatchInfo or IO[bytes] :return: An instance of LROPoller that returns either SqlPool or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.SqlPool] :raises ~azure.core.exceptions.HttpResponseError: @@ -597,7 +529,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SqlPool] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -616,12 +548,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("SqlPool", pipeline_response) + deserialized = self._deserialize("SqlPool", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -631,50 +564,48 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.SqlPool].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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}" - } + return LROPoller[_models.SqlPool]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _create_initial( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, - sql_pool_info: Union[_models.SqlPool, IO], + sql_pool_info: Union[_models.SqlPool, IO[bytes]], **kwargs: Any - ) -> Optional[_models.SqlPool]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, + 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, - 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), } 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: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.SqlPool]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(sql_pool_info, (IO, bytes)): + if isinstance(sql_pool_info, (IOBase, bytes)): _content = sql_pool_info else: _json = self._serialize.body(sql_pool_info, "SqlPool") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -683,36 +614,34 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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=False, **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 - if response.status_code == 200: - deserialized = self._deserialize("SqlPool", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}" - } + return deserialized # type: ignore @overload def begin_create( @@ -741,14 +670,6 @@ def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~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 SqlPool or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.SqlPool] :raises ~azure.core.exceptions.HttpResponseError: @@ -760,7 +681,7 @@ def begin_create( resource_group_name: str, workspace_name: str, sql_pool_name: str, - sql_pool_info: IO, + sql_pool_info: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -777,18 +698,10 @@ def begin_create( :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str :param sql_pool_info: The SQL pool to create. Required. - :type sql_pool_info: IO + :type sql_pool_info: 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 SqlPool or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.SqlPool] :raises ~azure.core.exceptions.HttpResponseError: @@ -800,7 +713,7 @@ def begin_create( resource_group_name: str, workspace_name: str, sql_pool_name: str, - sql_pool_info: Union[_models.SqlPool, IO], + sql_pool_info: Union[_models.SqlPool, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.SqlPool]: """Create SQL pool. @@ -814,19 +727,9 @@ def begin_create( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param sql_pool_info: The SQL pool to create. Is either a model type or a IO type. Required. - :type sql_pool_info: ~azure.mgmt.synapse.models.SqlPool 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 sql_pool_info: The SQL pool to create. Is either a SqlPool type or a IO[bytes] type. + Required. + :type sql_pool_info: ~azure.mgmt.synapse.models.SqlPool or IO[bytes] :return: An instance of LROPoller that returns either SqlPool or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.SqlPool] :raises ~azure.core.exceptions.HttpResponseError: @@ -834,7 +737,7 @@ def begin_create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SqlPool] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -853,12 +756,13 @@ def begin_create( 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("SqlPool", pipeline_response) + deserialized = self._deserialize("SqlPool", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -870,22 +774,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.SqlPool].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}" - } + return LROPoller[_models.SqlPool]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _delete_initial( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any - ) -> Optional[_models.SqlPool]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -896,48 +798,43 @@ def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - cls: ClsType[Optional[_models.SqlPool]] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("SqlPool", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("SqlPool", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -954,14 +851,6 @@ def begin_delete( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_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 SqlPool or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.SqlPool] :raises ~azure.core.exceptions.HttpResponseError: @@ -969,7 +858,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPool] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -985,12 +874,13 @@ 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): - deserialized = self._deserialize("SqlPool", pipeline_response) + deserialized = self._deserialize("SqlPool", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1002,17 +892,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.SqlPool].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.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}" - } + return LROPoller[_models.SqlPool]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list_by_workspace( @@ -1027,7 +915,6 @@ def list_by_workspace( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SqlPool or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.SqlPool] :raises ~azure.core.exceptions.HttpResponseError: @@ -1035,10 +922,10 @@ def list_by_workspace( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPoolInfoListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1049,24 +936,21 @@ def list_by_workspace( def prepare_request(next_link=None): if not next_link: - request = build_list_by_workspace_request( + _request = build_list_by_workspace_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_workspace.metadata["url"], 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("SqlPoolInfoListResult", pipeline_response) @@ -1076,10 +960,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1092,14 +977,10 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_workspace.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools" - } - def _pause_initial( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any - ) -> _models.SqlPool: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1110,48 +991,44 @@ def _pause_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - cls: ClsType[_models.SqlPool] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_pause_request( + _request = build_pause_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._pause_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) - if response.status_code == 200: - deserialized = self._deserialize("SqlPool", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("SqlPool", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _pause_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/pause" - } - @distributed_trace def begin_pause( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any @@ -1167,14 +1044,6 @@ def begin_pause( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_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 SqlPool or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.SqlPool] :raises ~azure.core.exceptions.HttpResponseError: @@ -1182,7 +1051,7 @@ def begin_pause( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPool] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -1198,12 +1067,13 @@ def begin_pause( 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("SqlPool", pipeline_response) + deserialized = self._deserialize("SqlPool", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1215,22 +1085,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.SqlPool].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_pause.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/pause" - } + return LROPoller[_models.SqlPool]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _resume_initial( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any - ) -> _models.SqlPool: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1241,48 +1109,44 @@ def _resume_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - cls: ClsType[_models.SqlPool] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_resume_request( + _request = build_resume_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._resume_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) - if response.status_code == 200: - deserialized = self._deserialize("SqlPool", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("SqlPool", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _resume_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/resume" - } - @distributed_trace def begin_resume( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any @@ -1298,14 +1162,6 @@ def begin_resume( :type workspace_name: str :param sql_pool_name: SQL pool name. Required. :type sql_pool_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 SqlPool or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.SqlPool] :raises ~azure.core.exceptions.HttpResponseError: @@ -1313,7 +1169,7 @@ def begin_resume( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.SqlPool] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -1329,12 +1185,13 @@ def begin_resume( 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("SqlPool", pipeline_response) + deserialized = self._deserialize("SqlPool", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1346,167 +1203,12 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.SqlPool].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_resume.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/resume" - } - - @overload - def rename( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - parameters: _models.ResourceMoveDefinition, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Rename a SQL pool. - - Rename a SQL pool. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param workspace_name: The name of the workspace. Required. - :type workspace_name: str - :param sql_pool_name: SQL pool name. Required. - :type sql_pool_name: str - :param parameters: The resource move definition for renaming this Sql pool. Required. - :type parameters: ~azure.mgmt.synapse.models.ResourceMoveDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - 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: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def rename( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Rename a SQL pool. - - Rename a SQL pool. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param workspace_name: The name of the workspace. Required. - :type workspace_name: str - :param sql_pool_name: SQL pool name. Required. - :type sql_pool_name: str - :param parameters: The resource move definition for renaming this Sql pool. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def rename( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - parameters: Union[_models.ResourceMoveDefinition, IO], - **kwargs: Any - ) -> None: - """Rename a SQL pool. - - Rename a SQL pool. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param workspace_name: The name of the workspace. Required. - :type workspace_name: str - :param sql_pool_name: SQL pool name. Required. - :type sql_pool_name: str - :param parameters: The resource move definition for renaming this Sql pool. Is either a model - type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.models.ResourceMoveDefinition or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "ResourceMoveDefinition") - - request = build_rename_request( - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.rename.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + return LROPoller[_models.SqlPool]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - rename.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/move" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_aad_admins_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_aad_admins_operations.py index 3b70ba2848c1..03da04e67a23 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_aad_admins_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_aad_admins_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,12 +15,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) 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 @@ -28,12 +29,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +47,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -63,7 +63,7 @@ def build_get_request( "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -80,7 +80,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: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -97,7 +97,7 @@ def build_create_or_update_request( "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -116,7 +116,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -132,7 +132,7 @@ def build_delete_request( "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -171,12 +171,11 @@ def get(self, resource_group_name: str, workspace_name: str, **kwargs: Any) -> _ :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: WorkspaceAadAdminInfo or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.WorkspaceAadAdminInfo :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -187,23 +186,22 @@ def get(self, resource_group_name: str, workspace_name: str, **kwargs: Any) -> _ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.WorkspaceAadAdminInfo] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -213,25 +211,21 @@ def get(self, resource_group_name: str, workspace_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("WorkspaceAadAdminInfo", pipeline_response) + deserialized = self._deserialize("WorkspaceAadAdminInfo", 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.Synapse/workspaces/{workspaceName}/administrators/activeDirectory" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, workspace_name: str, - aad_admin_info: Union[_models.WorkspaceAadAdminInfo, IO], + aad_admin_info: Union[_models.WorkspaceAadAdminInfo, IO[bytes]], **kwargs: Any - ) -> _models.WorkspaceAadAdminInfo: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -242,19 +236,19 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.WorkspaceAadAdminInfo] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(aad_admin_info, (IO, bytes)): + if isinstance(aad_admin_info, (IOBase, bytes)): _content = aad_admin_info else: _json = self._serialize.body(aad_admin_info, "WorkspaceAadAdminInfo") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, @@ -262,39 +256,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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) - if response.status_code == 200: - deserialized = self._deserialize("WorkspaceAadAdminInfo", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("WorkspaceAadAdminInfo", 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.Synapse/workspaces/{workspaceName}/administrators/activeDirectory" - } - @overload def begin_create_or_update( self, @@ -317,14 +307,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 WorkspaceAadAdminInfo or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.WorkspaceAadAdminInfo] @@ -336,7 +318,7 @@ def begin_create_or_update( self, resource_group_name: str, workspace_name: str, - aad_admin_info: IO, + aad_admin_info: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -349,18 +331,10 @@ def begin_create_or_update( :param workspace_name: The name of the workspace. Required. :type workspace_name: str :param aad_admin_info: Workspace active directory administrator properties. Required. - :type aad_admin_info: IO + :type aad_admin_info: 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 WorkspaceAadAdminInfo or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.WorkspaceAadAdminInfo] @@ -372,7 +346,7 @@ def begin_create_or_update( self, resource_group_name: str, workspace_name: str, - aad_admin_info: Union[_models.WorkspaceAadAdminInfo, IO], + aad_admin_info: Union[_models.WorkspaceAadAdminInfo, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.WorkspaceAadAdminInfo]: """Creates or updates a workspace active directory admin. @@ -382,20 +356,9 @@ def begin_create_or_update( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param aad_admin_info: Workspace active directory administrator properties. Is either a model - type or a IO type. Required. - :type aad_admin_info: ~azure.mgmt.synapse.models.WorkspaceAadAdminInfo 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 aad_admin_info: Workspace active directory administrator properties. Is either a + WorkspaceAadAdminInfo type or a IO[bytes] type. Required. + :type aad_admin_info: ~azure.mgmt.synapse.models.WorkspaceAadAdminInfo or IO[bytes] :return: An instance of LROPoller that returns either WorkspaceAadAdminInfo or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.WorkspaceAadAdminInfo] @@ -404,7 +367,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WorkspaceAadAdminInfo] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -422,12 +385,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("WorkspaceAadAdminInfo", pipeline_response) + deserialized = self._deserialize("WorkspaceAadAdminInfo", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -439,22 +403,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.WorkspaceAadAdminInfo].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.Synapse/workspaces/{workspaceName}/administrators/activeDirectory" - } + return LROPoller[_models.WorkspaceAadAdminInfo]( + 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, workspace_name: str, **kwargs: Any - ) -> None: - error_map = { + def _delete_initial(self, resource_group_name: str, workspace_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -465,38 +425,42 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/administrators/activeDirectory" - } + return deserialized # type: ignore @distributed_trace def begin_delete(self, resource_group_name: str, workspace_name: str, **kwargs: Any) -> LROPoller[None]: @@ -507,14 +471,6 @@ def begin_delete(self, resource_group_name: str, workspace_name: str, **kwargs: :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_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: @@ -522,13 +478,13 @@ def begin_delete(self, resource_group_name: str, workspace_name: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) 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._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, workspace_name=workspace_name, api_version=api_version, @@ -537,11 +493,12 @@ def begin_delete(self, resource_group_name: str, workspace_name: str, **kwargs: 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( @@ -552,14 +509,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.Synapse/workspaces/{workspaceName}/administrators/activeDirectory" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_managed_identity_sql_control_settings_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_managed_identity_sql_control_settings_operations.py index 85d9a6e5adae..544c7ac09133 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_managed_identity_sql_control_settings_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_managed_identity_sql_control_settings_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,12 +15,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) 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 @@ -28,12 +29,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +47,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -63,7 +63,7 @@ def build_get_request( "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -80,7 +80,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: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -97,7 +97,7 @@ def build_create_or_update_request( "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -110,7 +110,7 @@ def build_create_or_update_request( return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -class WorkspaceManagedIdentitySqlControlSettingsOperations: +class WorkspaceManagedIdentitySqlControlSettingsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -142,12 +142,11 @@ def get( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagedIdentitySqlControlSettingsModel or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ManagedIdentitySqlControlSettingsModel :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -158,23 +157,22 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.ManagedIdentitySqlControlSettingsModel] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -184,25 +182,21 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ManagedIdentitySqlControlSettingsModel", pipeline_response) + deserialized = self._deserialize("ManagedIdentitySqlControlSettingsModel", 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.Synapse/workspaces/{workspaceName}/managedIdentitySqlControlSettings/default" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, workspace_name: str, - managed_identity_sql_control_settings: Union[_models.ManagedIdentitySqlControlSettingsModel, IO], + managed_identity_sql_control_settings: Union[_models.ManagedIdentitySqlControlSettingsModel, IO[bytes]], **kwargs: Any - ) -> _models.ManagedIdentitySqlControlSettingsModel: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -213,21 +207,21 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ManagedIdentitySqlControlSettingsModel] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(managed_identity_sql_control_settings, (IO, bytes)): + if isinstance(managed_identity_sql_control_settings, (IOBase, bytes)): _content = managed_identity_sql_control_settings else: _json = self._serialize.body( managed_identity_sql_control_settings, "ManagedIdentitySqlControlSettingsModel" ) - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, @@ -235,39 +229,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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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("ManagedIdentitySqlControlSettingsModel", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ManagedIdentitySqlControlSettingsModel", 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.Synapse/workspaces/{workspaceName}/managedIdentitySqlControlSettings/default" - } - @overload def begin_create_or_update( self, @@ -293,14 +283,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 ManagedIdentitySqlControlSettingsModel or the result of cls(response) :rtype: @@ -313,7 +295,7 @@ def begin_create_or_update( self, resource_group_name: str, workspace_name: str, - managed_identity_sql_control_settings: IO, + managed_identity_sql_control_settings: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -328,18 +310,10 @@ def begin_create_or_update( :param workspace_name: The name of the workspace. Required. :type workspace_name: str :param managed_identity_sql_control_settings: Managed Identity Sql Control Settings. Required. - :type managed_identity_sql_control_settings: IO + :type managed_identity_sql_control_settings: 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 ManagedIdentitySqlControlSettingsModel or the result of cls(response) :rtype: @@ -352,7 +326,7 @@ def begin_create_or_update( self, resource_group_name: str, workspace_name: str, - managed_identity_sql_control_settings: Union[_models.ManagedIdentitySqlControlSettingsModel, IO], + managed_identity_sql_control_settings: Union[_models.ManagedIdentitySqlControlSettingsModel, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.ManagedIdentitySqlControlSettingsModel]: """Create or update Managed Identity Sql Control Settings. @@ -365,20 +339,9 @@ def begin_create_or_update( :param workspace_name: The name of the workspace. Required. :type workspace_name: str :param managed_identity_sql_control_settings: Managed Identity Sql Control Settings. Is either - a model type or a IO type. Required. + a ManagedIdentitySqlControlSettingsModel type or a IO[bytes] type. Required. :type managed_identity_sql_control_settings: - ~azure.mgmt.synapse.models.ManagedIdentitySqlControlSettingsModel 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. + ~azure.mgmt.synapse.models.ManagedIdentitySqlControlSettingsModel or IO[bytes] :return: An instance of LROPoller that returns either ManagedIdentitySqlControlSettingsModel or the result of cls(response) :rtype: @@ -388,7 +351,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ManagedIdentitySqlControlSettingsModel] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -406,12 +369,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("ManagedIdentitySqlControlSettingsModel", pipeline_response) + deserialized = self._deserialize("ManagedIdentitySqlControlSettingsModel", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -423,14 +387,12 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.ManagedIdentitySqlControlSettingsModel].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.Synapse/workspaces/{workspaceName}/managedIdentitySqlControlSettings/default" - } + return LROPoller[_models.ManagedIdentitySqlControlSettingsModel]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_managed_sql_server_blob_auditing_policies_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_managed_sql_server_blob_auditing_policies_operations.py index 82c1c2cd21fe..7ffabf09783f 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_managed_sql_server_blob_auditing_policies_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_managed_sql_server_blob_auditing_policies_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,13 +15,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 @@ -29,12 +30,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +52,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -69,7 +69,7 @@ def build_get_request( "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -90,7 +90,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: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -108,7 +108,7 @@ def build_create_or_update_request( "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -127,7 +127,7 @@ def build_list_by_workspace_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -143,7 +143,7 @@ def build_list_by_workspace_request( "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -154,7 +154,7 @@ def build_list_by_workspace_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class WorkspaceManagedSqlServerBlobAuditingPoliciesOperations: +class WorkspaceManagedSqlServerBlobAuditingPoliciesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -192,12 +192,11 @@ def get( :type workspace_name: str :param blob_auditing_policy_name: The name of the blob auditing policy. "default" Required. :type blob_auditing_policy_name: str or ~azure.mgmt.synapse.models.BlobAuditingPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: ServerBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ServerBlobAuditingPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -208,24 +207,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.ServerBlobAuditingPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, blob_auditing_policy_name=blob_auditing_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -234,26 +232,22 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ServerBlobAuditingPolicy", pipeline_response) + deserialized = self._deserialize("ServerBlobAuditingPolicy", 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.Synapse/workspaces/{workspaceName}/auditingSettings/{blobAuditingPolicyName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, workspace_name: str, blob_auditing_policy_name: Union[str, _models.BlobAuditingPolicyName], - parameters: Union[_models.ServerBlobAuditingPolicy, IO], + parameters: Union[_models.ServerBlobAuditingPolicy, IO[bytes]], **kwargs: Any - ) -> Optional[_models.ServerBlobAuditingPolicy]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -264,19 +258,19 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.ServerBlobAuditingPolicy]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ServerBlobAuditingPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, blob_auditing_policy_name=blob_auditing_policy_name, @@ -285,35 +279,33 @@ 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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("ServerBlobAuditingPolicy", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/auditingSettings/{blobAuditingPolicyName}" - } + return deserialized # type: ignore @overload def begin_create_or_update( @@ -342,14 +334,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 ServerBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.ServerBlobAuditingPolicy] @@ -362,7 +346,7 @@ def begin_create_or_update( resource_group_name: str, workspace_name: str, blob_auditing_policy_name: Union[str, _models.BlobAuditingPolicyName], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -379,18 +363,10 @@ def begin_create_or_update( :param blob_auditing_policy_name: The name of the blob auditing policy. "default" Required. :type blob_auditing_policy_name: str or ~azure.mgmt.synapse.models.BlobAuditingPolicyName :param parameters: Properties of extended blob auditing policy. 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 ServerBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.ServerBlobAuditingPolicy] @@ -403,7 +379,7 @@ def begin_create_or_update( resource_group_name: str, workspace_name: str, blob_auditing_policy_name: Union[str, _models.BlobAuditingPolicyName], - parameters: Union[_models.ServerBlobAuditingPolicy, IO], + parameters: Union[_models.ServerBlobAuditingPolicy, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.ServerBlobAuditingPolicy]: """Create or Update server's blob auditing policy. @@ -417,20 +393,9 @@ def begin_create_or_update( :type workspace_name: str :param blob_auditing_policy_name: The name of the blob auditing policy. "default" Required. :type blob_auditing_policy_name: str or ~azure.mgmt.synapse.models.BlobAuditingPolicyName - :param parameters: Properties of extended blob auditing policy. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.synapse.models.ServerBlobAuditingPolicy 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: Properties of extended blob auditing policy. Is either a + ServerBlobAuditingPolicy type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.ServerBlobAuditingPolicy or IO[bytes] :return: An instance of LROPoller that returns either ServerBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.ServerBlobAuditingPolicy] @@ -439,7 +404,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ServerBlobAuditingPolicy] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -458,12 +423,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("ServerBlobAuditingPolicy", pipeline_response) + deserialized = self._deserialize("ServerBlobAuditingPolicy", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -473,17 +439,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.ServerBlobAuditingPolicy].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.Synapse/workspaces/{workspaceName}/auditingSettings/{blobAuditingPolicyName}" - } + return LROPoller[_models.ServerBlobAuditingPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list_by_workspace( @@ -498,7 +462,6 @@ def list_by_workspace( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ServerBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.ServerBlobAuditingPolicy] @@ -507,10 +470,10 @@ def list_by_workspace( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.ServerBlobAuditingPolicyListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -521,24 +484,21 @@ def list_by_workspace( def prepare_request(next_link=None): if not next_link: - request = build_list_by_workspace_request( + _request = build_list_by_workspace_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_workspace.metadata["url"], 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ServerBlobAuditingPolicyListResult", pipeline_response) @@ -548,10 +508,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -562,7 +523,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_workspace.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/auditingSettings" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_managed_sql_server_dedicated_sql_minimal_tls_settings_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_managed_sql_server_dedicated_sql_minimal_tls_settings_operations.py index 82da0cb05352..4045f6aa2fcb 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_managed_sql_server_dedicated_sql_minimal_tls_settings_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_managed_sql_server_dedicated_sql_minimal_tls_settings_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,13 +15,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 @@ -29,12 +30,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +52,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -72,7 +72,7 @@ def build_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -95,7 +95,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -114,7 +114,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -131,7 +131,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -147,7 +147,7 @@ def build_list_request( "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -158,7 +158,7 @@ def build_list_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class WorkspaceManagedSqlServerDedicatedSQLMinimalTlsSettingsOperations: +class WorkspaceManagedSqlServerDedicatedSQLMinimalTlsSettingsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -182,10 +182,10 @@ def _update_initial( resource_group_name: str, workspace_name: str, dedicated_sq_lminimal_tls_settings_name: Union[str, _models.DedicatedSQLMinimalTlsSettingsName], - parameters: Union[_models.DedicatedSQLminimalTlsSettings, IO], + parameters: Union[_models.DedicatedSQLminimalTlsSettings, IO[bytes]], **kwargs: Any - ) -> Optional[_models.DedicatedSQLminimalTlsSettings]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -196,19 +196,19 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.DedicatedSQLminimalTlsSettings]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DedicatedSQLminimalTlsSettings") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, dedicated_sq_lminimal_tls_settings_name=dedicated_sq_lminimal_tls_settings_name, @@ -217,36 +217,34 @@ 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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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 - if response.status_code == 200: - deserialized = self._deserialize("DedicatedSQLminimalTlsSettings", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/dedicatedSQLminimalTlsSettings/{dedicatedSQLminimalTlsSettingsName}" - } + return deserialized # type: ignore @overload def begin_update( @@ -277,14 +275,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 DedicatedSQLminimalTlsSettings or the result of cls(response) :rtype: @@ -298,7 +288,7 @@ def begin_update( resource_group_name: str, workspace_name: str, dedicated_sq_lminimal_tls_settings_name: Union[str, _models.DedicatedSQLMinimalTlsSettingsName], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -317,18 +307,10 @@ def begin_update( :type dedicated_sq_lminimal_tls_settings_name: str or ~azure.mgmt.synapse.models.DedicatedSQLMinimalTlsSettingsName :param parameters: minimal tls settings. 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 DedicatedSQLminimalTlsSettings or the result of cls(response) :rtype: @@ -342,7 +324,7 @@ def begin_update( resource_group_name: str, workspace_name: str, dedicated_sq_lminimal_tls_settings_name: Union[str, _models.DedicatedSQLMinimalTlsSettingsName], - parameters: Union[_models.DedicatedSQLminimalTlsSettings, IO], + parameters: Union[_models.DedicatedSQLminimalTlsSettings, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.DedicatedSQLminimalTlsSettings]: """Update server's tls settings. @@ -358,19 +340,9 @@ def begin_update( settings. "default" Required. :type dedicated_sq_lminimal_tls_settings_name: str or ~azure.mgmt.synapse.models.DedicatedSQLMinimalTlsSettingsName - :param parameters: minimal tls settings. Is either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.models.DedicatedSQLminimalTlsSettings 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: minimal tls settings. Is either a DedicatedSQLminimalTlsSettings type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.DedicatedSQLminimalTlsSettings or IO[bytes] :return: An instance of LROPoller that returns either DedicatedSQLminimalTlsSettings or the result of cls(response) :rtype: @@ -380,7 +352,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DedicatedSQLminimalTlsSettings] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -399,12 +371,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("DedicatedSQLminimalTlsSettings", pipeline_response) + deserialized = self._deserialize("DedicatedSQLminimalTlsSettings", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -414,17 +387,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.DedicatedSQLminimalTlsSettings].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.Synapse/workspaces/{workspaceName}/dedicatedSQLminimalTlsSettings/{dedicatedSQLminimalTlsSettingsName}" - } + return LROPoller[_models.DedicatedSQLminimalTlsSettings]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def get( @@ -442,12 +413,11 @@ def get( :param dedicated_sq_lminimal_tls_settings_name: The name of the dedicated sql minimal tls settings. Required. :type dedicated_sq_lminimal_tls_settings_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DedicatedSQLminimalTlsSettings or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.DedicatedSQLminimalTlsSettings :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -458,24 +428,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.DedicatedSQLminimalTlsSettings] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, dedicated_sq_lminimal_tls_settings_name=dedicated_sq_lminimal_tls_settings_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -485,16 +454,12 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DedicatedSQLminimalTlsSettings", pipeline_response) + deserialized = self._deserialize("DedicatedSQLminimalTlsSettings", 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.Synapse/workspaces/{workspaceName}/dedicatedSQLminimalTlsSettings/{dedicatedSQLminimalTlsSettingsName}" - } + return deserialized # type: ignore @distributed_trace def list( @@ -509,7 +474,6 @@ def list( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DedicatedSQLminimalTlsSettings or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.DedicatedSQLminimalTlsSettings] @@ -518,10 +482,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.DedicatedSQLminimalTlsSettingsListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -532,24 +496,21 @@ 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, workspace_name=workspace_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DedicatedSQLminimalTlsSettingsListResult", pipeline_response) @@ -559,10 +520,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -574,7 +536,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.Synapse/workspaces/{workspaceName}/dedicatedSQLminimalTlsSettings" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_managed_sql_server_encryption_protector_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_managed_sql_server_encryption_protector_operations.py index be8c67df2e8b..f2e110f728bf 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_managed_sql_server_encryption_protector_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_managed_sql_server_encryption_protector_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,13 +15,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 @@ -29,12 +30,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +52,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -69,7 +69,7 @@ def build_get_request( "encryptionProtectorName": _SERIALIZER.url("encryption_protector_name", encryption_protector_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -90,7 +90,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: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -108,7 +108,7 @@ def build_create_or_update_request( "encryptionProtectorName": _SERIALIZER.url("encryption_protector_name", encryption_protector_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -127,7 +127,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -143,7 +143,7 @@ def build_list_request( "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -163,7 +163,7 @@ def build_revalidate_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # Construct URL _url = kwargs.pop( "template_url", @@ -178,7 +178,7 @@ def build_revalidate_request( "encryptionProtectorName": _SERIALIZER.url("encryption_protector_name", encryption_protector_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -186,7 +186,7 @@ def build_revalidate_request( return HttpRequest(method="POST", url=_url, params=_params, **kwargs) -class WorkspaceManagedSqlServerEncryptionProtectorOperations: +class WorkspaceManagedSqlServerEncryptionProtectorOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -224,12 +224,11 @@ def get( :type workspace_name: str :param encryption_protector_name: The name of the encryption protector. "current" Required. :type encryption_protector_name: str or ~azure.mgmt.synapse.models.EncryptionProtectorName - :keyword callable cls: A custom type or function that will be passed the direct response :return: EncryptionProtector or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.EncryptionProtector :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -240,24 +239,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.EncryptionProtector] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, encryption_protector_name=encryption_protector_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -267,26 +265,22 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("EncryptionProtector", pipeline_response) + deserialized = self._deserialize("EncryptionProtector", 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.Synapse/workspaces/{workspaceName}/encryptionProtector/{encryptionProtectorName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, workspace_name: str, encryption_protector_name: Union[str, _models.EncryptionProtectorName], - parameters: Union[_models.EncryptionProtector, IO], + parameters: Union[_models.EncryptionProtector, IO[bytes]], **kwargs: Any - ) -> Optional[_models.EncryptionProtector]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -297,19 +291,19 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.EncryptionProtector]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "EncryptionProtector") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, encryption_protector_name=encryption_protector_name, @@ -318,36 +312,34 @@ 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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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 - if response.status_code == 200: - deserialized = self._deserialize("EncryptionProtector", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector/{encryptionProtectorName}" - } + return deserialized # type: ignore @overload def begin_create_or_update( @@ -376,14 +368,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 EncryptionProtector or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.EncryptionProtector] @@ -396,7 +380,7 @@ def begin_create_or_update( resource_group_name: str, workspace_name: str, encryption_protector_name: Union[str, _models.EncryptionProtectorName], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -413,18 +397,10 @@ def begin_create_or_update( :param encryption_protector_name: The name of the encryption protector. "current" Required. :type encryption_protector_name: str or ~azure.mgmt.synapse.models.EncryptionProtectorName :param parameters: The requested encryption protector resource state. 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 EncryptionProtector or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.EncryptionProtector] @@ -437,7 +413,7 @@ def begin_create_or_update( resource_group_name: str, workspace_name: str, encryption_protector_name: Union[str, _models.EncryptionProtectorName], - parameters: Union[_models.EncryptionProtector, IO], + parameters: Union[_models.EncryptionProtector, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.EncryptionProtector]: """Updates workspace server's encryption protector. @@ -451,20 +427,9 @@ def begin_create_or_update( :type workspace_name: str :param encryption_protector_name: The name of the encryption protector. "current" Required. :type encryption_protector_name: str or ~azure.mgmt.synapse.models.EncryptionProtectorName - :param parameters: The requested encryption protector resource state. Is either a model type or - a IO type. Required. - :type parameters: ~azure.mgmt.synapse.models.EncryptionProtector 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: The requested encryption protector resource state. Is either a + EncryptionProtector type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.EncryptionProtector or IO[bytes] :return: An instance of LROPoller that returns either EncryptionProtector or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.EncryptionProtector] @@ -473,7 +438,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.EncryptionProtector] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -492,12 +457,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("EncryptionProtector", pipeline_response) + deserialized = self._deserialize("EncryptionProtector", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -507,17 +473,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.EncryptionProtector].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.Synapse/workspaces/{workspaceName}/encryptionProtector/{encryptionProtectorName}" - } + return LROPoller[_models.EncryptionProtector]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list( @@ -532,7 +496,6 @@ def list( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EncryptionProtector or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.EncryptionProtector] :raises ~azure.core.exceptions.HttpResponseError: @@ -540,10 +503,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.EncryptionProtectorListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -554,24 +517,21 @@ 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, workspace_name=workspace_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("EncryptionProtectorListResult", pipeline_response) @@ -581,10 +541,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -596,18 +557,14 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector" - } - - def _revalidate_initial( # pylint: disable=inconsistent-return-statements + def _revalidate_initial( self, resource_group_name: str, workspace_name: str, encryption_protector_name: Union[str, _models.EncryptionProtectorName], **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -618,38 +575,42 @@ def _revalidate_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_revalidate_request( + _request = build_revalidate_request( resource_group_name=resource_group_name, workspace_name=workspace_name, encryption_protector_name=encryption_protector_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._revalidate_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _revalidate_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector/{encryptionProtectorName}/revalidate" - } + return deserialized # type: ignore @distributed_trace def begin_revalidate( @@ -670,14 +631,6 @@ def begin_revalidate( :type workspace_name: str :param encryption_protector_name: The name of the encryption protector. "current" Required. :type encryption_protector_name: str or ~azure.mgmt.synapse.models.EncryptionProtectorName - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~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: @@ -685,13 +638,13 @@ def begin_revalidate( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) 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._revalidate_initial( # type: ignore + raw_result = self._revalidate_initial( resource_group_name=resource_group_name, workspace_name=workspace_name, encryption_protector_name=encryption_protector_name, @@ -701,11 +654,12 @@ def begin_revalidate( 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)) @@ -714,14 +668,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_revalidate.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector/{encryptionProtectorName}/revalidate" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_managed_sql_server_extended_blob_auditing_policies_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_managed_sql_server_extended_blob_auditing_policies_operations.py index f7c361f29210..0eae50471756 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_managed_sql_server_extended_blob_auditing_policies_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_managed_sql_server_extended_blob_auditing_policies_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,13 +15,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 @@ -29,12 +30,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +52,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -69,7 +69,7 @@ def build_get_request( "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -90,7 +90,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: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -108,7 +108,7 @@ def build_create_or_update_request( "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -127,7 +127,7 @@ def build_list_by_workspace_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -143,7 +143,7 @@ def build_list_by_workspace_request( "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -154,7 +154,7 @@ def build_list_by_workspace_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class WorkspaceManagedSqlServerExtendedBlobAuditingPoliciesOperations: +class WorkspaceManagedSqlServerExtendedBlobAuditingPoliciesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -192,12 +192,11 @@ def get( :type workspace_name: str :param blob_auditing_policy_name: The name of the blob auditing policy. "default" Required. :type blob_auditing_policy_name: str or ~azure.mgmt.synapse.models.BlobAuditingPolicyName - :keyword callable cls: A custom type or function that will be passed the direct response :return: ExtendedServerBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ExtendedServerBlobAuditingPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -208,24 +207,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.ExtendedServerBlobAuditingPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, blob_auditing_policy_name=blob_auditing_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -234,26 +232,22 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ExtendedServerBlobAuditingPolicy", pipeline_response) + deserialized = self._deserialize("ExtendedServerBlobAuditingPolicy", 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.Synapse/workspaces/{workspaceName}/extendedAuditingSettings/{blobAuditingPolicyName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, workspace_name: str, blob_auditing_policy_name: Union[str, _models.BlobAuditingPolicyName], - parameters: Union[_models.ExtendedServerBlobAuditingPolicy, IO], + parameters: Union[_models.ExtendedServerBlobAuditingPolicy, IO[bytes]], **kwargs: Any - ) -> Optional[_models.ExtendedServerBlobAuditingPolicy]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -264,19 +258,19 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.ExtendedServerBlobAuditingPolicy]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ExtendedServerBlobAuditingPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, blob_auditing_policy_name=blob_auditing_policy_name, @@ -285,35 +279,33 @@ 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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("ExtendedServerBlobAuditingPolicy", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/extendedAuditingSettings/{blobAuditingPolicyName}" - } + return deserialized # type: ignore @overload def begin_create_or_update( @@ -342,14 +334,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 ExtendedServerBlobAuditingPolicy or the result of cls(response) :rtype: @@ -363,7 +347,7 @@ def begin_create_or_update( resource_group_name: str, workspace_name: str, blob_auditing_policy_name: Union[str, _models.BlobAuditingPolicyName], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -380,18 +364,10 @@ def begin_create_or_update( :param blob_auditing_policy_name: The name of the blob auditing policy. "default" Required. :type blob_auditing_policy_name: str or ~azure.mgmt.synapse.models.BlobAuditingPolicyName :param parameters: Properties of extended blob auditing policy. 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 ExtendedServerBlobAuditingPolicy or the result of cls(response) :rtype: @@ -405,7 +381,7 @@ def begin_create_or_update( resource_group_name: str, workspace_name: str, blob_auditing_policy_name: Union[str, _models.BlobAuditingPolicyName], - parameters: Union[_models.ExtendedServerBlobAuditingPolicy, IO], + parameters: Union[_models.ExtendedServerBlobAuditingPolicy, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.ExtendedServerBlobAuditingPolicy]: """Create or Update server's extended blob auditing policy. @@ -419,20 +395,9 @@ def begin_create_or_update( :type workspace_name: str :param blob_auditing_policy_name: The name of the blob auditing policy. "default" Required. :type blob_auditing_policy_name: str or ~azure.mgmt.synapse.models.BlobAuditingPolicyName - :param parameters: Properties of extended blob auditing policy. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.synapse.models.ExtendedServerBlobAuditingPolicy 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: Properties of extended blob auditing policy. Is either a + ExtendedServerBlobAuditingPolicy type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.ExtendedServerBlobAuditingPolicy or IO[bytes] :return: An instance of LROPoller that returns either ExtendedServerBlobAuditingPolicy or the result of cls(response) :rtype: @@ -442,7 +407,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ExtendedServerBlobAuditingPolicy] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -461,12 +426,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("ExtendedServerBlobAuditingPolicy", pipeline_response) + deserialized = self._deserialize("ExtendedServerBlobAuditingPolicy", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -476,17 +442,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.ExtendedServerBlobAuditingPolicy].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.Synapse/workspaces/{workspaceName}/extendedAuditingSettings/{blobAuditingPolicyName}" - } + return LROPoller[_models.ExtendedServerBlobAuditingPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list_by_workspace( @@ -501,7 +465,6 @@ def list_by_workspace( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ExtendedServerBlobAuditingPolicy or the result of cls(response) :rtype: @@ -511,10 +474,10 @@ def list_by_workspace( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.ExtendedServerBlobAuditingPolicyListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -525,24 +488,21 @@ def list_by_workspace( def prepare_request(next_link=None): if not next_link: - request = build_list_by_workspace_request( + _request = build_list_by_workspace_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_workspace.metadata["url"], 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ExtendedServerBlobAuditingPolicyListResult", pipeline_response) @@ -552,10 +512,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -566,7 +527,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_workspace.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/extendedAuditingSettings" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_managed_sql_server_recoverable_sql_pools_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_managed_sql_server_recoverable_sql_pools_operations.py index f81495a58df7..5e8629a8ff66 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_managed_sql_server_recoverable_sql_pools_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_managed_sql_server_recoverable_sql_pools_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -19,20 +18,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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -46,7 +43,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -62,7 +59,7 @@ def build_list_request( "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -79,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: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -96,7 +93,7 @@ def build_get_request( "sqlPoolName": _SERIALIZER.url("sql_pool_name", sql_pool_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -107,7 +104,7 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class WorkspaceManagedSqlServerRecoverableSqlPoolsOperations: +class WorkspaceManagedSqlServerRecoverableSqlPoolsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -139,7 +136,6 @@ def list( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RecoverableSqlPool or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.RecoverableSqlPool] :raises ~azure.core.exceptions.HttpResponseError: @@ -147,10 +143,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.RecoverableSqlPoolListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -161,24 +157,21 @@ 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, workspace_name=workspace_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RecoverableSqlPoolListResult", pipeline_response) @@ -188,10 +181,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -203,10 +197,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/recoverableSqlPools" - } - @distributed_trace def get( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any @@ -222,12 +212,11 @@ def get( :type workspace_name: str :param sql_pool_name: The name of the sql pool. Required. :type sql_pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RecoverableSqlPool or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.RecoverableSqlPool :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -238,24 +227,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.RecoverableSqlPool] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -264,13 +252,9 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("RecoverableSqlPool", pipeline_response) + deserialized = self._deserialize("RecoverableSqlPool", 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.Synapse/workspaces/{workspaceName}/recoverableSqlPools/{sqlPoolName}" - } + return deserialized # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_managed_sql_server_security_alert_policy_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_managed_sql_server_security_alert_policy_operations.py index 308a562b1415..d11b1fb78913 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_managed_sql_server_security_alert_policy_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_managed_sql_server_security_alert_policy_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,13 +15,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 @@ -29,12 +30,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +52,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -69,7 +69,7 @@ def build_get_request( "securityAlertPolicyName": _SERIALIZER.url("security_alert_policy_name", security_alert_policy_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -90,7 +90,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: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -108,7 +108,7 @@ def build_create_or_update_request( "securityAlertPolicyName": _SERIALIZER.url("security_alert_policy_name", security_alert_policy_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -127,7 +127,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -143,7 +143,7 @@ def build_list_request( "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -154,7 +154,7 @@ def build_list_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class WorkspaceManagedSqlServerSecurityAlertPolicyOperations: +class WorkspaceManagedSqlServerSecurityAlertPolicyOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -193,12 +193,11 @@ def get( :param security_alert_policy_name: The name of the security alert policy. "Default" Required. :type security_alert_policy_name: str or ~azure.mgmt.synapse.models.SecurityAlertPolicyNameAutoGenerated - :keyword callable cls: A custom type or function that will be passed the direct response :return: ServerSecurityAlertPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ServerSecurityAlertPolicy :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -209,24 +208,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.ServerSecurityAlertPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, security_alert_policy_name=security_alert_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -235,26 +233,22 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ServerSecurityAlertPolicy", pipeline_response) + deserialized = self._deserialize("ServerSecurityAlertPolicy", 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.Synapse/workspaces/{workspaceName}/securityAlertPolicies/{securityAlertPolicyName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, workspace_name: str, security_alert_policy_name: Union[str, _models.SecurityAlertPolicyNameAutoGenerated], - parameters: Union[_models.ServerSecurityAlertPolicy, IO], + parameters: Union[_models.ServerSecurityAlertPolicy, IO[bytes]], **kwargs: Any - ) -> Optional[_models.ServerSecurityAlertPolicy]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -265,19 +259,19 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.ServerSecurityAlertPolicy]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ServerSecurityAlertPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, security_alert_policy_name=security_alert_policy_name, @@ -286,35 +280,33 @@ 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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("ServerSecurityAlertPolicy", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/securityAlertPolicies/{securityAlertPolicyName}" - } + return deserialized # type: ignore @overload def begin_create_or_update( @@ -344,14 +336,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 ServerSecurityAlertPolicy or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.ServerSecurityAlertPolicy] @@ -364,7 +348,7 @@ def begin_create_or_update( resource_group_name: str, workspace_name: str, security_alert_policy_name: Union[str, _models.SecurityAlertPolicyNameAutoGenerated], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -382,18 +366,10 @@ def begin_create_or_update( :type security_alert_policy_name: str or ~azure.mgmt.synapse.models.SecurityAlertPolicyNameAutoGenerated :param parameters: The workspace managed sql server security alert policy. 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 ServerSecurityAlertPolicy or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.ServerSecurityAlertPolicy] @@ -406,7 +382,7 @@ def begin_create_or_update( resource_group_name: str, workspace_name: str, security_alert_policy_name: Union[str, _models.SecurityAlertPolicyNameAutoGenerated], - parameters: Union[_models.ServerSecurityAlertPolicy, IO], + parameters: Union[_models.ServerSecurityAlertPolicy, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.ServerSecurityAlertPolicy]: """Create or Update server's threat detection policy. @@ -421,20 +397,9 @@ def begin_create_or_update( :param security_alert_policy_name: The name of the security alert policy. "Default" Required. :type security_alert_policy_name: str or ~azure.mgmt.synapse.models.SecurityAlertPolicyNameAutoGenerated - :param parameters: The workspace managed sql server security alert policy. Is either a model - type or a IO type. Required. - :type parameters: ~azure.mgmt.synapse.models.ServerSecurityAlertPolicy 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: The workspace managed sql server security alert policy. Is either a + ServerSecurityAlertPolicy type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.ServerSecurityAlertPolicy or IO[bytes] :return: An instance of LROPoller that returns either ServerSecurityAlertPolicy or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.ServerSecurityAlertPolicy] @@ -443,7 +408,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ServerSecurityAlertPolicy] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -462,12 +427,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("ServerSecurityAlertPolicy", pipeline_response) + deserialized = self._deserialize("ServerSecurityAlertPolicy", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -477,17 +443,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.ServerSecurityAlertPolicy].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.Synapse/workspaces/{workspaceName}/securityAlertPolicies/{securityAlertPolicyName}" - } + return LROPoller[_models.ServerSecurityAlertPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list( @@ -502,7 +466,6 @@ def list( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ServerSecurityAlertPolicy or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.ServerSecurityAlertPolicy] @@ -511,10 +474,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.ServerSecurityAlertPolicyListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -525,24 +488,21 @@ 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, workspace_name=workspace_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ServerSecurityAlertPolicyListResult", pipeline_response) @@ -552,10 +512,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -566,7 +527,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.Synapse/workspaces/{workspaceName}/securityAlertPolicies" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_managed_sql_server_usages_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_managed_sql_server_usages_operations.py index d58aeffda6ba..6936339d6ce9 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_managed_sql_server_usages_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_managed_sql_server_usages_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -19,20 +18,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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -46,7 +43,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -62,7 +59,7 @@ def build_list_request( "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -73,7 +70,7 @@ def build_list_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class WorkspaceManagedSqlServerUsagesOperations: +class WorkspaceManagedSqlServerUsagesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -103,7 +100,6 @@ def list(self, resource_group_name: str, workspace_name: str, **kwargs: Any) -> :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ServerUsage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.ServerUsage] :raises ~azure.core.exceptions.HttpResponseError: @@ -111,10 +107,10 @@ def list(self, resource_group_name: str, workspace_name: str, **kwargs: Any) -> _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.ServerUsageListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -125,24 +121,21 @@ def list(self, resource_group_name: str, workspace_name: str, **kwargs: Any) -> def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, workspace_name=workspace_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ServerUsageListResult", pipeline_response) @@ -152,10 +145,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -166,7 +160,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.Synapse/workspaces/{workspaceName}/sqlUsages" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_managed_sql_server_vulnerability_assessments_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_managed_sql_server_vulnerability_assessments_operations.py index ab55c7d4b039..5a02713cb451 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_managed_sql_server_vulnerability_assessments_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_managed_sql_server_vulnerability_assessments_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload @@ -19,20 +19,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, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +48,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -69,7 +67,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -90,7 +88,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: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -110,7 +108,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -132,7 +130,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # Construct URL _url = kwargs.pop( "template_url", @@ -149,7 +147,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -163,7 +161,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -179,7 +177,7 @@ def build_list_request( "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -190,7 +188,7 @@ def build_list_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class WorkspaceManagedSqlServerVulnerabilityAssessmentsOperations: +class WorkspaceManagedSqlServerVulnerabilityAssessmentsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -230,12 +228,11 @@ def get( Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :keyword callable cls: A custom type or function that will be passed the direct response :return: ServerVulnerabilityAssessment or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ServerVulnerabilityAssessment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -246,24 +243,23 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.ServerVulnerabilityAssessment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_name, vulnerability_assessment_name=vulnerability_assessment_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -272,16 +268,12 @@ def get( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize("ServerVulnerabilityAssessment", pipeline_response) + deserialized = self._deserialize("ServerVulnerabilityAssessment", 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.Synapse/workspaces/{workspaceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}" - } + return deserialized # type: ignore @overload def create_or_update( @@ -312,7 +304,6 @@ def 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 :return: ServerVulnerabilityAssessment or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ServerVulnerabilityAssessment :raises ~azure.core.exceptions.HttpResponseError: @@ -324,7 +315,7 @@ def create_or_update( resource_group_name: str, workspace_name: str, vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -343,11 +334,10 @@ def create_or_update( :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName :param parameters: Properties for vulnerability assessment. 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: ServerVulnerabilityAssessment or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ServerVulnerabilityAssessment :raises ~azure.core.exceptions.HttpResponseError: @@ -359,7 +349,7 @@ def create_or_update( resource_group_name: str, workspace_name: str, vulnerability_assessment_name: Union[str, _models.VulnerabilityAssessmentName], - parameters: Union[_models.ServerVulnerabilityAssessment, IO], + parameters: Union[_models.ServerVulnerabilityAssessment, IO[bytes]], **kwargs: Any ) -> _models.ServerVulnerabilityAssessment: """Create or Update server's vulnerability assessment. @@ -375,18 +365,14 @@ def create_or_update( Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :param parameters: Properties for vulnerability assessment. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.synapse.models.ServerVulnerabilityAssessment 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 parameters: Properties for vulnerability assessment. Is either a + ServerVulnerabilityAssessment type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.synapse.models.ServerVulnerabilityAssessment or IO[bytes] :return: ServerVulnerabilityAssessment or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ServerVulnerabilityAssessment :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -397,19 +383,19 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ServerVulnerabilityAssessment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ServerVulnerabilityAssessment") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, vulnerability_assessment_name=vulnerability_assessment_name, @@ -418,15 +404,14 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -435,21 +420,13 @@ def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ServerVulnerabilityAssessment", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ServerVulnerabilityAssessment", pipeline_response) + deserialized = self._deserialize("ServerVulnerabilityAssessment", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}" - } - @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, @@ -471,12 +448,11 @@ def delete( # pylint: disable=inconsistent-return-statements Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :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 = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -487,24 +463,23 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_name, vulnerability_assessment_name=vulnerability_assessment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -514,11 +489,7 @@ def delete( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list( @@ -533,7 +504,6 @@ def list( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ServerVulnerabilityAssessment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.ServerVulnerabilityAssessment] @@ -542,10 +512,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.ServerVulnerabilityAssessmentListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -556,24 +526,21 @@ 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, workspace_name=workspace_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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("ServerVulnerabilityAssessmentListResult", pipeline_response) @@ -583,10 +550,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -597,7 +565,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.Synapse/workspaces/{workspaceName}/vulnerabilityAssessments" - } diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_sql_aad_admins_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_sql_aad_admins_operations.py index 3e569f89ab12..b661e8a70bc1 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_sql_aad_admins_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspace_sql_aad_admins_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,12 +15,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) 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 @@ -28,12 +29,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +47,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -63,7 +63,7 @@ def build_get_request( "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -80,7 +80,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: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -97,7 +97,7 @@ def build_create_or_update_request( "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -116,7 +116,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -132,7 +132,7 @@ def build_delete_request( "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -171,12 +171,11 @@ def get(self, resource_group_name: str, workspace_name: str, **kwargs: Any) -> _ :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: WorkspaceAadAdminInfo or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.WorkspaceAadAdminInfo :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -187,23 +186,22 @@ def get(self, resource_group_name: str, workspace_name: str, **kwargs: Any) -> _ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.WorkspaceAadAdminInfo] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -213,25 +211,21 @@ def get(self, resource_group_name: str, workspace_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("WorkspaceAadAdminInfo", pipeline_response) + deserialized = self._deserialize("WorkspaceAadAdminInfo", 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.Synapse/workspaces/{workspaceName}/sqlAdministrators/activeDirectory" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, workspace_name: str, - aad_admin_info: Union[_models.WorkspaceAadAdminInfo, IO], + aad_admin_info: Union[_models.WorkspaceAadAdminInfo, IO[bytes]], **kwargs: Any - ) -> _models.WorkspaceAadAdminInfo: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -242,19 +236,19 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.WorkspaceAadAdminInfo] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(aad_admin_info, (IO, bytes)): + if isinstance(aad_admin_info, (IOBase, bytes)): _content = aad_admin_info else: _json = self._serialize.body(aad_admin_info, "WorkspaceAadAdminInfo") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, @@ -262,39 +256,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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) - if response.status_code == 200: - deserialized = self._deserialize("WorkspaceAadAdminInfo", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("WorkspaceAadAdminInfo", 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.Synapse/workspaces/{workspaceName}/sqlAdministrators/activeDirectory" - } - @overload def begin_create_or_update( self, @@ -317,14 +307,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 WorkspaceAadAdminInfo or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.WorkspaceAadAdminInfo] @@ -336,7 +318,7 @@ def begin_create_or_update( self, resource_group_name: str, workspace_name: str, - aad_admin_info: IO, + aad_admin_info: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -349,18 +331,10 @@ def begin_create_or_update( :param workspace_name: The name of the workspace. Required. :type workspace_name: str :param aad_admin_info: Workspace active directory administrator properties. Required. - :type aad_admin_info: IO + :type aad_admin_info: 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 WorkspaceAadAdminInfo or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.WorkspaceAadAdminInfo] @@ -372,7 +346,7 @@ def begin_create_or_update( self, resource_group_name: str, workspace_name: str, - aad_admin_info: Union[_models.WorkspaceAadAdminInfo, IO], + aad_admin_info: Union[_models.WorkspaceAadAdminInfo, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.WorkspaceAadAdminInfo]: """Creates or updates a workspace SQL active directory admin. @@ -382,20 +356,9 @@ def begin_create_or_update( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param aad_admin_info: Workspace active directory administrator properties. Is either a model - type or a IO type. Required. - :type aad_admin_info: ~azure.mgmt.synapse.models.WorkspaceAadAdminInfo 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 aad_admin_info: Workspace active directory administrator properties. Is either a + WorkspaceAadAdminInfo type or a IO[bytes] type. Required. + :type aad_admin_info: ~azure.mgmt.synapse.models.WorkspaceAadAdminInfo or IO[bytes] :return: An instance of LROPoller that returns either WorkspaceAadAdminInfo or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.WorkspaceAadAdminInfo] @@ -404,7 +367,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WorkspaceAadAdminInfo] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -422,12 +385,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("WorkspaceAadAdminInfo", pipeline_response) + deserialized = self._deserialize("WorkspaceAadAdminInfo", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -439,22 +403,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.WorkspaceAadAdminInfo].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.Synapse/workspaces/{workspaceName}/sqlAdministrators/activeDirectory" - } + return LROPoller[_models.WorkspaceAadAdminInfo]( + 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, workspace_name: str, **kwargs: Any - ) -> None: - error_map = { + def _delete_initial(self, resource_group_name: str, workspace_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -465,38 +425,42 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlAdministrators/activeDirectory" - } + return deserialized # type: ignore @distributed_trace def begin_delete(self, resource_group_name: str, workspace_name: str, **kwargs: Any) -> LROPoller[None]: @@ -507,14 +471,6 @@ def begin_delete(self, resource_group_name: str, workspace_name: str, **kwargs: :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_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: @@ -522,13 +478,13 @@ def begin_delete(self, resource_group_name: str, workspace_name: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) 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._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, workspace_name=workspace_name, api_version=api_version, @@ -537,11 +493,12 @@ def begin_delete(self, resource_group_name: str, workspace_name: str, **kwargs: 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( @@ -552,14 +509,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.Synapse/workspaces/{workspaceName}/sqlAdministrators/activeDirectory" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspaces_operations.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspaces_operations.py index 7d3a5fb7888d..d234d48bd034 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspaces_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_workspaces_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +5,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,13 +15,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 @@ -29,12 +30,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -46,7 +46,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: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,7 +61,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,7 +78,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -94,7 +94,7 @@ def build_get_request( "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -111,7 +111,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -128,7 +128,7 @@ def build_update_request( "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -147,7 +147,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: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -164,7 +164,7 @@ def build_create_or_update_request( "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -183,7 +183,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -199,7 +199,7 @@ def build_delete_request( "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -214,7 +214,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: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -223,7 +223,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -260,7 +260,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 Workspace or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.Workspace] :raises ~azure.core.exceptions.HttpResponseError: @@ -268,10 +267,10 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.WorkspaceInfoListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -282,23 +281,20 @@ 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("WorkspaceInfoListResult", pipeline_response) @@ -308,10 +304,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -324,10 +321,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces" - } - @distributed_trace def get(self, resource_group_name: str, workspace_name: str, **kwargs: Any) -> _models.Workspace: """Gets a workspace. @@ -337,12 +330,11 @@ def get(self, resource_group_name: str, workspace_name: str, **kwargs: Any) -> _ :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Workspace or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.Workspace :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -353,23 +345,22 @@ def get(self, resource_group_name: str, workspace_name: str, **kwargs: Any) -> _ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.Workspace] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, workspace_name=workspace_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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -379,25 +370,21 @@ def get(self, resource_group_name: str, workspace_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("Workspace", pipeline_response) + deserialized = self._deserialize("Workspace", 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.Synapse/workspaces/{workspaceName}" - } + return deserialized # type: ignore def _update_initial( self, resource_group_name: str, workspace_name: str, - workspace_patch_info: Union[_models.WorkspacePatchInfo, IO], + workspace_patch_info: Union[_models.WorkspacePatchInfo, IO[bytes]], **kwargs: Any - ) -> _models.Workspace: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -408,19 +395,19 @@ def _update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Workspace] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(workspace_patch_info, (IO, bytes)): + if isinstance(workspace_patch_info, (IOBase, bytes)): _content = workspace_patch_info else: _json = self._serialize.body(workspace_patch_info, "WorkspacePatchInfo") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, @@ -428,39 +415,35 @@ 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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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("Workspace", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Workspace", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}" - } - @overload def begin_update( self, @@ -483,14 +466,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 Workspace or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.Workspace] :raises ~azure.core.exceptions.HttpResponseError: @@ -501,7 +476,7 @@ def begin_update( self, resource_group_name: str, workspace_name: str, - workspace_patch_info: IO, + workspace_patch_info: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -514,18 +489,10 @@ def begin_update( :param workspace_name: The name of the workspace. Required. :type workspace_name: str :param workspace_patch_info: Workspace patch request properties. Required. - :type workspace_patch_info: IO + :type workspace_patch_info: 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 Workspace or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.Workspace] :raises ~azure.core.exceptions.HttpResponseError: @@ -536,7 +503,7 @@ def begin_update( self, resource_group_name: str, workspace_name: str, - workspace_patch_info: Union[_models.WorkspacePatchInfo, IO], + workspace_patch_info: Union[_models.WorkspacePatchInfo, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Workspace]: """Updates a workspace. @@ -546,20 +513,9 @@ def begin_update( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param workspace_patch_info: Workspace patch request properties. Is either a model type or a IO - type. Required. - :type workspace_patch_info: ~azure.mgmt.synapse.models.WorkspacePatchInfo 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 workspace_patch_info: Workspace patch request properties. Is either a WorkspacePatchInfo + type or a IO[bytes] type. Required. + :type workspace_patch_info: ~azure.mgmt.synapse.models.WorkspacePatchInfo or IO[bytes] :return: An instance of LROPoller that returns either Workspace or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.Workspace] :raises ~azure.core.exceptions.HttpResponseError: @@ -567,7 +523,7 @@ def begin_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Workspace] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -585,12 +541,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("Workspace", pipeline_response) + deserialized = self._deserialize("Workspace", 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,22 +559,24 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Workspace].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.Synapse/workspaces/{workspaceName}" - } + return LROPoller[_models.Workspace]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _create_or_update_initial( - self, resource_group_name: str, workspace_name: str, workspace_info: Union[_models.Workspace, IO], **kwargs: Any - ) -> _models.Workspace: - error_map = { + self, + resource_group_name: str, + workspace_name: str, + workspace_info: Union[_models.Workspace, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -628,19 +587,19 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Workspace] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(workspace_info, (IO, bytes)): + if isinstance(workspace_info, (IOBase, bytes)): _content = workspace_info else: _json = self._serialize.body(workspace_info, "Workspace") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, subscription_id=self._config.subscription_id, @@ -648,39 +607,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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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("Workspace", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Workspace", 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.Synapse/workspaces/{workspaceName}" - } - @overload def begin_create_or_update( self, @@ -703,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 Workspace or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.Workspace] :raises ~azure.core.exceptions.HttpResponseError: @@ -721,7 +668,7 @@ def begin_create_or_update( self, resource_group_name: str, workspace_name: str, - workspace_info: IO, + workspace_info: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -734,18 +681,10 @@ def begin_create_or_update( :param workspace_name: The name of the workspace. Required. :type workspace_name: str :param workspace_info: Workspace create or update request properties. Required. - :type workspace_info: IO + :type workspace_info: 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 Workspace or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.Workspace] :raises ~azure.core.exceptions.HttpResponseError: @@ -753,7 +692,11 @@ def begin_create_or_update( @distributed_trace def begin_create_or_update( - self, resource_group_name: str, workspace_name: str, workspace_info: Union[_models.Workspace, IO], **kwargs: Any + self, + resource_group_name: str, + workspace_name: str, + workspace_info: Union[_models.Workspace, IO[bytes]], + **kwargs: Any ) -> LROPoller[_models.Workspace]: """Creates or updates a workspace. @@ -762,20 +705,9 @@ def begin_create_or_update( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param workspace_info: Workspace create or update request properties. Is either a model type or - a IO type. Required. - :type workspace_info: ~azure.mgmt.synapse.models.Workspace 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 workspace_info: Workspace create or update request properties. Is either a Workspace + type or a IO[bytes] type. Required. + :type workspace_info: ~azure.mgmt.synapse.models.Workspace or IO[bytes] :return: An instance of LROPoller that returns either Workspace or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.Workspace] :raises ~azure.core.exceptions.HttpResponseError: @@ -783,7 +715,7 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Workspace] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -801,12 +733,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("Workspace", pipeline_response) + deserialized = self._deserialize("Workspace", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -818,22 +751,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Workspace].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.Synapse/workspaces/{workspaceName}" - } + return LROPoller[_models.Workspace]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( - self, resource_group_name: str, workspace_name: str, **kwargs: Any - ) -> Optional[_models.Workspace]: - error_map = { + def _delete_initial(self, resource_group_name: str, workspace_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -844,47 +773,42 @@ def _delete_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) - cls: ClsType[Optional[_models.Workspace]] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_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) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **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) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize("Workspace", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("Workspace", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -897,14 +821,6 @@ def begin_delete( :type resource_group_name: str :param workspace_name: The name of the workspace. Required. :type workspace_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 Workspace or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.Workspace] :raises ~azure.core.exceptions.HttpResponseError: @@ -912,7 +828,7 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.Workspace] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -927,12 +843,13 @@ 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): - deserialized = self._deserialize("Workspace", pipeline_response) + deserialized = self._deserialize("Workspace", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -944,23 +861,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Workspace].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.Synapse/workspaces/{workspaceName}" - } + return LROPoller[_models.Workspace]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Workspace"]: """Returns a list of workspaces in a subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Workspace or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.Workspace] :raises ~azure.core.exceptions.HttpResponseError: @@ -968,10 +882,10 @@ def list(self, **kwargs: Any) -> Iterable["_models.Workspace"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.WorkspaceInfoListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -982,22 +896,19 @@ def list(self, **kwargs: Any) -> Iterable["_models.Workspace"]: 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: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("WorkspaceInfoListResult", pipeline_response) @@ -1007,10 +918,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=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1022,5 +934,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Synapse/workspaces"} diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/approve_private_endpoint_connection.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/approve_private_endpoint_connection.py index 50ac732f6555..bd8ded7c8e39 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/approve_private_endpoint_connection.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/approve_private_endpoint_connection.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/check_name_availability_workspace_already_exists.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/check_name_availability_workspace_already_exists.py index f98b5e655c33..e535d1b4ccdf 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/check_name_availability_workspace_already_exists.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/check_name_availability_workspace_already_exists.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/check_name_availability_workspace_available.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/check_name_availability_workspace_available.py index 670ebddec1cc..35bf44f8d45c 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/check_name_availability_workspace_available.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/check_name_availability_workspace_available.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_ip_firewall_rule.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_ip_firewall_rule.py index 3ed35b3b7cca..852cc8e49a3d 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_ip_firewall_rule.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_ip_firewall_rule.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_big_data_pool.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_big_data_pool.py index e5bc4f8939e8..e547a5f49027 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_big_data_pool.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_big_data_pool.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ @@ -45,7 +46,7 @@ def main(): "nodeSize": "Medium", "nodeSizeFamily": "MemoryOptimized", "sparkEventsFolder": "/events", - "sparkVersion": "2.4", + "sparkVersion": "3.3", }, "tags": {"key": "value"}, }, diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_geo_backup_policies.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_geo_backup_policies.py index 9baa6383a55d..3b5c84f8346a 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_geo_backup_policies.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_geo_backup_policies.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_key.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_key.py index 2395db4ceb07..dd1e200b0e5e 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_key.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_key.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_maintenance_windows.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_maintenance_windows.py index f88b12a9fab0..4f01340f0300 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_maintenance_windows.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_maintenance_windows.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ @@ -29,7 +30,7 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.sql_pool_maintenance_windows.create_or_update( + client.sql_pool_maintenance_windows.create_or_update( resource_group_name="samplerg", workspace_name="testworkspace", sql_pool_name="testsp", @@ -38,7 +39,6 @@ def main(): "properties": {"timeRanges": [{"dayOfWeek": "Saturday", "duration": "PT60M", "startTime": "00:00:00"}]} }, ) - print(response) # x-ms-original-file: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateMaintenanceWindows.json diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_managed_identity_sql_control_settings.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_managed_identity_sql_control_settings.py index 66ecac90d534..d7b4361a98a0 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_managed_identity_sql_control_settings.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_managed_identity_sql_control_settings.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_private_link_hub.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_private_link_hub.py index e0b30d411478..ca67a4cbbc9e 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_private_link_hub.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_private_link_hub.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_blob_auditing_with_all_parameters.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_blob_auditing_with_all_parameters.py index cfb3afd07f81..919d7fe339a0 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_blob_auditing_with_all_parameters.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_blob_auditing_with_all_parameters.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_blob_auditing_with_min_parameters.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_blob_auditing_with_min_parameters.py index 635ea58a5c71..299578699829 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_blob_auditing_with_min_parameters.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_blob_auditing_with_min_parameters.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_column_sensitivity_label_with_all_parameters.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_column_sensitivity_label_with_all_parameters.py index 17912ba98e05..332674ec57e0 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_column_sensitivity_label_with_all_parameters.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_column_sensitivity_label_with_all_parameters.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_security_alert_with_all_parameters.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_security_alert_with_all_parameters.py index 81f1327b9d6e..e379d24b5665 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_security_alert_with_all_parameters.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_security_alert_with_all_parameters.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_security_alert_with_min_parameters.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_security_alert_with_min_parameters.py index d6e62ad3e0cc..f55cf43e6566 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_security_alert_with_min_parameters.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_security_alert_with_min_parameters.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_transparent_data_encryption.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_transparent_data_encryption.py index d1102a99aa4f..3f6da7e44f04 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_transparent_data_encryption.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_transparent_data_encryption.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_vulnerability_assessment_rule_baseline.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_vulnerability_assessment_rule_baseline.py index 141e0122c2a0..b058685b8760 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_vulnerability_assessment_rule_baseline.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_vulnerability_assessment_rule_baseline.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_vulnerability_assessment_with_all_parameters.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_vulnerability_assessment_with_all_parameters.py index e8e43ad083e5..a2dff1ae1452 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_vulnerability_assessment_with_all_parameters.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_vulnerability_assessment_with_all_parameters.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_vulnerability_assessment_with_container_sas_key_and_min_parameters.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_vulnerability_assessment_with_container_sas_key_and_min_parameters.py index f0c22b69a337..60abc228706f 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_vulnerability_assessment_with_container_sas_key_and_min_parameters.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_vulnerability_assessment_with_container_sas_key_and_min_parameters.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_workload_classifier_max.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_workload_classifier_max.py index 67bb1bacd671..d05402efab8c 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_workload_classifier_max.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_workload_classifier_max.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_workload_classifier_min.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_workload_classifier_min.py index 6e44d84167fe..abaf0c20ccf0 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_workload_classifier_min.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_workload_classifier_min.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_workload_group_max.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_workload_group_max.py index 362d88ac1b68..22697b5f2bca 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_workload_group_max.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_workload_group_max.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_workload_group_min.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_workload_group_min.py index 9238163008a1..2d987f747649 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_workload_group_min.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_sql_pool_workload_group_min.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_vulnerability_assessment_with_storage_access_key_and_min_parameters.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_vulnerability_assessment_with_storage_access_key_and_min_parameters.py index cef2b0f1f3b3..512cea0ed4ed 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_vulnerability_assessment_with_storage_access_key_and_min_parameters.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_vulnerability_assessment_with_storage_access_key_and_min_parameters.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_workspace.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_workspace.py index ccceebcaac79..f091109bc2e6 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_workspace.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_workspace.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_workspace_aad_admin.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_workspace_aad_admin.py index 30a2f07fbc19..62dcb5164a95 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_workspace_aad_admin.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_or_update_workspace_aad_admin.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ @@ -29,7 +30,7 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.workspace_aad_admins.begin_create_or_update( + response = client.workspace_sql_aad_admins.begin_create_or_update( resource_group_name="resourceGroup1", workspace_name="workspace1", aad_admin_info={ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_sql_pool.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_sql_pool.py index af0c54612439..84d3c2bd38cd 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_sql_pool.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_sql_pool.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_sql_pool_metadata_sync_config.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_sql_pool_metadata_sync_config.py index 274e94a7f1c0..469ad8248ff1 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_sql_pool_metadata_sync_config.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_sql_pool_metadata_sync_config.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_sql_pool_restore_points.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_sql_pool_restore_points.py index 2b391994bfb3..30408706b348 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_sql_pool_restore_points.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_sql_pool_restore_points.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_workspace_managed_sql_server_blob_auditing_settings_with_all_parameters.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_workspace_managed_sql_server_blob_auditing_settings_with_all_parameters.py index f6ca03371d2c..0213db3b3b50 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_workspace_managed_sql_server_blob_auditing_settings_with_all_parameters.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_workspace_managed_sql_server_blob_auditing_settings_with_all_parameters.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_workspace_managed_sql_server_blob_auditing_settings_with_min_parameters.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_workspace_managed_sql_server_blob_auditing_settings_with_min_parameters.py index 1546716e8a2c..f2d59cf43244 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_workspace_managed_sql_server_blob_auditing_settings_with_min_parameters.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_workspace_managed_sql_server_blob_auditing_settings_with_min_parameters.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_workspace_managed_sql_server_exetended_blob_auditing_settings_with_min_parameters.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_workspace_managed_sql_server_exetended_blob_auditing_settings_with_min_parameters.py index 364a20e79080..d557d396466c 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_workspace_managed_sql_server_exetended_blob_auditing_settings_with_min_parameters.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_workspace_managed_sql_server_exetended_blob_auditing_settings_with_min_parameters.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_workspace_managed_sql_server_extended_blob_auditing_settings_with_all_parameters.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_workspace_managed_sql_server_extended_blob_auditing_settings_with_all_parameters.py index 670cf21dd3fe..0d827097c0dd 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/create_workspace_managed_sql_server_extended_blob_auditing_settings_with_all_parameters.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/create_workspace_managed_sql_server_extended_blob_auditing_settings_with_all_parameters.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/data_masking_policy_create_or_update_max.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/data_masking_policy_create_or_update_max.py index 35313eb72f77..058c47314340 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/data_masking_policy_create_or_update_max.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/data_masking_policy_create_or_update_max.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/data_masking_policy_create_or_update_min.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/data_masking_policy_create_or_update_min.py index f2156391d3fe..1e16d134eebf 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/data_masking_policy_create_or_update_min.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/data_masking_policy_create_or_update_min.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/data_masking_policy_get.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/data_masking_policy_get.py index 7aea14475bd3..16976102719c 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/data_masking_policy_get.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/data_masking_policy_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/data_masking_rule_create_or_update_default_max.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/data_masking_rule_create_or_update_default_max.py index 5660fd0ca3e4..856cf24595a1 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/data_masking_rule_create_or_update_default_max.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/data_masking_rule_create_or_update_default_max.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/data_masking_rule_create_or_update_default_min.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/data_masking_rule_create_or_update_default_min.py index c82b8062fb0b..6ea9cb70a2c8 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/data_masking_rule_create_or_update_default_min.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/data_masking_rule_create_or_update_default_min.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/data_masking_rule_create_or_update_number.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/data_masking_rule_create_or_update_number.py index 2c34b30e9d01..314047459f2c 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/data_masking_rule_create_or_update_number.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/data_masking_rule_create_or_update_number.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/data_masking_rule_create_or_update_text.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/data_masking_rule_create_or_update_text.py index 81481ef1dbab..32fd18d2d44e 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/data_masking_rule_create_or_update_text.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/data_masking_rule_create_or_update_text.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/data_masking_rule_get.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/data_masking_rule_get.py index 1776a55c0947..81f64249754b 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/data_masking_rule_get.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/data_masking_rule_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/data_masking_rule_list.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/data_masking_rule_list.py index cfa34929fddb..f6f85ba73952 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/data_masking_rule_list.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/data_masking_rule_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_big_data_pool.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_big_data_pool.py index 25c4e22dca7e..3ae1dda44540 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_big_data_pool.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_big_data_pool.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_ip_firewall_rule.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_ip_firewall_rule.py index 13257c651f6a..647b8e389993 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_ip_firewall_rule.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_ip_firewall_rule.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_key.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_key.py index 5216f3886960..3e283bef7a75 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_key.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_key.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_private_endpoint_connection.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_private_endpoint_connection.py index dea544d45ee2..6ba1fd59ac0a 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_private_endpoint_connection.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_private_endpoint_connection.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_private_link_hub.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_private_link_hub.py index 245e35012f30..4d8dd258fe93 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_private_link_hub.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_private_link_hub.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ @@ -29,11 +30,10 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.private_link_hubs.begin_delete( + client.private_link_hubs.begin_delete( resource_group_name="resourceGroup1", private_link_hub_name="privateLinkHub1", ).result() - print(response) # x-ms-original-file: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DeletePrivateLinkHub.json diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_sql_pool.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_sql_pool.py index 1bd034575244..3e64bd1ef03e 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_sql_pool.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_sql_pool.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_sql_pool_column_sensitivity_label.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_sql_pool_column_sensitivity_label.py index e367b3d1b04c..bf1e12604208 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_sql_pool_column_sensitivity_label.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_sql_pool_column_sensitivity_label.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ @@ -29,7 +30,7 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.sql_pool_sensitivity_labels.delete( + client.sql_pool_sensitivity_labels.delete( resource_group_name="myRG", workspace_name="myServer", sql_pool_name="myDatabase", @@ -37,7 +38,6 @@ def main(): table_name="myTable", column_name="myColumn", ) - print(response) # x-ms-original-file: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DeleteSqlPoolColumnSensitivityLabel.json diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_sql_pool_vulnerability_assessment.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_sql_pool_vulnerability_assessment.py index 1172ff316cd9..fd0d908c230b 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_sql_pool_vulnerability_assessment.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_sql_pool_vulnerability_assessment.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ @@ -29,13 +30,12 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.sql_pool_vulnerability_assessments.delete( + client.sql_pool_vulnerability_assessments.delete( resource_group_name="vulnerabilityaseessmenttest-4799", workspace_name="vulnerabilityaseessmenttest-6440", sql_pool_name="testdb", vulnerability_assessment_name="default", ) - print(response) # x-ms-original-file: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DeleteSqlPoolVulnerabilityAssessment.json diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_sql_pool_vulnerability_assessment_rule_baseline.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_sql_pool_vulnerability_assessment_rule_baseline.py index d399507a138b..b77712599c03 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_sql_pool_vulnerability_assessment_rule_baseline.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_sql_pool_vulnerability_assessment_rule_baseline.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ @@ -29,7 +30,7 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.sql_pool_vulnerability_assessment_rule_baselines.delete( + client.sql_pool_vulnerability_assessment_rule_baselines.delete( resource_group_name="vulnerabilityaseessmenttest-4799", workspace_name="vulnerabilityaseessmenttest-6440", sql_pool_name="testdb", @@ -37,7 +38,6 @@ def main(): rule_id="VA1001", baseline_name="default", ) - print(response) # x-ms-original-file: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DeleteSqlPoolVulnerabilityAssessmentRuleBaseline.json diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_sql_pool_workload_group.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_sql_pool_workload_group.py index 5010fb378cce..281a4dbc0362 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_sql_pool_workload_group.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_sql_pool_workload_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ @@ -29,13 +30,12 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.sql_pool_workload_group.begin_delete( + client.sql_pool_workload_group.begin_delete( resource_group_name="sqlcrudtest-6852", workspace_name="sqlcrudtest-2080", sql_pool_name="sqlcrudtest-9187", workload_group_name="wlm_workloadgroup", ).result() - print(response) # x-ms-original-file: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DeleteSqlPoolWorkloadGroup.json diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_sql_pool_workload_group_workload_classifer.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_sql_pool_workload_group_workload_classifer.py index b868614c8dc3..43ea8fc43b0c 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_sql_pool_workload_group_workload_classifer.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_sql_pool_workload_group_workload_classifer.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ @@ -29,14 +30,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.sql_pool_workload_classifier.begin_delete( + client.sql_pool_workload_classifier.begin_delete( resource_group_name="sqlcrudtest-6852", workspace_name="sqlcrudtest-2080", sql_pool_name="sqlcrudtest-9187", workload_group_name="wlm_workloadgroup", workload_classifier_name="wlm_workloadclassifier", ).result() - print(response) # x-ms-original-file: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DeleteSqlPoolWorkloadGroupWorkloadClassifer.json diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_workspace.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_workspace.py index 756e6acef951..968739fee24b 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_workspace.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_workspace.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_workspace_aad_admin.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_workspace_aad_admin.py index bae352834ad9..d6a07b537b42 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_workspace_aad_admin.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_workspace_aad_admin.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ @@ -29,11 +30,10 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.workspace_aad_admins.begin_delete( + client.workspace_sql_aad_admins.begin_delete( resource_group_name="resourceGroup1", workspace_name="workspace1", ).result() - print(response) # x-ms-original-file: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DeleteWorkspaceAadAdmin.json diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_workspace_managed_sql_server_vulnerability_assessment.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_workspace_managed_sql_server_vulnerability_assessment.py index 95b70d0d5f3e..ad395a0c3ac2 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_workspace_managed_sql_server_vulnerability_assessment.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/delete_workspace_managed_sql_server_vulnerability_assessment.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ @@ -29,12 +30,11 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.workspace_managed_sql_server_vulnerability_assessments.delete( + client.workspace_managed_sql_server_vulnerability_assessments.delete( resource_group_name="wsg-7398", workspace_name="testWorkspace", vulnerability_assessment_name="default", ) - print(response) # x-ms-original-file: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DeleteWorkspaceManagedSqlServerVulnerabilityAssessment.json diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/enable_interactivequery_integration_runtimes.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/enable_interactivequery_integration_runtimes.py index f26dddb8322d..be27a8585439 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/enable_interactivequery_integration_runtimes.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/enable_interactivequery_integration_runtimes.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/execute_sql_pool_vulnerability_assessment_scans.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/execute_sql_pool_vulnerability_assessment_scans.py index ccd588ee5c45..de0995a9f2d7 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/execute_sql_pool_vulnerability_assessment_scans.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/execute_sql_pool_vulnerability_assessment_scans.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ @@ -29,14 +30,13 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.sql_pool_vulnerability_assessment_scans.begin_initiate_scan( + client.sql_pool_vulnerability_assessment_scans.begin_initiate_scan( resource_group_name="vulnerabilityassessmenttest-4711", workspace_name="vulnerabilityassessmenttest-6411", sql_pool_name="testdb", vulnerability_assessment_name="default", scan_id="scan01", ).result() - print(response) # x-ms-original-file: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ExecuteSqlPoolVulnerabilityAssessmentScans.json diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/export_sql_pool_vulnerability_assessment_scan.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/export_sql_pool_vulnerability_assessment_scan.py index 0cdd5afdc206..f8c0b5b093e7 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/export_sql_pool_vulnerability_assessment_scan.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/export_sql_pool_vulnerability_assessment_scan.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/extended_sql_pool_azure_monitor_auditing_create_min.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/extended_sql_pool_azure_monitor_auditing_create_min.py index df9f21c73298..a568421892bd 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/extended_sql_pool_azure_monitor_auditing_create_min.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/extended_sql_pool_azure_monitor_auditing_create_min.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/extended_sql_pool_blob_auditing_create_max.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/extended_sql_pool_blob_auditing_create_max.py index 483818ce2904..8dcd543e4501 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/extended_sql_pool_blob_auditing_create_max.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/extended_sql_pool_blob_auditing_create_max.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/extended_sql_pool_blob_auditing_create_min.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/extended_sql_pool_blob_auditing_create_min.py index 833248fef550..e8674a6e1655 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/extended_sql_pool_blob_auditing_create_min.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/extended_sql_pool_blob_auditing_create_min.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/extended_sql_pool_blob_auditing_get.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/extended_sql_pool_blob_auditing_get.py index c0718346ae9e..4ba4703bd850 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/extended_sql_pool_blob_auditing_get.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/extended_sql_pool_blob_auditing_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_available_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_available_operations.py index c45735425ea2..bc2769acd879 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_available_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_available_operations.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_azure_ad_only_authentication.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_azure_ad_only_authentication.py index 54ac00184538..01d3070f278f 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_azure_ad_only_authentication.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_azure_ad_only_authentication.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_azure_async_operation_header.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_azure_async_operation_header.py index dd9e354189f4..9d18b566fdc1 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_azure_async_operation_header.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_azure_async_operation_header.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_big_data_pool.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_big_data_pool.py index 91c6861d4ea7..91d857706830 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_big_data_pool.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_big_data_pool.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_ip_firewall_rule.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_ip_firewall_rule.py index f08cc5b921b7..ea8730f04e87 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_ip_firewall_rule.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_ip_firewall_rule.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_key.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_key.py index a8cf919dca1a..4ac1a51db2c2 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_key.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_key.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_location_header.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_location_header.py index 9d97493f3f8e..a717c271267f 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_location_header.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_location_header.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ @@ -29,12 +30,11 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.operations.get_location_header_result( + client.operations.get_location_header_result( resource_group_name="resourceGroup1", workspace_name="workspace1", operation_id="01234567-89ab-4def-0123-456789abcdef", ) - print(response) # x-ms-original-file: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetLocationHeader.json diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_location_header_result_with_sql_pool.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_location_header_result_with_sql_pool.py index 38dbcac35df0..100b3e515173 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_location_header_result_with_sql_pool.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_location_header_result_with_sql_pool.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ @@ -29,12 +30,12 @@ def main(): subscription_id="01234567-89ab-4def-0123-456789abcdef", ) - response = client.sql_pool_operation_results.begin_get_location_header_result( + response = client.sql_pool_operation_results.get_location_header_result( resource_group_name="ExampleResourceGroup", workspace_name="ExampleWorkspace", sql_pool_name="ExampleSqlPool", operation_id="fedcba98-7654-4210-fedc-ba9876543210", - ).result() + ) print(response) diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_maintenance_window_options.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_maintenance_window_options.py index a9e83f700249..d3b90d1ef089 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_maintenance_window_options.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_maintenance_window_options.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_maintenance_windows.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_maintenance_windows.py index 5ec9b31b0ab4..5a05bab7f248 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_maintenance_windows.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_maintenance_windows.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_managed_identity_sql_control_settings.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_managed_identity_sql_control_settings.py index 67ef651f4601..6e3826099ef9 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_managed_identity_sql_control_settings.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_managed_identity_sql_control_settings.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_private_endpoint_connection.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_private_endpoint_connection.py index 0de17a137274..859ced6269fe 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_private_endpoint_connection.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_private_endpoint_connection.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_private_link_hub.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_private_link_hub.py index 59e2de2c7ead..c2467226dea3 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_private_link_hub.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_private_link_hub.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_private_link_hub_private_link_resource.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_private_link_hub_private_link_resource.py index d1b5c6d1bf7e..e764a84c8ed6 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_private_link_hub_private_link_resource.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_private_link_hub_private_link_resource.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_private_link_resource.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_private_link_resource.py index 99701b99ca22..95950de02c09 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_private_link_resource.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_private_link_resource.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool.py index 09bd93a45486..4928c8ede95c 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_blob_auditing.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_blob_auditing.py index d69e9e7c374b..829696ea0203 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_blob_auditing.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_blob_auditing.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_column_sensitivity_label_get.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_column_sensitivity_label_get.py index 06264f76f9e9..bcb6db020f54 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_column_sensitivity_label_get.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_column_sensitivity_label_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_connection_policy.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_connection_policy.py index 31ec4d4c11ff..42a493d48396 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_connection_policy.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_connection_policy.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_geo_backup_policy.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_geo_backup_policy.py index 02cbfdc45527..c493ddb40bbb 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_geo_backup_policy.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_geo_backup_policy.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_metadata_sync_config.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_metadata_sync_config.py index b7033687e925..b00a5f262875 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_metadata_sync_config.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_metadata_sync_config.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_security_alert.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_security_alert.py index afd3e32b4633..0aee20731715 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_security_alert.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_security_alert.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_transparent_data_encryption.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_transparent_data_encryption.py index 29fb0fd7c58d..864f07f0718b 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_transparent_data_encryption.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_transparent_data_encryption.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_transparent_data_encryption_list.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_transparent_data_encryption_list.py index 3109d915147b..81eb44aac832 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_transparent_data_encryption_list.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_transparent_data_encryption_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_user_activity.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_user_activity.py index 7eb0f43b3453..2a96fb601070 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_user_activity.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_user_activity.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_vulnerability_assessment.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_vulnerability_assessment.py index 544c62e82324..6685a8524409 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_vulnerability_assessment.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_vulnerability_assessment.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_workload_group.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_workload_group.py index df9c6028d386..5febf66f8ab0 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_workload_group.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_workload_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_workload_group_list.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_workload_group_list.py index 5247808ef0c7..5dc41d752eef 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_workload_group_list.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_workload_group_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_workload_group_workload_classifier.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_workload_group_workload_classifier.py index d1d5b3aca373..264249a81d1a 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_workload_group_workload_classifier.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_workload_group_workload_classifier.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_workload_group_workload_classifier_list.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_workload_group_workload_classifier_list.py index a95803d2b324..17a71ca6480f 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_workload_group_workload_classifier_list.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_sql_pool_workload_group_workload_classifier_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace.py index 90eddaa06446..dd72b1b8677d 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace_aad_admin.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace_aad_admin.py index 28eaf93a8348..65436fcce8d2 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace_aad_admin.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace_aad_admin.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ @@ -29,7 +30,7 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.workspace_aad_admins.get( + response = client.workspace_sql_aad_admins.get( resource_group_name="resourceGroup1", workspace_name="workspace1", ) diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace_managed_sql_extended_server_blob_auditing_settings.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace_managed_sql_extended_server_blob_auditing_settings.py index b39be6b76592..674eb4b3182d 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace_managed_sql_extended_server_blob_auditing_settings.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace_managed_sql_extended_server_blob_auditing_settings.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace_managed_sql_server_blob_auditing_settings.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace_managed_sql_server_blob_auditing_settings.py index b516feee2122..794e143b1f06 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace_managed_sql_server_blob_auditing_settings.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace_managed_sql_server_blob_auditing_settings.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace_managed_sql_server_dedicated_sq_lminimal_tls_settings.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace_managed_sql_server_dedicated_sq_lminimal_tls_settings.py index 814f09c092f8..7ad9369578a4 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace_managed_sql_server_dedicated_sq_lminimal_tls_settings.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace_managed_sql_server_dedicated_sq_lminimal_tls_settings.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace_managed_sql_server_encryption_protector.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace_managed_sql_server_encryption_protector.py index a9b3421c4637..792f6d904683 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace_managed_sql_server_encryption_protector.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace_managed_sql_server_encryption_protector.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace_managed_sql_server_encryption_protector_list.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace_managed_sql_server_encryption_protector_list.py index 2eb54c2ce8fe..5a141877f0f7 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace_managed_sql_server_encryption_protector_list.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace_managed_sql_server_encryption_protector_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace_managed_sql_server_recoverable_sql_pool.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace_managed_sql_server_recoverable_sql_pool.py index 4c27e5bde9c9..a79e1c233b58 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace_managed_sql_server_recoverable_sql_pool.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace_managed_sql_server_recoverable_sql_pool.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace_managed_sql_server_security_alert_policy.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace_managed_sql_server_security_alert_policy.py index ffd1e19c456b..b5cce6a0e334 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace_managed_sql_server_security_alert_policy.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace_managed_sql_server_security_alert_policy.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace_managed_sql_server_vulnerability_assessment.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace_managed_sql_server_vulnerability_assessment.py index c8ec8f57ef2c..2cdfb220961d 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace_managed_sql_server_vulnerability_assessment.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/get_workspace_managed_sql_server_vulnerability_assessment.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtime_monitoring_data_list.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtime_monitoring_data_list.py index 9771a2423719..3501f9ac5307 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtime_monitoring_data_list.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtime_monitoring_data_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtime_nodes_delete.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtime_nodes_delete.py index 94d273cbedf8..6d0fa9cae441 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtime_nodes_delete.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtime_nodes_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ @@ -29,13 +30,12 @@ def main(): subscription_id="12345678-1234-1234-1234-12345678abc", ) - response = client.integration_runtime_nodes.delete( + client.integration_runtime_nodes.delete( resource_group_name="exampleResourceGroup", workspace_name="exampleWorkspace", integration_runtime_name="exampleIntegrationRuntime", node_name="Node_1", ) - print(response) # x-ms-original-file: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/IntegrationRuntimeNodes_Delete.json diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtime_nodes_get.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtime_nodes_get.py index 92bd75540722..fb3ae17f11a4 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtime_nodes_get.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtime_nodes_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtime_nodes_get_ip_address.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtime_nodes_get_ip_address.py index bf87fa709a2b..fc34bdf1c280 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtime_nodes_get_ip_address.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtime_nodes_get_ip_address.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtime_nodes_update.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtime_nodes_update.py index 1f2fccf7edb7..13adbda6d7e0 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtime_nodes_update.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtime_nodes_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtime_object_metadata_list.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtime_object_metadata_list.py index 09b3168d61b8..ce6561febe70 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtime_object_metadata_list.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtime_object_metadata_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtime_object_metadata_refresh.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtime_object_metadata_refresh.py index 0d2ca3328ed7..e5a9ab2ad614 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtime_object_metadata_refresh.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtime_object_metadata_refresh.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_create.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_create.py index 2ecc96398885..4694e0970ef1 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_create.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_create.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_delete.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_delete.py index 3448ecf55a72..d6818fe694cd 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_delete.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ @@ -29,12 +30,11 @@ def main(): subscription_id="12345678-1234-1234-1234-12345678abc", ) - response = client.integration_runtimes.begin_delete( + client.integration_runtimes.begin_delete( resource_group_name="exampleResourceGroup", workspace_name="exampleWorkspace", integration_runtime_name="exampleIntegrationRuntime", ).result() - print(response) # x-ms-original-file: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/IntegrationRuntimes_Delete.json diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_disable_interactive_query.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_disable_interactive_query.py index 5a1502ba95e5..11def4ac525d 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_disable_interactive_query.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_disable_interactive_query.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ @@ -29,12 +30,11 @@ def main(): subscription_id="12345678-1234-1234-1234-12345678abc", ) - response = client.integration_runtimes.begin_disable_interactive_query( + client.integration_runtimes.begin_disable_interactive_query( resource_group_name="exampleResourceGroup", workspace_name="exampleWorkspace", integration_runtime_name="exampleManagedIntegrationRuntime", ).result() - print(response) # x-ms-original-file: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/IntegrationRuntimes_DisableInteractiveQuery.json diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_enable_interactive_query.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_enable_interactive_query.py index 512f0c6d61e8..2519c5425bf5 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_enable_interactive_query.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_enable_interactive_query.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ @@ -29,12 +30,11 @@ def main(): subscription_id="12345678-1234-1234-1234-12345678abc", ) - response = client.integration_runtimes.begin_enable_interactive_query( + client.integration_runtimes.begin_enable_interactive_query( resource_group_name="exampleResourceGroup", workspace_name="exampleWorkspace", integration_runtime_name="exampleManagedIntegrationRuntime", ).result() - print(response) # x-ms-original-file: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/IntegrationRuntimes_EnableInteractiveQuery.json diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_get.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_get.py index b4ea36b7be8e..9af7a1ef1307 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_get.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_get_connection_info.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_get_connection_info.py index cc21c33d8388..5d4d61114387 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_get_connection_info.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_get_connection_info.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_get_status.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_get_status.py index 3a8b101e89b9..c39a9866690d 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_get_status.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_get_status.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_list_auth_keys.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_list_auth_keys.py index cd18d5971015..e32ca21716cd 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_list_auth_keys.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_list_auth_keys.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_list_by_workspace.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_list_by_workspace.py index 5b8317df5dcd..871bcd82884f 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_list_by_workspace.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_list_by_workspace.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_list_outbound_network_dependencies_endpoints.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_list_outbound_network_dependencies_endpoints.py index 6b9ef3c114cd..3bb67afc494e 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_list_outbound_network_dependencies_endpoints.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_list_outbound_network_dependencies_endpoints.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_regenerate_auth_key.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_regenerate_auth_key.py index 96760d572fc6..c9db5d619d2f 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_regenerate_auth_key.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_regenerate_auth_key.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_start.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_start.py index 74eea37fd778..3a645db6f424 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_start.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_start.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_start_operation_status.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_start_operation_status.py index 251a803300aa..ae60891fa3aa 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_start_operation_status.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_start_operation_status.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_stop.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_stop.py index 689a43e4097b..c36ac46b8117 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_stop.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_stop.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ @@ -29,12 +30,11 @@ def main(): subscription_id="12345678-1234-1234-1234-12345678abc", ) - response = client.integration_runtimes.begin_stop( + client.integration_runtimes.begin_stop( resource_group_name="exampleResourceGroup", workspace_name="exampleWorkspace", integration_runtime_name="exampleManagedIntegrationRuntime", ).result() - print(response) # x-ms-original-file: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/IntegrationRuntimes_Stop.json diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_stop_operation_status.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_stop_operation_status.py index 940e467ccec7..03befdbe5609 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_stop_operation_status.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_stop_operation_status.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_sync_credentials.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_sync_credentials.py index 9e651056e55a..889ae70a0d79 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_sync_credentials.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_sync_credentials.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ @@ -29,12 +30,11 @@ def main(): subscription_id="12345678-1234-1234-1234-12345678abc", ) - response = client.integration_runtime_credentials.sync( + client.integration_runtime_credentials.sync( resource_group_name="exampleResourceGroup", workspace_name="exampleWorkspace", integration_runtime_name="exampleIntegrationRuntime", ) - print(response) # x-ms-original-file: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/IntegrationRuntimes_SyncCredentials.json diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_update.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_update.py index 42c07b180953..d4fbea36c092 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_update.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_upgrade.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_upgrade.py index bdce9104355a..f17c947db3d0 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_upgrade.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/integration_runtimes_upgrade.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ @@ -29,12 +30,11 @@ def main(): subscription_id="12345678-1234-1234-1234-12345678abc", ) - response = client.integration_runtimes.upgrade( + client.integration_runtimes.upgrade( resource_group_name="exampleResourceGroup", workspace_name="exampleWorkspace", integration_runtime_name="exampleIntegrationRuntime", ) - print(response) # x-ms-original-file: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/IntegrationRuntimes_Upgrade.json diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_databases_list_by_kusto_pool.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_databases_list_by_kusto_pool.py index 94b39cde61d9..7995b998e3c8 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_databases_list_by_kusto_pool.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_databases_list_by_kusto_pool.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_operations_list.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_operations_list.py index a5f5c8a488f0..17a503cb9756 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_operations_list.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_operations_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_attached_database_configuration_check_name_availability.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_attached_database_configuration_check_name_availability.py index 3ef58a0680c0..9004eb7249cd 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_attached_database_configuration_check_name_availability.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_attached_database_configuration_check_name_availability.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_attached_database_configurations_create_or_update.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_attached_database_configurations_create_or_update.py index 6a60fcf13782..75cd760d18c3 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_attached_database_configurations_create_or_update.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_attached_database_configurations_create_or_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_attached_database_configurations_delete.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_attached_database_configurations_delete.py index c7b937abb515..1fb6a556211d 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_attached_database_configurations_delete.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_attached_database_configurations_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ @@ -29,13 +30,12 @@ def main(): subscription_id="12345678-1234-1234-1234-123456789098", ) - response = client.kusto_pool_attached_database_configurations.begin_delete( + client.kusto_pool_attached_database_configurations.begin_delete( workspace_name="kustorptest", kusto_pool_name="kustoclusterrptest4", attached_database_configuration_name="attachedDatabaseConfigurations1", resource_group_name="kustorptest", ).result() - print(response) # x-ms-original-file: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolAttachedDatabaseConfigurationsDelete.json diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_attached_database_configurations_get.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_attached_database_configurations_get.py index fbc53794e076..3fba0d82b9cc 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_attached_database_configurations_get.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_attached_database_configurations_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_attached_database_configurations_list_by_kusto_pool.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_attached_database_configurations_list_by_kusto_pool.py index 2a4d954701b9..b3c83d63f4c8 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_attached_database_configurations_list_by_kusto_pool.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_attached_database_configurations_list_by_kusto_pool.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_data_connection_validation.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_data_connection_validation.py index 1e38f044415f..a611952f9d4d 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_data_connection_validation.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_data_connection_validation.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_data_connections_check_name_availability.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_data_connections_check_name_availability.py index 8fc770a23989..de12faf56a58 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_data_connections_check_name_availability.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_data_connections_check_name_availability.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_data_connections_create_or_update.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_data_connections_create_or_update.py index 2ddef8a2cf50..9998109364ff 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_data_connections_create_or_update.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_data_connections_create_or_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_data_connections_delete.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_data_connections_delete.py index 1ce275f507b4..443d74532fba 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_data_connections_delete.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_data_connections_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ @@ -29,14 +30,13 @@ def main(): subscription_id="12345678-1234-1234-1234-123456789098", ) - response = client.kusto_pool_data_connections.begin_delete( + client.kusto_pool_data_connections.begin_delete( resource_group_name="kustorptest", workspace_name="synapseWorkspaceName", kusto_pool_name="kustoclusterrptest4", database_name="KustoDatabase8", data_connection_name="kustoeventhubconnection1", ).result() - print(response) # x-ms-original-file: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolDataConnectionsDelete.json diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_data_connections_get.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_data_connections_get.py index ad82ee96dd07..b7aca6da5096 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_data_connections_get.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_data_connections_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_data_connections_list_by_database.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_data_connections_list_by_database.py index 00e6a5370b26..e3e3587594a0 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_data_connections_list_by_database.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_data_connections_list_by_database.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_data_connections_update.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_data_connections_update.py index efc8617eca1c..34446c308422 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_data_connections_update.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_data_connections_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_database_principal_assignments_check_name_availability.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_database_principal_assignments_check_name_availability.py index 0d134cd97f7e..c2fbca6d02f6 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_database_principal_assignments_check_name_availability.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_database_principal_assignments_check_name_availability.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_database_principal_assignments_create_or_update.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_database_principal_assignments_create_or_update.py index c16279bd2dce..4d052075439e 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_database_principal_assignments_create_or_update.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_database_principal_assignments_create_or_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_database_principal_assignments_delete.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_database_principal_assignments_delete.py index c56497dace7e..e0d552bf51c2 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_database_principal_assignments_delete.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_database_principal_assignments_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ @@ -29,14 +30,13 @@ def main(): subscription_id="12345678-1234-1234-1234-123456789098", ) - response = client.kusto_pool_database_principal_assignments.begin_delete( + client.kusto_pool_database_principal_assignments.begin_delete( workspace_name="synapseWorkspaceName", kusto_pool_name="kustoclusterrptest4", database_name="Kustodatabase8", principal_assignment_name="kustoprincipal1", resource_group_name="kustorptest", ).result() - print(response) # x-ms-original-file: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolDatabasePrincipalAssignmentsDelete.json diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_database_principal_assignments_get.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_database_principal_assignments_get.py index 97ec97f46546..26e8343be960 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_database_principal_assignments_get.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_database_principal_assignments_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_database_principal_assignments_list.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_database_principal_assignments_list.py index 64f4105e239f..a2c2f4c112ee 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_database_principal_assignments_list.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_database_principal_assignments_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_databases_check_name_availability.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_databases_check_name_availability.py index 9539b21d23e8..dc7da7a0d941 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_databases_check_name_availability.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_databases_check_name_availability.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_databases_create_or_update.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_databases_create_or_update.py index 04ae11b91a06..760018a35927 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_databases_create_or_update.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_databases_create_or_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_databases_delete.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_databases_delete.py index 8eaece515787..1b32deadf66c 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_databases_delete.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_databases_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ @@ -29,13 +30,12 @@ def main(): subscription_id="12345678-1234-1234-1234-123456789098", ) - response = client.kusto_pool_databases.begin_delete( + client.kusto_pool_databases.begin_delete( resource_group_name="kustorptest", workspace_name="synapseWorkspaceName", kusto_pool_name="kustoclusterrptest4", database_name="KustoDatabase8", ).result() - print(response) # x-ms-original-file: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolDatabasesDelete.json diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_databases_get.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_databases_get.py index ca1a90c3d36c..fe11496192d1 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_databases_get.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_databases_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_databases_update.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_databases_update.py index de04602d7b3b..68b48d0db3c6 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_databases_update.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_databases_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_follower_databases_detach.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_follower_databases_detach.py index 0b1e19684730..e4a0e4176160 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_follower_databases_detach.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_follower_databases_detach.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ @@ -29,7 +30,7 @@ def main(): subscription_id="12345678-1234-1234-1234-123456789098", ) - response = client.kusto_pools.begin_detach_follower_databases( + client.kusto_pools.begin_detach_follower_databases( workspace_name="kustorptest", kusto_pool_name="kustoclusterrptest4", resource_group_name="kustorptest", @@ -38,7 +39,6 @@ def main(): "clusterResourceId": "/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.Synapse/workspaces/kustorptest/kustoPools/leader4", }, ).result() - print(response) # x-ms-original-file: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolFollowerDatabasesDetach.json diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_follower_databases_list.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_follower_databases_list.py index 49bfd101cf9d..3eac833ac852 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_follower_databases_list.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_follower_databases_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_language_extensions_add.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_language_extensions_add.py index 58b89e5e8c61..78f4ccf30e9d 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_language_extensions_add.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_language_extensions_add.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ @@ -29,13 +30,12 @@ def main(): subscription_id="12345678-1234-1234-1234-123456789098", ) - response = client.kusto_pools.begin_add_language_extensions( + client.kusto_pools.begin_add_language_extensions( workspace_name="kustorptest", kusto_pool_name="kustoclusterrptest4", resource_group_name="kustorptest", language_extensions_to_add={"value": [{"languageExtensionName": "PYTHON"}, {"languageExtensionName": "R"}]}, ).result() - print(response) # x-ms-original-file: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolLanguageExtensionsAdd.json diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_language_extensions_list.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_language_extensions_list.py index 82e839c0677d..0e466f01a6be 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_language_extensions_list.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_language_extensions_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_language_extensions_remove.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_language_extensions_remove.py index ab05a1d89e88..93d68f250c5b 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_language_extensions_remove.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_language_extensions_remove.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ @@ -29,13 +30,12 @@ def main(): subscription_id="12345678-1234-1234-1234-123456789098", ) - response = client.kusto_pools.begin_remove_language_extensions( + client.kusto_pools.begin_remove_language_extensions( workspace_name="kustorptest", kusto_pool_name="kustoclusterrptest4", resource_group_name="kustorptest", language_extensions_to_remove={"value": [{"languageExtensionName": "PYTHON"}, {"languageExtensionName": "R"}]}, ).result() - print(response) # x-ms-original-file: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolLanguageExtensionsRemove.json diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_principal_assignments_check_name_availability.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_principal_assignments_check_name_availability.py index 41b40071532a..ac2debd5fbcc 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_principal_assignments_check_name_availability.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_principal_assignments_check_name_availability.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_principal_assignments_create_or_update.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_principal_assignments_create_or_update.py index 0842188513f3..8687582b460e 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_principal_assignments_create_or_update.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_principal_assignments_create_or_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_principal_assignments_delete.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_principal_assignments_delete.py index 50c547ee9f3c..d14b6dc42083 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_principal_assignments_delete.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_principal_assignments_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ @@ -29,13 +30,12 @@ def main(): subscription_id="12345678-1234-1234-1234-123456789098", ) - response = client.kusto_pool_principal_assignments.begin_delete( + client.kusto_pool_principal_assignments.begin_delete( workspace_name="synapseWorkspaceName", kusto_pool_name="kustoclusterrptest4", principal_assignment_name="kustoprincipal1", resource_group_name="kustorptest", ).result() - print(response) # x-ms-original-file: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolPrincipalAssignmentsDelete.json diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_principal_assignments_get.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_principal_assignments_get.py index af8b809ceeab..9b9bce3ed616 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_principal_assignments_get.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_principal_assignments_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_principal_assignments_list.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_principal_assignments_list.py index a00a2e195c93..2c55fe0e6108 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_principal_assignments_list.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_principal_assignments_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_private_link_resources_list.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_private_link_resources_list.py index 0ee524e9aa59..74ce397ed52a 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_private_link_resources_list.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pool_private_link_resources_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_check_name_availability.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_check_name_availability.py index 0d39e64b2da6..41a55ff4e362 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_check_name_availability.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_check_name_availability.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_create_or_update.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_create_or_update.py index fd6d7fb350cb..57a6e3e90083 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_create_or_update.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_create_or_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_delete.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_delete.py index f07b8a89cddb..80c7c4747eeb 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_delete.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ @@ -29,12 +30,11 @@ def main(): subscription_id="12345678-1234-1234-1234-123456789098", ) - response = client.kusto_pools.begin_delete( + client.kusto_pools.begin_delete( workspace_name="kustorptest", resource_group_name="kustorptest", kusto_pool_name="kustoclusterrptest4", ).result() - print(response) # x-ms-original-file: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolsDelete.json diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_get.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_get.py index f2207a5f912e..7452a83cfd6f 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_get.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_list_by_workspace.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_list_by_workspace.py index 739de25d2543..fbb88ab28255 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_list_by_workspace.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_list_by_workspace.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_list_resource_skus.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_list_resource_skus.py index 0740d66a7d94..a35e514883e0 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_list_resource_skus.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_list_resource_skus.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_list_skus.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_list_skus.py index 3ae5980326b8..324a4397cf98 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_list_skus.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_list_skus.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_start.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_start.py index d2435e192e5b..a0247b80d131 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_start.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_start.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ @@ -29,12 +30,11 @@ def main(): subscription_id="12345678-1234-1234-1234-123456789098", ) - response = client.kusto_pools.begin_start( + client.kusto_pools.begin_start( workspace_name="kustorptest", kusto_pool_name="kustoclusterrptest4", resource_group_name="kustorptest", ).result() - print(response) # x-ms-original-file: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolsStart.json diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_stop.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_stop.py index c5f211157299..c94036859163 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_stop.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_stop.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ @@ -29,12 +30,11 @@ def main(): subscription_id="12345678-1234-1234-1234-123456789098", ) - response = client.kusto_pools.begin_stop( + client.kusto_pools.begin_stop( workspace_name="kustorptest", kusto_pool_name="kustoclusterrptest4", resource_group_name="kustorptest", ).result() - print(response) # x-ms-original-file: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolsStop.json diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_update.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_update.py index 0d40a13f1e71..ebe66a4dd549 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_update.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/kusto_pools_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/libraries_list_by_workspace.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/libraries_list_by_workspace.py index 4e3b70fc8235..2d323cc90200 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/libraries_list_by_workspace.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/libraries_list_by_workspace.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/library_get.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/library_get.py index 96b55bbe38c7..24c4413bbea7 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/library_get.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/library_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_azure_ad_only_authentication.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_azure_ad_only_authentication.py index e5ab49f1e549..3cdc07e3dbfe 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_azure_ad_only_authentication.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_azure_ad_only_authentication.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_big_data_pools_in_workspace.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_big_data_pools_in_workspace.py index 91e70458a8b4..23dadecff8ff 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_big_data_pools_in_workspace.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_big_data_pools_in_workspace.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_ip_firewall_rules.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_ip_firewall_rules.py index e6bc42b9b884..cd971150a40b 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_ip_firewall_rules.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_ip_firewall_rules.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_keys_in_workspace.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_keys_in_workspace.py index 1d7b29a77cb6..a2c1a420e8be 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_keys_in_workspace.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_keys_in_workspace.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_private_endpoint_connections.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_private_endpoint_connections.py index 60c8c2731819..f98cda7ad8a9 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_private_endpoint_connections.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_private_endpoint_connections.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_private_link_hub_private_link_resources.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_private_link_hub_private_link_resources.py index e286d5442f5b..51cb80ad93f0 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_private_link_hub_private_link_resources.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_private_link_hub_private_link_resources.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_private_link_hubs_in_resource_group.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_private_link_hubs_in_resource_group.py index ed5f75103209..d0678e9b502e 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_private_link_hubs_in_resource_group.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_private_link_hubs_in_resource_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_private_link_hubs_in_subscription.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_private_link_hubs_in_subscription.py index d822ab5ba51d..06efd5070ff7 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_private_link_hubs_in_subscription.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_private_link_hubs_in_subscription.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_private_link_resources.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_private_link_resources.py index 89fd95b34540..52df8ecd3426 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_private_link_resources.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_private_link_resources.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pool_columns.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pool_columns.py index f2b3d617ae03..f41126b8a0d9 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pool_columns.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pool_columns.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pool_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pool_operations.py index e0a9e9cd3aa8..989055b45381 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pool_operations.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pool_operations.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pool_replication_links.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pool_replication_links.py index b97386c41a39..dc6bc4d56880 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pool_replication_links.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pool_replication_links.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pool_restore_points.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pool_restore_points.py index 828f675097c8..c4c57098f063 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pool_restore_points.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pool_restore_points.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pool_schema.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pool_schema.py index 883b59707059..1a7fc6f99648 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pool_schema.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pool_schema.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pool_sensitivity_labels_with_source_recommended.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pool_sensitivity_labels_with_source_recommended.py index f21fa6294624..90badd44c800 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pool_sensitivity_labels_with_source_recommended.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pool_sensitivity_labels_with_source_recommended.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pool_tables.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pool_tables.py index 34406fcb5680..9e4df3292067 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pool_tables.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pool_tables.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pool_vulnerability_assessment_scan_records.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pool_vulnerability_assessment_scan_records.py index d08df6d174df..b9f8666ef30a 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pool_vulnerability_assessment_scan_records.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pool_vulnerability_assessment_scan_records.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pool_vulnerability_assessments.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pool_vulnerability_assessments.py index ceeed0c9816c..5f46a2b9a1ae 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pool_vulnerability_assessments.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pool_vulnerability_assessments.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pools_in_workspace.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pools_in_workspace.py index 161f42dfeafb..0fad8d2e952f 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pools_in_workspace.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pools_in_workspace.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pools_in_workspace_with_filter.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pools_in_workspace_with_filter.py index 63916f55b901..03a34d1e4a07 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pools_in_workspace_with_filter.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pools_in_workspace_with_filter.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pools_sensitivity_labels_with_source_current.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pools_sensitivity_labels_with_source_current.py index 10ac8af28dba..9b9a9f1c8916 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pools_sensitivity_labels_with_source_current.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_sql_pools_sensitivity_labels_with_source_current.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_workspace_managed_sql_server_blob_auditing_settings.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_workspace_managed_sql_server_blob_auditing_settings.py index 215a0c306888..eb2cdc9edec0 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_workspace_managed_sql_server_blob_auditing_settings.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_workspace_managed_sql_server_blob_auditing_settings.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_workspace_managed_sql_server_dedicated_sq_lminimal_tls_settings.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_workspace_managed_sql_server_dedicated_sq_lminimal_tls_settings.py index c3e9e35dd5d3..fd5d27199916 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_workspace_managed_sql_server_dedicated_sq_lminimal_tls_settings.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_workspace_managed_sql_server_dedicated_sq_lminimal_tls_settings.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_workspace_managed_sql_server_extended_blob_auditing_settings.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_workspace_managed_sql_server_extended_blob_auditing_settings.py index ef74b7a35cc5..e94e45d904fd 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_workspace_managed_sql_server_extended_blob_auditing_settings.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_workspace_managed_sql_server_extended_blob_auditing_settings.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_workspace_managed_sql_server_recoverable_sql_pool.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_workspace_managed_sql_server_recoverable_sql_pool.py index e12c6a9bf891..bf4f776a5423 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_workspace_managed_sql_server_recoverable_sql_pool.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_workspace_managed_sql_server_recoverable_sql_pool.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_workspace_managed_sql_server_security_alert_policies.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_workspace_managed_sql_server_security_alert_policies.py index e015374024f3..39c7f22205a1 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_workspace_managed_sql_server_security_alert_policies.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_workspace_managed_sql_server_security_alert_policies.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_workspace_managed_sql_server_usages.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_workspace_managed_sql_server_usages.py index 90577aca1849..7faea74bca19 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_workspace_managed_sql_server_usages.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_workspace_managed_sql_server_usages.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_workspace_managed_sql_server_vulnerability_assessment_policies.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_workspace_managed_sql_server_vulnerability_assessment_policies.py index 91f5b6075f9f..f9a67b15dec8 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_workspace_managed_sql_server_vulnerability_assessment_policies.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_workspace_managed_sql_server_vulnerability_assessment_policies.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_workspaces_in_resource_group.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_workspaces_in_resource_group.py index 78d2c5218253..a1609d08b01c 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_workspaces_in_resource_group.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_workspaces_in_resource_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_workspaces_in_subscription.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_workspaces_in_subscription.py index d9b0986226fd..f8433a4c6f1f 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/list_workspaces_in_subscription.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/list_workspaces_in_subscription.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/pause_sql_pool.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/pause_sql_pool.py index 40235c40832e..991b449c1870 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/pause_sql_pool.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/pause_sql_pool.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/private_endpoint_connections_private_link_hub_get.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/private_endpoint_connections_private_link_hub_get.py index 50ad92f0b957..94953c01a7b3 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/private_endpoint_connections_private_link_hub_get.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/private_endpoint_connections_private_link_hub_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/private_endpoint_connections_private_link_hub_list.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/private_endpoint_connections_private_link_hub_list.py index 31adeee5ad6b..0a86c129a6a2 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/private_endpoint_connections_private_link_hub_list.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/private_endpoint_connections_private_link_hub_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/put_workspace_managed_sql_server_vulnerability_assessment_with_all_parameters.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/put_workspace_managed_sql_server_vulnerability_assessment_with_all_parameters.py index b79447c96382..2dd4ec3f8667 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/put_workspace_managed_sql_server_vulnerability_assessment_with_all_parameters.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/put_workspace_managed_sql_server_vulnerability_assessment_with_all_parameters.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/put_workspace_manged_sql_server_vulnerability_assessment_create_container_sas_key_min.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/put_workspace_manged_sql_server_vulnerability_assessment_create_container_sas_key_min.py index 244d6a238ccb..2a33ea921e04 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/put_workspace_manged_sql_server_vulnerability_assessment_create_container_sas_key_min.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/put_workspace_manged_sql_server_vulnerability_assessment_create_container_sas_key_min.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/put_workspace_manged_sql_server_vulnerability_assessment_create_storage_access_key_min.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/put_workspace_manged_sql_server_vulnerability_assessment_create_storage_access_key_min.py index 8aa9a4c97091..69552aa2e503 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/put_workspace_manged_sql_server_vulnerability_assessment_create_storage_access_key_min.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/put_workspace_manged_sql_server_vulnerability_assessment_create_storage_access_key_min.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/recommended_column_sensitivity_label_disable.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/recommended_column_sensitivity_label_disable.py index 85070633d88d..479082daa142 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/recommended_column_sensitivity_label_disable.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/recommended_column_sensitivity_label_disable.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ @@ -29,7 +30,7 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.sql_pool_sensitivity_labels.disable_recommendation( + client.sql_pool_sensitivity_labels.disable_recommendation( resource_group_name="myRG", workspace_name="myServer", sql_pool_name="myDatabase", @@ -37,7 +38,6 @@ def main(): table_name="myTable", column_name="myColumn", ) - print(response) # x-ms-original-file: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/RecommendedColumnSensitivityLabelDisable.json diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/recommended_column_sensitivity_label_enable.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/recommended_column_sensitivity_label_enable.py index c5d080a0e7e4..875839a4c0b8 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/recommended_column_sensitivity_label_enable.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/recommended_column_sensitivity_label_enable.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ @@ -29,7 +30,7 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.sql_pool_sensitivity_labels.enable_recommendation( + client.sql_pool_sensitivity_labels.enable_recommendation( resource_group_name="myRG", workspace_name="myServer", sql_pool_name="myDatabase", @@ -37,7 +38,6 @@ def main(): table_name="myTable", column_name="myColumn", ) - print(response) # x-ms-original-file: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/RecommendedColumnSensitivityLabelEnable.json diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/rename_sql_pool.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/rename_sql_pool.py deleted file mode 100644 index 499856c322f8..000000000000 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/rename_sql_pool.py +++ /dev/null @@ -1,45 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential -from azure.mgmt.synapse import SynapseManagementClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-synapse -# USAGE - python rename_sql_pool.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 = SynapseManagementClient( - credential=DefaultAzureCredential(), - subscription_id="00000000-1111-2222-3333-444444444444", - ) - - response = client.sql_pools.rename( - resource_group_name="Default-SQL-SouthEastAsia", - workspace_name="testsvr", - sql_pool_name="testdb", - parameters={ - "id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Synapse/workspaces/testsvr/sqlPools/newtestdb" - }, - ) - print(response) - - -# x-ms-original-file: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/RenameSqlPool.json -if __name__ == "__main__": - main() diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/replace_all_ip_firewall_rules.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/replace_all_ip_firewall_rules.py index 9842e1eaf450..176e5165a569 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/replace_all_ip_firewall_rules.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/replace_all_ip_firewall_rules.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/restorable_dropped_sql_pool_get.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/restorable_dropped_sql_pool_get.py index 3d8d28d2a05f..7a65fca44fad 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/restorable_dropped_sql_pool_get.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/restorable_dropped_sql_pool_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/restorable_dropped_sqlpool_list.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/restorable_dropped_sqlpool_list.py index 246532744b8e..c1b11ed50282 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/restorable_dropped_sqlpool_list.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/restorable_dropped_sqlpool_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/resume_sql_pool.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/resume_sql_pool.py index e7120654284f..e7b70dfc29d1 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/resume_sql_pool.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/resume_sql_pool.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/sensitivity_labels_current_update.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/sensitivity_labels_current_update.py index 84bf7dc6384b..c3055452fa6c 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/sensitivity_labels_current_update.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/sensitivity_labels_current_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ @@ -29,7 +30,7 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.sql_pool_sensitivity_labels.update( + client.sql_pool_sensitivity_labels.update( resource_group_name="myRG", workspace_name="myWorkspace", sql_pool_name="mySqlPool", @@ -73,7 +74,6 @@ def main(): ] }, ) - print(response) # x-ms-original-file: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/SensitivityLabelsCurrentUpdate.json diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/sensitivity_labels_recommended_update.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/sensitivity_labels_recommended_update.py index fbe12bcef23c..ce50598d3707 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/sensitivity_labels_recommended_update.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/sensitivity_labels_recommended_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ @@ -29,7 +30,7 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.sql_pool_recommended_sensitivity_labels.update( + client.sql_pool_recommended_sensitivity_labels.update( resource_group_name="myRG", workspace_name="myWorkspace", sql_pool_name="mySqlPool", @@ -41,7 +42,6 @@ def main(): ] }, ) - print(response) # x-ms-original-file: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/SensitivityLabelsRecommendedUpdate.json diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/spark_configuration_get.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/spark_configuration_get.py index ec8ddc4a2f79..7991fb5be211 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/spark_configuration_get.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/spark_configuration_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/spark_configurations_list_by_workspace.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/spark_configurations_list_by_workspace.py index 520c20041c29..c01d7a135dbe 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/spark_configurations_list_by_workspace.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/spark_configurations_list_by_workspace.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_auditing_settings_list.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_auditing_settings_list.py index 7646041a6aff..6d56cf4269ff 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_auditing_settings_list.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_auditing_settings_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_column_get.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_column_get.py index bfc54ac132f7..2e1d83a690ba 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_column_get.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_column_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_extended_auditing_settings_list.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_extended_auditing_settings_list.py index afc9a3754ad4..8233fae67a7f 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_extended_auditing_settings_list.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_extended_auditing_settings_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_geo_backup_policies_list.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_geo_backup_policies_list.py index adbc257358dc..e25a2fbb0bd5 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_geo_backup_policies_list.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_geo_backup_policies_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_replication_links_get_by_name.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_replication_links_get_by_name.py index d14a8b1ef24b..9d11688d51cf 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_replication_links_get_by_name.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_replication_links_get_by_name.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_restore_points_delete.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_restore_points_delete.py index 3e80d4fed32d..c1115178b2aa 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_restore_points_delete.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_restore_points_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ @@ -29,13 +30,12 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.sql_pool_restore_points.delete( + client.sql_pool_restore_points.delete( resource_group_name="Default-SQL-SouthEastAsia", workspace_name="testws", sql_pool_name="testpool", restore_point_name="131546477590000000", ) - print(response) # x-ms-original-file: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/SqlPoolRestorePointsDelete.json diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_restore_points_get.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_restore_points_get.py index de568f40fa64..a2546e5582fd 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_restore_points_get.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_restore_points_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_schema_get.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_schema_get.py index ac567eb2e06d..949ee4d47cf3 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_schema_get.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_schema_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_security_alert_policies_list.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_security_alert_policies_list.py index 64cf362d51f3..71d07829bb99 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_security_alert_policies_list.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_security_alert_policies_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_table_get.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_table_get.py index 21a1108ad6cb..f706ab47d342 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_table_get.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_table_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_usage_metrics_list.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_usage_metrics_list.py index 7f56cd9451ca..7f043726a5c5 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_usage_metrics_list.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_usage_metrics_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_vulnerability_assessment_rule_baseline_get.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_vulnerability_assessment_rule_baseline_get.py index 2a52c539aa7e..b032dc38348a 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_vulnerability_assessment_rule_baseline_get.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_vulnerability_assessment_rule_baseline_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_vulnerability_assessment_scan_records_get.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_vulnerability_assessment_scan_records_get.py index c56aee32c91c..8b002711f4bd 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_vulnerability_assessment_scan_records_get.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/sql_pool_vulnerability_assessment_scan_records_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/update_big_data_pool.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/update_big_data_pool.py index 3beaa88ee3d3..8ff8467d6ac5 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/update_big_data_pool.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/update_big_data_pool.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/update_private_link_hub.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/update_private_link_hub.py index 62f8d3206faa..39d5d9497dba 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/update_private_link_hub.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/update_private_link_hub.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/update_sql_pool.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/update_sql_pool.py index e809f585347d..125d91bc460a 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/update_sql_pool.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/update_sql_pool.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/update_workspace.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/update_workspace.py index 99ee853277bc..ce860b7b4f59 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/update_workspace.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/update_workspace.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/update_workspace_managed_sql_server_dedicated_sq_lminimal_tls_settings.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/update_workspace_managed_sql_server_dedicated_sq_lminimal_tls_settings.py index e9f559051eb7..8bb357bd9e9c 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/update_workspace_managed_sql_server_dedicated_sq_lminimal_tls_settings.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/update_workspace_managed_sql_server_dedicated_sq_lminimal_tls_settings.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/workspace_managed_sql_server_encryption_protector_create_or_update_key_vault.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/workspace_managed_sql_server_encryption_protector_create_or_update_key_vault.py index 0bbee940708a..508568bda4c3 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/workspace_managed_sql_server_encryption_protector_create_or_update_key_vault.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/workspace_managed_sql_server_encryption_protector_create_or_update_key_vault.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/workspace_managed_sql_server_encryption_protector_create_or_update_service_managed.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/workspace_managed_sql_server_encryption_protector_create_or_update_service_managed.py index 7d5bfedf660f..e5c419143008 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/workspace_managed_sql_server_encryption_protector_create_or_update_service_managed.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/workspace_managed_sql_server_encryption_protector_create_or_update_service_managed.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/workspace_managed_sql_server_encryption_protector_revalidate.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/workspace_managed_sql_server_encryption_protector_revalidate.py index 60550a9235ff..6af956bb0449 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/workspace_managed_sql_server_encryption_protector_revalidate.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/workspace_managed_sql_server_encryption_protector_revalidate.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ @@ -29,12 +30,11 @@ def main(): subscription_id="00000000-1111-2222-3333-444444444444", ) - response = client.workspace_managed_sql_server_encryption_protector.begin_revalidate( + client.workspace_managed_sql_server_encryption_protector.begin_revalidate( resource_group_name="wsg-7398", workspace_name="testWorkspace", encryption_protector_name="current", ).result() - print(response) # x-ms-original-file: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/WorkspaceManagedSqlServerEncryptionProtectorRevalidate.json diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/workspace_managed_sql_server_security_alert_create_with_min_parameters.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/workspace_managed_sql_server_security_alert_create_with_min_parameters.py index 133fdbd9ca05..4f8b49d7685a 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/workspace_managed_sql_server_security_alert_create_with_min_parameters.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/workspace_managed_sql_server_security_alert_create_with_min_parameters.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_samples/workspace_managed_sql_server_security_alert_with_all_parameters.py b/sdk/synapse/azure-mgmt-synapse/generated_samples/workspace_managed_sql_server_security_alert_with_all_parameters.py index 238e82cf1486..da87a0b6f615 100644 --- a/sdk/synapse/azure-mgmt-synapse/generated_samples/workspace_managed_sql_server_security_alert_with_all_parameters.py +++ b/sdk/synapse/azure-mgmt-synapse/generated_samples/workspace_managed_sql_server_security_alert_with_all_parameters.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.synapse import SynapseManagementClient """ diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/conftest.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/conftest.py new file mode 100644 index 000000000000..3f5cebc55e75 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/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() + + +# For security, please avoid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + synapsemanagement_subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + synapsemanagement_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + synapsemanagement_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + synapsemanagement_client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=synapsemanagement_subscription_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=synapsemanagement_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=synapsemanagement_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=synapsemanagement_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/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_azure_ad_only_authentications_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_azure_ad_only_authentications_operations.py new file mode 100644 index 000000000000..cdd8349bd41e --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_azure_ad_only_authentications_operations.py @@ -0,0 +1,65 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementAzureADOnlyAuthenticationsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_azure_ad_only_authentications_get(self, resource_group): + response = self.client.azure_ad_only_authentications.get( + resource_group_name=resource_group.name, + workspace_name="str", + azure_ad_only_authentication_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_azure_ad_only_authentications_begin_create(self, resource_group): + response = self.client.azure_ad_only_authentications.begin_create( + resource_group_name=resource_group.name, + workspace_name="str", + azure_ad_only_authentication_name="str", + azure_ad_only_authentication_info={ + "azureADOnlyAuthentication": bool, + "creationDate": "2020-02-20 00:00:00", + "id": "str", + "name": "str", + "state": "str", + "type": "str", + }, + api_version="2021-06-01", + ).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_azure_ad_only_authentications_list(self, resource_group): + response = self.client.azure_ad_only_authentications.list( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_azure_ad_only_authentications_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_azure_ad_only_authentications_operations_async.py new file mode 100644 index 000000000000..9070c155c4cd --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_azure_ad_only_authentications_operations_async.py @@ -0,0 +1,68 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementAzureADOnlyAuthenticationsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_azure_ad_only_authentications_get(self, resource_group): + response = await self.client.azure_ad_only_authentications.get( + resource_group_name=resource_group.name, + workspace_name="str", + azure_ad_only_authentication_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_azure_ad_only_authentications_begin_create(self, resource_group): + response = await ( + await self.client.azure_ad_only_authentications.begin_create( + resource_group_name=resource_group.name, + workspace_name="str", + azure_ad_only_authentication_name="str", + azure_ad_only_authentication_info={ + "azureADOnlyAuthentication": bool, + "creationDate": "2020-02-20 00:00:00", + "id": "str", + "name": "str", + "state": "str", + "type": "str", + }, + api_version="2021-06-01", + ) + ).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_azure_ad_only_authentications_list(self, resource_group): + response = self.client.azure_ad_only_authentications.list( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_big_data_pools_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_big_data_pools_operations.py new file mode 100644 index 000000000000..7610e28c17f4 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_big_data_pools_operations.py @@ -0,0 +1,125 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementBigDataPoolsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_big_data_pools_get(self, resource_group): + response = self.client.big_data_pools.get( + resource_group_name=resource_group.name, + workspace_name="str", + big_data_pool_name="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_big_data_pools_update(self, resource_group): + response = self.client.big_data_pools.update( + resource_group_name=resource_group.name, + workspace_name="str", + big_data_pool_name="str", + big_data_pool_patch_info={"tags": {"str": "str"}}, + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_big_data_pools_begin_create_or_update(self, resource_group): + response = self.client.big_data_pools.begin_create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + big_data_pool_name="str", + big_data_pool_info={ + "location": "str", + "autoPause": {"delayInMinutes": 0, "enabled": bool}, + "autoScale": {"enabled": bool, "maxNodeCount": 0, "minNodeCount": 0}, + "cacheSize": 0, + "creationDate": "2020-02-20 00:00:00", + "customLibraries": [ + { + "containerName": "str", + "creatorId": "str", + "name": "str", + "path": "str", + "provisioningStatus": "str", + "type": "str", + "uploadedTimestamp": "2020-02-20 00:00:00", + } + ], + "defaultSparkLogFolder": "str", + "dynamicExecutorAllocation": {"enabled": bool, "maxExecutors": 0, "minExecutors": 0}, + "id": "str", + "isAutotuneEnabled": bool, + "isComputeIsolationEnabled": bool, + "lastSucceededTimestamp": "2020-02-20 00:00:00", + "libraryRequirements": {"content": "str", "filename": "str", "time": "2020-02-20 00:00:00"}, + "name": "str", + "nodeCount": 0, + "nodeSize": "str", + "nodeSizeFamily": "str", + "provisioningState": "str", + "sessionLevelPackagesEnabled": bool, + "sparkConfigProperties": { + "configurationType": "str", + "content": "str", + "filename": "str", + "time": "2020-02-20 00:00:00", + }, + "sparkEventsFolder": "str", + "sparkVersion": "str", + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2021-06-01-preview", + ).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_big_data_pools_begin_delete(self, resource_group): + response = self.client.big_data_pools.begin_delete( + resource_group_name=resource_group.name, + workspace_name="str", + big_data_pool_name="str", + api_version="2021-06-01-preview", + ).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_big_data_pools_list_by_workspace(self, resource_group): + response = self.client.big_data_pools.list_by_workspace( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_big_data_pools_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_big_data_pools_operations_async.py new file mode 100644 index 000000000000..5c5c50ef7882 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_big_data_pools_operations_async.py @@ -0,0 +1,130 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementBigDataPoolsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_big_data_pools_get(self, resource_group): + response = await self.client.big_data_pools.get( + resource_group_name=resource_group.name, + workspace_name="str", + big_data_pool_name="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_big_data_pools_update(self, resource_group): + response = await self.client.big_data_pools.update( + resource_group_name=resource_group.name, + workspace_name="str", + big_data_pool_name="str", + big_data_pool_patch_info={"tags": {"str": "str"}}, + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_big_data_pools_begin_create_or_update(self, resource_group): + response = await ( + await self.client.big_data_pools.begin_create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + big_data_pool_name="str", + big_data_pool_info={ + "location": "str", + "autoPause": {"delayInMinutes": 0, "enabled": bool}, + "autoScale": {"enabled": bool, "maxNodeCount": 0, "minNodeCount": 0}, + "cacheSize": 0, + "creationDate": "2020-02-20 00:00:00", + "customLibraries": [ + { + "containerName": "str", + "creatorId": "str", + "name": "str", + "path": "str", + "provisioningStatus": "str", + "type": "str", + "uploadedTimestamp": "2020-02-20 00:00:00", + } + ], + "defaultSparkLogFolder": "str", + "dynamicExecutorAllocation": {"enabled": bool, "maxExecutors": 0, "minExecutors": 0}, + "id": "str", + "isAutotuneEnabled": bool, + "isComputeIsolationEnabled": bool, + "lastSucceededTimestamp": "2020-02-20 00:00:00", + "libraryRequirements": {"content": "str", "filename": "str", "time": "2020-02-20 00:00:00"}, + "name": "str", + "nodeCount": 0, + "nodeSize": "str", + "nodeSizeFamily": "str", + "provisioningState": "str", + "sessionLevelPackagesEnabled": bool, + "sparkConfigProperties": { + "configurationType": "str", + "content": "str", + "filename": "str", + "time": "2020-02-20 00:00:00", + }, + "sparkEventsFolder": "str", + "sparkVersion": "str", + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2021-06-01-preview", + ) + ).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_big_data_pools_begin_delete(self, resource_group): + response = await ( + await self.client.big_data_pools.begin_delete( + resource_group_name=resource_group.name, + workspace_name="str", + big_data_pool_name="str", + api_version="2021-06-01-preview", + ) + ).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_big_data_pools_list_by_workspace(self, resource_group): + response = self.client.big_data_pools.list_by_workspace( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_data_masking_policies_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_data_masking_policies_operations.py new file mode 100644 index 000000000000..57444034f0d1 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_data_masking_policies_operations.py @@ -0,0 +1,59 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementDataMaskingPoliciesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_data_masking_policies_create_or_update(self, resource_group): + response = self.client.data_masking_policies.create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + parameters={ + "applicationPrincipals": "str", + "dataMaskingState": "str", + "exemptPrincipals": "str", + "id": "str", + "kind": "str", + "location": "str", + "managedBy": "str", + "maskingLevel": "str", + "name": "str", + "type": "str", + }, + api_version="2021-06-01", + data_masking_policy_name="Default", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_data_masking_policies_get(self, resource_group): + response = self.client.data_masking_policies.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + data_masking_policy_name="Default", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_data_masking_policies_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_data_masking_policies_operations_async.py new file mode 100644 index 000000000000..debaf22eccfd --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_data_masking_policies_operations_async.py @@ -0,0 +1,60 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementDataMaskingPoliciesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_data_masking_policies_create_or_update(self, resource_group): + response = await self.client.data_masking_policies.create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + parameters={ + "applicationPrincipals": "str", + "dataMaskingState": "str", + "exemptPrincipals": "str", + "id": "str", + "kind": "str", + "location": "str", + "managedBy": "str", + "maskingLevel": "str", + "name": "str", + "type": "str", + }, + api_version="2021-06-01", + data_masking_policy_name="Default", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_data_masking_policies_get(self, resource_group): + response = await self.client.data_masking_policies.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + data_masking_policy_name="Default", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_data_masking_rules_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_data_masking_rules_operations.py new file mode 100644 index 000000000000..b42b66016f52 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_data_masking_rules_operations.py @@ -0,0 +1,81 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementDataMaskingRulesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_data_masking_rules_create_or_update(self, resource_group): + response = self.client.data_masking_rules.create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + data_masking_rule_name="str", + parameters={ + "aliasName": "str", + "columnName": "str", + "id": "str", + "kind": "str", + "location": "str", + "maskingFunction": "str", + "name": "str", + "numberFrom": "str", + "numberTo": "str", + "prefixSize": "str", + "replacementString": "str", + "ruleState": "str", + "schemaName": "str", + "suffixSize": "str", + "tableName": "str", + "type": "str", + }, + api_version="2021-06-01", + data_masking_policy_name="Default", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_data_masking_rules_get(self, resource_group): + response = self.client.data_masking_rules.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + data_masking_rule_name="str", + api_version="2021-06-01", + data_masking_policy_name="Default", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_data_masking_rules_list_by_sql_pool(self, resource_group): + response = self.client.data_masking_rules.list_by_sql_pool( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + data_masking_policy_name="Default", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_data_masking_rules_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_data_masking_rules_operations_async.py new file mode 100644 index 000000000000..84d8a7e35086 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_data_masking_rules_operations_async.py @@ -0,0 +1,82 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementDataMaskingRulesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_data_masking_rules_create_or_update(self, resource_group): + response = await self.client.data_masking_rules.create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + data_masking_rule_name="str", + parameters={ + "aliasName": "str", + "columnName": "str", + "id": "str", + "kind": "str", + "location": "str", + "maskingFunction": "str", + "name": "str", + "numberFrom": "str", + "numberTo": "str", + "prefixSize": "str", + "replacementString": "str", + "ruleState": "str", + "schemaName": "str", + "suffixSize": "str", + "tableName": "str", + "type": "str", + }, + api_version="2021-06-01", + data_masking_policy_name="Default", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_data_masking_rules_get(self, resource_group): + response = await self.client.data_masking_rules.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + data_masking_rule_name="str", + api_version="2021-06-01", + data_masking_policy_name="Default", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_data_masking_rules_list_by_sql_pool(self, resource_group): + response = self.client.data_masking_rules.list_by_sql_pool( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + data_masking_policy_name="Default", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_extended_sql_pool_blob_auditing_policies_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_extended_sql_pool_blob_auditing_policies_operations.py new file mode 100644 index 000000000000..29df69af283f --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_extended_sql_pool_blob_auditing_policies_operations.py @@ -0,0 +1,75 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementExtendedSqlPoolBlobAuditingPoliciesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_extended_sql_pool_blob_auditing_policies_get(self, resource_group): + response = self.client.extended_sql_pool_blob_auditing_policies.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + blob_auditing_policy_name="default", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_extended_sql_pool_blob_auditing_policies_create_or_update(self, resource_group): + response = self.client.extended_sql_pool_blob_auditing_policies.create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + parameters={ + "auditActionsAndGroups": ["str"], + "id": "str", + "isAzureMonitorTargetEnabled": bool, + "isStorageSecondaryKeyInUse": bool, + "name": "str", + "predicateExpression": "str", + "queueDelayMs": 0, + "retentionDays": 0, + "state": "str", + "storageAccountAccessKey": "str", + "storageAccountSubscriptionId": "str", + "storageEndpoint": "str", + "type": "str", + }, + api_version="2021-06-01", + blob_auditing_policy_name="default", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_extended_sql_pool_blob_auditing_policies_list_by_sql_pool(self, resource_group): + response = self.client.extended_sql_pool_blob_auditing_policies.list_by_sql_pool( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_extended_sql_pool_blob_auditing_policies_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_extended_sql_pool_blob_auditing_policies_operations_async.py new file mode 100644 index 000000000000..d172620d5c8d --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_extended_sql_pool_blob_auditing_policies_operations_async.py @@ -0,0 +1,76 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementExtendedSqlPoolBlobAuditingPoliciesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_extended_sql_pool_blob_auditing_policies_get(self, resource_group): + response = await self.client.extended_sql_pool_blob_auditing_policies.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + blob_auditing_policy_name="default", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_extended_sql_pool_blob_auditing_policies_create_or_update(self, resource_group): + response = await self.client.extended_sql_pool_blob_auditing_policies.create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + parameters={ + "auditActionsAndGroups": ["str"], + "id": "str", + "isAzureMonitorTargetEnabled": bool, + "isStorageSecondaryKeyInUse": bool, + "name": "str", + "predicateExpression": "str", + "queueDelayMs": 0, + "retentionDays": 0, + "state": "str", + "storageAccountAccessKey": "str", + "storageAccountSubscriptionId": "str", + "storageEndpoint": "str", + "type": "str", + }, + api_version="2021-06-01", + blob_auditing_policy_name="default", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_extended_sql_pool_blob_auditing_policies_list_by_sql_pool(self, resource_group): + response = self.client.extended_sql_pool_blob_auditing_policies.list_by_sql_pool( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_get_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_get_operations.py new file mode 100644 index 000000000000..428d134af42b --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_get_operations.py @@ -0,0 +1,61 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementGetOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_integration_runtime_start(self, resource_group): + response = self.client.get.integration_runtime_start( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + integration_runtime_operation_id="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_integration_runtime_stop(self, resource_group): + response = self.client.get.integration_runtime_stop( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + integration_runtime_operation_id="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_integration_runtime_enable_interactivequery(self, resource_group): + response = self.client.get.integration_runtime_enable_interactivequery( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + integration_runtime_operation_id="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_get_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_get_operations_async.py new file mode 100644 index 000000000000..29f3d6e48b81 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_get_operations_async.py @@ -0,0 +1,62 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementGetOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_integration_runtime_start(self, resource_group): + response = await self.client.get.integration_runtime_start( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + integration_runtime_operation_id="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_integration_runtime_stop(self, resource_group): + response = await self.client.get.integration_runtime_stop( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + integration_runtime_operation_id="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_integration_runtime_enable_interactivequery(self, resource_group): + response = await self.client.get.integration_runtime_enable_interactivequery( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + integration_runtime_operation_id="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_auth_keys_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_auth_keys_operations.py new file mode 100644 index 000000000000..2097bc528858 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_auth_keys_operations.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.synapse import SynapseManagementClient + +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 TestSynapseManagementIntegrationRuntimeAuthKeysOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_integration_runtime_auth_keys_regenerate(self, resource_group): + response = self.client.integration_runtime_auth_keys.regenerate( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + regenerate_key_parameters={"keyName": "str"}, + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_integration_runtime_auth_keys_list(self, resource_group): + response = self.client.integration_runtime_auth_keys.list( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_auth_keys_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_auth_keys_operations_async.py new file mode 100644 index 000000000000..31dc590db84b --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_auth_keys_operations_async.py @@ -0,0 +1,47 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementIntegrationRuntimeAuthKeysOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_integration_runtime_auth_keys_regenerate(self, resource_group): + response = await self.client.integration_runtime_auth_keys.regenerate( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + regenerate_key_parameters={"keyName": "str"}, + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_integration_runtime_auth_keys_list(self, resource_group): + response = await self.client.integration_runtime_auth_keys.list( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_connection_infos_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_connection_infos_operations.py new file mode 100644 index 000000000000..62f97ea1a806 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_connection_infos_operations.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.synapse import SynapseManagementClient + +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 TestSynapseManagementIntegrationRuntimeConnectionInfosOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_integration_runtime_connection_infos_get(self, resource_group): + response = self.client.integration_runtime_connection_infos.get( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_connection_infos_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_connection_infos_operations_async.py new file mode 100644 index 000000000000..a511e7b0dffd --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_connection_infos_operations_async.py @@ -0,0 +1,33 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementIntegrationRuntimeConnectionInfosOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_integration_runtime_connection_infos_get(self, resource_group): + response = await self.client.integration_runtime_connection_infos.get( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_credentials_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_credentials_operations.py new file mode 100644 index 000000000000..80f21ef0bfe7 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_credentials_operations.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.synapse import SynapseManagementClient + +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 TestSynapseManagementIntegrationRuntimeCredentialsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_integration_runtime_credentials_sync(self, resource_group): + response = self.client.integration_runtime_credentials.sync( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_credentials_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_credentials_operations_async.py new file mode 100644 index 000000000000..bb1cac5c6122 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_credentials_operations_async.py @@ -0,0 +1,33 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementIntegrationRuntimeCredentialsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_integration_runtime_credentials_sync(self, resource_group): + response = await self.client.integration_runtime_credentials.sync( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_monitoring_data_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_monitoring_data_operations.py new file mode 100644 index 000000000000..98347daed18c --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_monitoring_data_operations.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.synapse import SynapseManagementClient + +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 TestSynapseManagementIntegrationRuntimeMonitoringDataOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_integration_runtime_monitoring_data_list(self, resource_group): + response = self.client.integration_runtime_monitoring_data.list( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_monitoring_data_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_monitoring_data_operations_async.py new file mode 100644 index 000000000000..b826dd2fad41 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_monitoring_data_operations_async.py @@ -0,0 +1,33 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementIntegrationRuntimeMonitoringDataOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_integration_runtime_monitoring_data_list(self, resource_group): + response = await self.client.integration_runtime_monitoring_data.list( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_node_ip_address_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_node_ip_address_operations.py new file mode 100644 index 000000000000..608bf17f6d72 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_node_ip_address_operations.py @@ -0,0 +1,33 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementIntegrationRuntimeNodeIpAddressOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_integration_runtime_node_ip_address_get(self, resource_group): + response = self.client.integration_runtime_node_ip_address.get( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + node_name="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_node_ip_address_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_node_ip_address_operations_async.py new file mode 100644 index 000000000000..0d9fa04a6191 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_node_ip_address_operations_async.py @@ -0,0 +1,34 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementIntegrationRuntimeNodeIpAddressOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_integration_runtime_node_ip_address_get(self, resource_group): + response = await self.client.integration_runtime_node_ip_address.get( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + node_name="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_nodes_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_nodes_operations.py new file mode 100644 index 000000000000..920adc263f81 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_nodes_operations.py @@ -0,0 +1,62 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementIntegrationRuntimeNodesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_integration_runtime_nodes_get(self, resource_group): + response = self.client.integration_runtime_nodes.get( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + node_name="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_integration_runtime_nodes_update(self, resource_group): + response = self.client.integration_runtime_nodes.update( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + node_name="str", + update_integration_runtime_node_request={"concurrentJobsLimit": 0}, + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_integration_runtime_nodes_delete(self, resource_group): + response = self.client.integration_runtime_nodes.delete( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + node_name="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_nodes_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_nodes_operations_async.py new file mode 100644 index 000000000000..ed27edca5c24 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_nodes_operations_async.py @@ -0,0 +1,63 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementIntegrationRuntimeNodesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_integration_runtime_nodes_get(self, resource_group): + response = await self.client.integration_runtime_nodes.get( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + node_name="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_integration_runtime_nodes_update(self, resource_group): + response = await self.client.integration_runtime_nodes.update( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + node_name="str", + update_integration_runtime_node_request={"concurrentJobsLimit": 0}, + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_integration_runtime_nodes_delete(self, resource_group): + response = await self.client.integration_runtime_nodes.delete( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + node_name="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_object_metadata_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_object_metadata_operations.py new file mode 100644 index 000000000000..43c9a5e54d53 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_object_metadata_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.synapse import SynapseManagementClient + +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 TestSynapseManagementIntegrationRuntimeObjectMetadataOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_integration_runtime_object_metadata_list(self, resource_group): + response = self.client.integration_runtime_object_metadata.list( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_integration_runtime_object_metadata_begin_refresh(self, resource_group): + response = self.client.integration_runtime_object_metadata.begin_refresh( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + api_version="2021-06-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_object_metadata_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_object_metadata_operations_async.py new file mode 100644 index 000000000000..e313d84cd6ce --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_object_metadata_operations_async.py @@ -0,0 +1,48 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementIntegrationRuntimeObjectMetadataOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_integration_runtime_object_metadata_list(self, resource_group): + response = await self.client.integration_runtime_object_metadata.list( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_integration_runtime_object_metadata_begin_refresh(self, resource_group): + response = await ( + await self.client.integration_runtime_object_metadata.begin_refresh( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + api_version="2021-06-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_status_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_status_operations.py new file mode 100644 index 000000000000..037ede0e0956 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_status_operations.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.synapse import SynapseManagementClient + +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 TestSynapseManagementIntegrationRuntimeStatusOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_integration_runtime_status_get(self, resource_group): + response = self.client.integration_runtime_status.get( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_status_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_status_operations_async.py new file mode 100644 index 000000000000..944e8e085d91 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtime_status_operations_async.py @@ -0,0 +1,33 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementIntegrationRuntimeStatusOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_integration_runtime_status_get(self, resource_group): + response = await self.client.integration_runtime_status.get( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtimes_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtimes_operations.py new file mode 100644 index 000000000000..01434449d2fa --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtimes_operations.py @@ -0,0 +1,163 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementIntegrationRuntimesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_integration_runtimes_update(self, resource_group): + response = self.client.integration_runtimes.update( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + update_integration_runtime_request={"autoUpdate": "str", "updateDelayOffset": "str"}, + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_integration_runtimes_get(self, resource_group): + response = self.client.integration_runtimes.get( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_integration_runtimes_begin_create(self, resource_group): + response = self.client.integration_runtimes.begin_create( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + integration_runtime={"description": "str", "etag": "str", "id": "str", "name": "str", "type": "str"}, + api_version="2021-06-01-preview", + ).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_integration_runtimes_begin_delete(self, resource_group): + response = self.client.integration_runtimes.begin_delete( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + api_version="2021-06-01-preview", + ).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_integration_runtimes_upgrade(self, resource_group): + response = self.client.integration_runtimes.upgrade( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_integration_runtimes_list_by_workspace(self, resource_group): + response = self.client.integration_runtimes.list_by_workspace( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_integration_runtimes_begin_start(self, resource_group): + response = self.client.integration_runtimes.begin_start( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + api_version="2021-06-01-preview", + ).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_integration_runtimes_begin_stop(self, resource_group): + response = self.client.integration_runtimes.begin_stop( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + api_version="2021-06-01-preview", + ).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_integration_runtimes_list_outbound_network_dependencies_endpoints(self, resource_group): + response = self.client.integration_runtimes.list_outbound_network_dependencies_endpoints( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_integration_runtimes_begin_enable_interactive_query(self, resource_group): + response = self.client.integration_runtimes.begin_enable_interactive_query( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + api_version="2021-06-01-preview", + ).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_integration_runtimes_begin_disable_interactive_query(self, resource_group): + response = self.client.integration_runtimes.begin_disable_interactive_query( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + api_version="2021-06-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtimes_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtimes_operations_async.py new file mode 100644 index 000000000000..15ede1e48b34 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_integration_runtimes_operations_async.py @@ -0,0 +1,176 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementIntegrationRuntimesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_integration_runtimes_update(self, resource_group): + response = await self.client.integration_runtimes.update( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + update_integration_runtime_request={"autoUpdate": "str", "updateDelayOffset": "str"}, + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_integration_runtimes_get(self, resource_group): + response = await self.client.integration_runtimes.get( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_integration_runtimes_begin_create(self, resource_group): + response = await ( + await self.client.integration_runtimes.begin_create( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + integration_runtime={"description": "str", "etag": "str", "id": "str", "name": "str", "type": "str"}, + api_version="2021-06-01-preview", + ) + ).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_integration_runtimes_begin_delete(self, resource_group): + response = await ( + await self.client.integration_runtimes.begin_delete( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + api_version="2021-06-01-preview", + ) + ).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_integration_runtimes_upgrade(self, resource_group): + response = await self.client.integration_runtimes.upgrade( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_integration_runtimes_list_by_workspace(self, resource_group): + response = self.client.integration_runtimes.list_by_workspace( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01-preview", + ) + 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_integration_runtimes_begin_start(self, resource_group): + response = await ( + await self.client.integration_runtimes.begin_start( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + api_version="2021-06-01-preview", + ) + ).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_integration_runtimes_begin_stop(self, resource_group): + response = await ( + await self.client.integration_runtimes.begin_stop( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + api_version="2021-06-01-preview", + ) + ).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_integration_runtimes_list_outbound_network_dependencies_endpoints(self, resource_group): + response = await self.client.integration_runtimes.list_outbound_network_dependencies_endpoints( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_integration_runtimes_begin_enable_interactive_query(self, resource_group): + response = await ( + await self.client.integration_runtimes.begin_enable_interactive_query( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + api_version="2021-06-01-preview", + ) + ).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_integration_runtimes_begin_disable_interactive_query(self, resource_group): + response = await ( + await self.client.integration_runtimes.begin_disable_interactive_query( + resource_group_name=resource_group.name, + workspace_name="str", + integration_runtime_name="str", + api_version="2021-06-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_ip_firewall_rules_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_ip_firewall_rules_operations.py new file mode 100644 index 000000000000..e58050f8ac77 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_ip_firewall_rules_operations.py @@ -0,0 +1,93 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementIpFirewallRulesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_ip_firewall_rules_list_by_workspace(self, resource_group): + response = self.client.ip_firewall_rules.list_by_workspace( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_ip_firewall_rules_begin_create_or_update(self, resource_group): + response = self.client.ip_firewall_rules.begin_create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + rule_name="str", + ip_firewall_rule_info={ + "endIpAddress": "str", + "id": "str", + "name": "str", + "provisioningState": "str", + "startIpAddress": "str", + "type": "str", + }, + api_version="2021-06-01", + ).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_ip_firewall_rules_begin_delete(self, resource_group): + response = self.client.ip_firewall_rules.begin_delete( + resource_group_name=resource_group.name, + workspace_name="str", + rule_name="str", + api_version="2021-06-01", + ).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_ip_firewall_rules_get(self, resource_group): + response = self.client.ip_firewall_rules.get( + resource_group_name=resource_group.name, + workspace_name="str", + rule_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_ip_firewall_rules_begin_replace_all(self, resource_group): + response = self.client.ip_firewall_rules.begin_replace_all( + resource_group_name=resource_group.name, + workspace_name="str", + request={ + "ipFirewallRules": {"str": {"endIpAddress": "str", "provisioningState": "str", "startIpAddress": "str"}} + }, + api_version="2021-06-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_ip_firewall_rules_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_ip_firewall_rules_operations_async.py new file mode 100644 index 000000000000..da79eaf9ad62 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_ip_firewall_rules_operations_async.py @@ -0,0 +1,102 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementIpFirewallRulesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_ip_firewall_rules_list_by_workspace(self, resource_group): + response = self.client.ip_firewall_rules.list_by_workspace( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + 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_ip_firewall_rules_begin_create_or_update(self, resource_group): + response = await ( + await self.client.ip_firewall_rules.begin_create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + rule_name="str", + ip_firewall_rule_info={ + "endIpAddress": "str", + "id": "str", + "name": "str", + "provisioningState": "str", + "startIpAddress": "str", + "type": "str", + }, + api_version="2021-06-01", + ) + ).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_ip_firewall_rules_begin_delete(self, resource_group): + response = await ( + await self.client.ip_firewall_rules.begin_delete( + resource_group_name=resource_group.name, + workspace_name="str", + rule_name="str", + api_version="2021-06-01", + ) + ).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_ip_firewall_rules_get(self, resource_group): + response = await self.client.ip_firewall_rules.get( + resource_group_name=resource_group.name, + workspace_name="str", + rule_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_ip_firewall_rules_begin_replace_all(self, resource_group): + response = await ( + await self.client.ip_firewall_rules.begin_replace_all( + resource_group_name=resource_group.name, + workspace_name="str", + request={ + "ipFirewallRules": { + "str": {"endIpAddress": "str", "provisioningState": "str", "startIpAddress": "str"} + } + }, + api_version="2021-06-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_keys_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_keys_operations.py new file mode 100644 index 000000000000..d51014aecfcd --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_keys_operations.py @@ -0,0 +1,71 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementKeysOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_keys_list_by_workspace(self, resource_group): + response = self.client.keys.list_by_workspace( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_keys_get(self, resource_group): + response = self.client.keys.get( + resource_group_name=resource_group.name, + workspace_name="str", + key_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_keys_create_or_update(self, resource_group): + response = self.client.keys.create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + key_name="str", + key_properties={"id": "str", "isActiveCMK": bool, "keyVaultUrl": "str", "name": "str", "type": "str"}, + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_keys_delete(self, resource_group): + response = self.client.keys.delete( + resource_group_name=resource_group.name, + workspace_name="str", + key_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_keys_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_keys_operations_async.py new file mode 100644 index 000000000000..91838d15ef69 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_keys_operations_async.py @@ -0,0 +1,72 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementKeysOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_keys_list_by_workspace(self, resource_group): + response = self.client.keys.list_by_workspace( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + 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_keys_get(self, resource_group): + response = await self.client.keys.get( + resource_group_name=resource_group.name, + workspace_name="str", + key_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_keys_create_or_update(self, resource_group): + response = await self.client.keys.create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + key_name="str", + key_properties={"id": "str", "isActiveCMK": bool, "keyVaultUrl": "str", "name": "str", "type": "str"}, + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_keys_delete(self, resource_group): + response = await self.client.keys.delete( + resource_group_name=resource_group.name, + workspace_name="str", + key_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_operations_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_operations_operations.py new file mode 100644 index 000000000000..1e25b36e62ed --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_operations_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.synapse import SynapseManagementClient + +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 TestSynapseManagementKustoOperationsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_kusto_operations_list(self, resource_group): + response = self.client.kusto_operations.list( + api_version="2021-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_operations_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_operations_operations_async.py new file mode 100644 index 000000000000..f2b616271c0d --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_operations_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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementKustoOperationsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_kusto_operations_list(self, resource_group): + response = self.client.kusto_operations.list( + api_version="2021-06-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_attached_database_configurations_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_attached_database_configurations_operations.py new file mode 100644 index 000000000000..2e8273bfc75d --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_attached_database_configurations_operations.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.synapse import SynapseManagementClient + +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 TestSynapseManagementKustoPoolAttachedDatabaseConfigurationsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_kusto_pool_attached_database_configurations_list_by_kusto_pool(self, resource_group): + response = self.client.kusto_pool_attached_database_configurations.list_by_kusto_pool( + workspace_name="str", + kusto_pool_name="str", + resource_group_name=resource_group.name, + api_version="2021-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_kusto_pool_attached_database_configurations_get(self, resource_group): + response = self.client.kusto_pool_attached_database_configurations.get( + workspace_name="str", + kusto_pool_name="str", + attached_database_configuration_name="str", + resource_group_name=resource_group.name, + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_kusto_pool_attached_database_configurations_begin_create_or_update(self, resource_group): + response = self.client.kusto_pool_attached_database_configurations.begin_create_or_update( + workspace_name="str", + kusto_pool_name="str", + attached_database_configuration_name="str", + resource_group_name=resource_group.name, + parameters={ + "attachedDatabaseNames": ["str"], + "clusterResourceId": "str", + "databaseName": "str", + "defaultPrincipalsModificationKind": "str", + "id": "str", + "location": "str", + "name": "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", + }, + "tableLevelSharingProperties": { + "externalTablesToExclude": ["str"], + "externalTablesToInclude": ["str"], + "materializedViewsToExclude": ["str"], + "materializedViewsToInclude": ["str"], + "tablesToExclude": ["str"], + "tablesToInclude": ["str"], + }, + "type": "str", + }, + api_version="2021-06-01-preview", + ).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_kusto_pool_attached_database_configurations_begin_delete(self, resource_group): + response = self.client.kusto_pool_attached_database_configurations.begin_delete( + workspace_name="str", + kusto_pool_name="str", + attached_database_configuration_name="str", + resource_group_name=resource_group.name, + api_version="2021-06-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_attached_database_configurations_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_attached_database_configurations_operations_async.py new file mode 100644 index 000000000000..aa11ca35bb38 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_attached_database_configurations_operations_async.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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementKustoPoolAttachedDatabaseConfigurationsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_kusto_pool_attached_database_configurations_list_by_kusto_pool(self, resource_group): + response = self.client.kusto_pool_attached_database_configurations.list_by_kusto_pool( + workspace_name="str", + kusto_pool_name="str", + resource_group_name=resource_group.name, + api_version="2021-06-01-preview", + ) + 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_kusto_pool_attached_database_configurations_get(self, resource_group): + response = await self.client.kusto_pool_attached_database_configurations.get( + workspace_name="str", + kusto_pool_name="str", + attached_database_configuration_name="str", + resource_group_name=resource_group.name, + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_kusto_pool_attached_database_configurations_begin_create_or_update(self, resource_group): + response = await ( + await self.client.kusto_pool_attached_database_configurations.begin_create_or_update( + workspace_name="str", + kusto_pool_name="str", + attached_database_configuration_name="str", + resource_group_name=resource_group.name, + parameters={ + "attachedDatabaseNames": ["str"], + "clusterResourceId": "str", + "databaseName": "str", + "defaultPrincipalsModificationKind": "str", + "id": "str", + "location": "str", + "name": "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", + }, + "tableLevelSharingProperties": { + "externalTablesToExclude": ["str"], + "externalTablesToInclude": ["str"], + "materializedViewsToExclude": ["str"], + "materializedViewsToInclude": ["str"], + "tablesToExclude": ["str"], + "tablesToInclude": ["str"], + }, + "type": "str", + }, + api_version="2021-06-01-preview", + ) + ).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_kusto_pool_attached_database_configurations_begin_delete(self, resource_group): + response = await ( + await self.client.kusto_pool_attached_database_configurations.begin_delete( + workspace_name="str", + kusto_pool_name="str", + attached_database_configuration_name="str", + resource_group_name=resource_group.name, + api_version="2021-06-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_child_resource_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_child_resource_operations.py new file mode 100644 index 000000000000..60e1f68e23ab --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_child_resource_operations.py @@ -0,0 +1,33 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementKustoPoolChildResourceOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_kusto_pool_child_resource_check_name_availability(self, resource_group): + response = self.client.kusto_pool_child_resource.check_name_availability( + workspace_name="str", + kusto_pool_name="str", + resource_group_name=resource_group.name, + resource_name={"name": "str", "type": "str"}, + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_child_resource_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_child_resource_operations_async.py new file mode 100644 index 000000000000..15dc3c0b3ac5 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_child_resource_operations_async.py @@ -0,0 +1,34 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementKustoPoolChildResourceOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_kusto_pool_child_resource_check_name_availability(self, resource_group): + response = await self.client.kusto_pool_child_resource.check_name_availability( + workspace_name="str", + kusto_pool_name="str", + resource_group_name=resource_group.name, + resource_name={"name": "str", "type": "str"}, + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_data_connections_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_data_connections_operations.py new file mode 100644 index 000000000000..5b5c8ed9ed3a --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_data_connections_operations.py @@ -0,0 +1,174 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementKustoPoolDataConnectionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_kusto_pool_data_connections_check_name_availability(self, resource_group): + response = self.client.kusto_pool_data_connections.check_name_availability( + resource_group_name=resource_group.name, + workspace_name="str", + kusto_pool_name="str", + database_name="str", + data_connection_name={ + "name": "str", + "type": "Microsoft.Synapse/workspaces/kustoPools/databases/dataConnections", + }, + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_kusto_pool_data_connections_begin_data_connection_validation(self, resource_group): + response = self.client.kusto_pool_data_connections.begin_data_connection_validation( + resource_group_name=resource_group.name, + workspace_name="str", + kusto_pool_name="str", + database_name="str", + parameters={"dataConnectionName": "str", "properties": "data_connection"}, + api_version="2021-06-01-preview", + ).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_kusto_pool_data_connections_list_by_database(self, resource_group): + response = self.client.kusto_pool_data_connections.list_by_database( + resource_group_name=resource_group.name, + workspace_name="str", + kusto_pool_name="str", + database_name="str", + api_version="2021-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_kusto_pool_data_connections_get(self, resource_group): + response = self.client.kusto_pool_data_connections.get( + resource_group_name=resource_group.name, + workspace_name="str", + kusto_pool_name="str", + database_name="str", + data_connection_name="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_kusto_pool_data_connections_begin_create_or_update(self, resource_group): + response = self.client.kusto_pool_data_connections.begin_create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + kusto_pool_name="str", + database_name="str", + data_connection_name="str", + parameters={ + "kind": "EventGrid", + "blobStorageEventType": "str", + "consumerGroup": "str", + "dataFormat": "str", + "eventHubResourceId": "str", + "id": "str", + "ignoreFirstRecord": bool, + "location": "str", + "mappingRuleName": "str", + "name": "str", + "provisioningState": "str", + "storageAccountResourceId": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tableName": "str", + "type": "str", + }, + api_version="2021-06-01-preview", + ).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_kusto_pool_data_connections_begin_update(self, resource_group): + response = self.client.kusto_pool_data_connections.begin_update( + resource_group_name=resource_group.name, + workspace_name="str", + kusto_pool_name="str", + database_name="str", + data_connection_name="str", + parameters={ + "kind": "EventGrid", + "blobStorageEventType": "str", + "consumerGroup": "str", + "dataFormat": "str", + "eventHubResourceId": "str", + "id": "str", + "ignoreFirstRecord": bool, + "location": "str", + "mappingRuleName": "str", + "name": "str", + "provisioningState": "str", + "storageAccountResourceId": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tableName": "str", + "type": "str", + }, + api_version="2021-06-01-preview", + ).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_kusto_pool_data_connections_begin_delete(self, resource_group): + response = self.client.kusto_pool_data_connections.begin_delete( + resource_group_name=resource_group.name, + workspace_name="str", + kusto_pool_name="str", + database_name="str", + data_connection_name="str", + api_version="2021-06-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_data_connections_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_data_connections_operations_async.py new file mode 100644 index 000000000000..dbe850c3f556 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_data_connections_operations_async.py @@ -0,0 +1,183 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementKustoPoolDataConnectionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_kusto_pool_data_connections_check_name_availability(self, resource_group): + response = await self.client.kusto_pool_data_connections.check_name_availability( + resource_group_name=resource_group.name, + workspace_name="str", + kusto_pool_name="str", + database_name="str", + data_connection_name={ + "name": "str", + "type": "Microsoft.Synapse/workspaces/kustoPools/databases/dataConnections", + }, + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_kusto_pool_data_connections_begin_data_connection_validation(self, resource_group): + response = await ( + await self.client.kusto_pool_data_connections.begin_data_connection_validation( + resource_group_name=resource_group.name, + workspace_name="str", + kusto_pool_name="str", + database_name="str", + parameters={"dataConnectionName": "str", "properties": "data_connection"}, + api_version="2021-06-01-preview", + ) + ).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_kusto_pool_data_connections_list_by_database(self, resource_group): + response = self.client.kusto_pool_data_connections.list_by_database( + resource_group_name=resource_group.name, + workspace_name="str", + kusto_pool_name="str", + database_name="str", + api_version="2021-06-01-preview", + ) + 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_kusto_pool_data_connections_get(self, resource_group): + response = await self.client.kusto_pool_data_connections.get( + resource_group_name=resource_group.name, + workspace_name="str", + kusto_pool_name="str", + database_name="str", + data_connection_name="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_kusto_pool_data_connections_begin_create_or_update(self, resource_group): + response = await ( + await self.client.kusto_pool_data_connections.begin_create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + kusto_pool_name="str", + database_name="str", + data_connection_name="str", + parameters={ + "kind": "EventGrid", + "blobStorageEventType": "str", + "consumerGroup": "str", + "dataFormat": "str", + "eventHubResourceId": "str", + "id": "str", + "ignoreFirstRecord": bool, + "location": "str", + "mappingRuleName": "str", + "name": "str", + "provisioningState": "str", + "storageAccountResourceId": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tableName": "str", + "type": "str", + }, + api_version="2021-06-01-preview", + ) + ).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_kusto_pool_data_connections_begin_update(self, resource_group): + response = await ( + await self.client.kusto_pool_data_connections.begin_update( + resource_group_name=resource_group.name, + workspace_name="str", + kusto_pool_name="str", + database_name="str", + data_connection_name="str", + parameters={ + "kind": "EventGrid", + "blobStorageEventType": "str", + "consumerGroup": "str", + "dataFormat": "str", + "eventHubResourceId": "str", + "id": "str", + "ignoreFirstRecord": bool, + "location": "str", + "mappingRuleName": "str", + "name": "str", + "provisioningState": "str", + "storageAccountResourceId": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tableName": "str", + "type": "str", + }, + api_version="2021-06-01-preview", + ) + ).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_kusto_pool_data_connections_begin_delete(self, resource_group): + response = await ( + await self.client.kusto_pool_data_connections.begin_delete( + resource_group_name=resource_group.name, + workspace_name="str", + kusto_pool_name="str", + database_name="str", + data_connection_name="str", + api_version="2021-06-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_database_principal_assignments_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_database_principal_assignments_operations.py new file mode 100644 index 000000000000..81e18c862d84 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_database_principal_assignments_operations.py @@ -0,0 +1,117 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementKustoPoolDatabasePrincipalAssignmentsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_kusto_pool_database_principal_assignments_check_name_availability(self, resource_group): + response = self.client.kusto_pool_database_principal_assignments.check_name_availability( + workspace_name="str", + kusto_pool_name="str", + database_name="str", + resource_group_name=resource_group.name, + principal_assignment_name={ + "name": "str", + "type": "Microsoft.Synapse/workspaces/kustoPools/databases/principalAssignments", + }, + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_kusto_pool_database_principal_assignments_list(self, resource_group): + response = self.client.kusto_pool_database_principal_assignments.list( + workspace_name="str", + kusto_pool_name="str", + database_name="str", + resource_group_name=resource_group.name, + api_version="2021-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_kusto_pool_database_principal_assignments_get(self, resource_group): + response = self.client.kusto_pool_database_principal_assignments.get( + workspace_name="str", + kusto_pool_name="str", + database_name="str", + principal_assignment_name="str", + resource_group_name=resource_group.name, + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_kusto_pool_database_principal_assignments_begin_create_or_update(self, resource_group): + response = self.client.kusto_pool_database_principal_assignments.begin_create_or_update( + workspace_name="str", + kusto_pool_name="str", + database_name="str", + principal_assignment_name="str", + resource_group_name=resource_group.name, + parameters={ + "aadObjectId": "str", + "id": "str", + "name": "str", + "principalId": "str", + "principalName": "str", + "principalType": "str", + "provisioningState": "str", + "role": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tenantId": "str", + "tenantName": "str", + "type": "str", + }, + api_version="2021-06-01-preview", + ).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_kusto_pool_database_principal_assignments_begin_delete(self, resource_group): + response = self.client.kusto_pool_database_principal_assignments.begin_delete( + workspace_name="str", + kusto_pool_name="str", + database_name="str", + principal_assignment_name="str", + resource_group_name=resource_group.name, + api_version="2021-06-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_database_principal_assignments_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_database_principal_assignments_operations_async.py new file mode 100644 index 000000000000..d9254126eca3 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_database_principal_assignments_operations_async.py @@ -0,0 +1,122 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementKustoPoolDatabasePrincipalAssignmentsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_kusto_pool_database_principal_assignments_check_name_availability(self, resource_group): + response = await self.client.kusto_pool_database_principal_assignments.check_name_availability( + workspace_name="str", + kusto_pool_name="str", + database_name="str", + resource_group_name=resource_group.name, + principal_assignment_name={ + "name": "str", + "type": "Microsoft.Synapse/workspaces/kustoPools/databases/principalAssignments", + }, + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_kusto_pool_database_principal_assignments_list(self, resource_group): + response = self.client.kusto_pool_database_principal_assignments.list( + workspace_name="str", + kusto_pool_name="str", + database_name="str", + resource_group_name=resource_group.name, + api_version="2021-06-01-preview", + ) + 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_kusto_pool_database_principal_assignments_get(self, resource_group): + response = await self.client.kusto_pool_database_principal_assignments.get( + workspace_name="str", + kusto_pool_name="str", + database_name="str", + principal_assignment_name="str", + resource_group_name=resource_group.name, + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_kusto_pool_database_principal_assignments_begin_create_or_update(self, resource_group): + response = await ( + await self.client.kusto_pool_database_principal_assignments.begin_create_or_update( + workspace_name="str", + kusto_pool_name="str", + database_name="str", + principal_assignment_name="str", + resource_group_name=resource_group.name, + parameters={ + "aadObjectId": "str", + "id": "str", + "name": "str", + "principalId": "str", + "principalName": "str", + "principalType": "str", + "provisioningState": "str", + "role": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tenantId": "str", + "tenantName": "str", + "type": "str", + }, + api_version="2021-06-01-preview", + ) + ).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_kusto_pool_database_principal_assignments_begin_delete(self, resource_group): + response = await ( + await self.client.kusto_pool_database_principal_assignments.begin_delete( + workspace_name="str", + kusto_pool_name="str", + database_name="str", + principal_assignment_name="str", + resource_group_name=resource_group.name, + api_version="2021-06-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_databases_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_databases_operations.py new file mode 100644 index 000000000000..ff41c78e1001 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_databases_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.synapse import SynapseManagementClient + +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 TestSynapseManagementKustoPoolDatabasesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_kusto_pool_databases_list_by_kusto_pool(self, resource_group): + response = self.client.kusto_pool_databases.list_by_kusto_pool( + resource_group_name=resource_group.name, + workspace_name="str", + kusto_pool_name="str", + api_version="2021-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_kusto_pool_databases_get(self, resource_group): + response = self.client.kusto_pool_databases.get( + resource_group_name=resource_group.name, + workspace_name="str", + kusto_pool_name="str", + database_name="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_kusto_pool_databases_begin_create_or_update(self, resource_group): + response = self.client.kusto_pool_databases.begin_create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + kusto_pool_name="str", + database_name="str", + parameters={ + "kind": "ReadOnlyFollowing", + "attachedDatabaseConfigurationName": "str", + "hotCachePeriod": "1 day, 0:00:00", + "id": "str", + "leaderClusterResourceId": "str", + "location": "str", + "name": "str", + "principalsModificationKind": "str", + "provisioningState": "str", + "softDeletePeriod": "1 day, 0:00:00", + "statistics": {"size": 0.0}, + "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="2021-06-01-preview", + ).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_kusto_pool_databases_begin_update(self, resource_group): + response = self.client.kusto_pool_databases.begin_update( + resource_group_name=resource_group.name, + workspace_name="str", + kusto_pool_name="str", + database_name="str", + parameters={ + "kind": "ReadOnlyFollowing", + "attachedDatabaseConfigurationName": "str", + "hotCachePeriod": "1 day, 0:00:00", + "id": "str", + "leaderClusterResourceId": "str", + "location": "str", + "name": "str", + "principalsModificationKind": "str", + "provisioningState": "str", + "softDeletePeriod": "1 day, 0:00:00", + "statistics": {"size": 0.0}, + "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="2021-06-01-preview", + ).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_kusto_pool_databases_begin_delete(self, resource_group): + response = self.client.kusto_pool_databases.begin_delete( + resource_group_name=resource_group.name, + workspace_name="str", + kusto_pool_name="str", + database_name="str", + api_version="2021-06-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_databases_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_databases_operations_async.py new file mode 100644 index 000000000000..aa59f5ba4972 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_databases_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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementKustoPoolDatabasesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_kusto_pool_databases_list_by_kusto_pool(self, resource_group): + response = self.client.kusto_pool_databases.list_by_kusto_pool( + resource_group_name=resource_group.name, + workspace_name="str", + kusto_pool_name="str", + api_version="2021-06-01-preview", + ) + 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_kusto_pool_databases_get(self, resource_group): + response = await self.client.kusto_pool_databases.get( + resource_group_name=resource_group.name, + workspace_name="str", + kusto_pool_name="str", + database_name="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_kusto_pool_databases_begin_create_or_update(self, resource_group): + response = await ( + await self.client.kusto_pool_databases.begin_create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + kusto_pool_name="str", + database_name="str", + parameters={ + "kind": "ReadOnlyFollowing", + "attachedDatabaseConfigurationName": "str", + "hotCachePeriod": "1 day, 0:00:00", + "id": "str", + "leaderClusterResourceId": "str", + "location": "str", + "name": "str", + "principalsModificationKind": "str", + "provisioningState": "str", + "softDeletePeriod": "1 day, 0:00:00", + "statistics": {"size": 0.0}, + "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="2021-06-01-preview", + ) + ).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_kusto_pool_databases_begin_update(self, resource_group): + response = await ( + await self.client.kusto_pool_databases.begin_update( + resource_group_name=resource_group.name, + workspace_name="str", + kusto_pool_name="str", + database_name="str", + parameters={ + "kind": "ReadOnlyFollowing", + "attachedDatabaseConfigurationName": "str", + "hotCachePeriod": "1 day, 0:00:00", + "id": "str", + "leaderClusterResourceId": "str", + "location": "str", + "name": "str", + "principalsModificationKind": "str", + "provisioningState": "str", + "softDeletePeriod": "1 day, 0:00:00", + "statistics": {"size": 0.0}, + "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="2021-06-01-preview", + ) + ).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_kusto_pool_databases_begin_delete(self, resource_group): + response = await ( + await self.client.kusto_pool_databases.begin_delete( + resource_group_name=resource_group.name, + workspace_name="str", + kusto_pool_name="str", + database_name="str", + api_version="2021-06-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_principal_assignments_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_principal_assignments_operations.py new file mode 100644 index 000000000000..d24348e92b2d --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_principal_assignments_operations.py @@ -0,0 +1,112 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementKustoPoolPrincipalAssignmentsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_kusto_pool_principal_assignments_check_name_availability(self, resource_group): + response = self.client.kusto_pool_principal_assignments.check_name_availability( + workspace_name="str", + kusto_pool_name="str", + resource_group_name=resource_group.name, + principal_assignment_name={ + "name": "str", + "type": "Microsoft.Synapse/workspaces/kustoPools/principalAssignments", + }, + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_kusto_pool_principal_assignments_list(self, resource_group): + response = self.client.kusto_pool_principal_assignments.list( + workspace_name="str", + kusto_pool_name="str", + resource_group_name=resource_group.name, + api_version="2021-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_kusto_pool_principal_assignments_get(self, resource_group): + response = self.client.kusto_pool_principal_assignments.get( + workspace_name="str", + kusto_pool_name="str", + principal_assignment_name="str", + resource_group_name=resource_group.name, + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_kusto_pool_principal_assignments_begin_create_or_update(self, resource_group): + response = self.client.kusto_pool_principal_assignments.begin_create_or_update( + workspace_name="str", + kusto_pool_name="str", + principal_assignment_name="str", + resource_group_name=resource_group.name, + parameters={ + "aadObjectId": "str", + "id": "str", + "name": "str", + "principalId": "str", + "principalName": "str", + "principalType": "str", + "provisioningState": "str", + "role": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tenantId": "str", + "tenantName": "str", + "type": "str", + }, + api_version="2021-06-01-preview", + ).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_kusto_pool_principal_assignments_begin_delete(self, resource_group): + response = self.client.kusto_pool_principal_assignments.begin_delete( + workspace_name="str", + kusto_pool_name="str", + principal_assignment_name="str", + resource_group_name=resource_group.name, + api_version="2021-06-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_principal_assignments_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_principal_assignments_operations_async.py new file mode 100644 index 000000000000..99bef4b06dea --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_principal_assignments_operations_async.py @@ -0,0 +1,117 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementKustoPoolPrincipalAssignmentsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_kusto_pool_principal_assignments_check_name_availability(self, resource_group): + response = await self.client.kusto_pool_principal_assignments.check_name_availability( + workspace_name="str", + kusto_pool_name="str", + resource_group_name=resource_group.name, + principal_assignment_name={ + "name": "str", + "type": "Microsoft.Synapse/workspaces/kustoPools/principalAssignments", + }, + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_kusto_pool_principal_assignments_list(self, resource_group): + response = self.client.kusto_pool_principal_assignments.list( + workspace_name="str", + kusto_pool_name="str", + resource_group_name=resource_group.name, + api_version="2021-06-01-preview", + ) + 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_kusto_pool_principal_assignments_get(self, resource_group): + response = await self.client.kusto_pool_principal_assignments.get( + workspace_name="str", + kusto_pool_name="str", + principal_assignment_name="str", + resource_group_name=resource_group.name, + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_kusto_pool_principal_assignments_begin_create_or_update(self, resource_group): + response = await ( + await self.client.kusto_pool_principal_assignments.begin_create_or_update( + workspace_name="str", + kusto_pool_name="str", + principal_assignment_name="str", + resource_group_name=resource_group.name, + parameters={ + "aadObjectId": "str", + "id": "str", + "name": "str", + "principalId": "str", + "principalName": "str", + "principalType": "str", + "provisioningState": "str", + "role": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tenantId": "str", + "tenantName": "str", + "type": "str", + }, + api_version="2021-06-01-preview", + ) + ).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_kusto_pool_principal_assignments_begin_delete(self, resource_group): + response = await ( + await self.client.kusto_pool_principal_assignments.begin_delete( + workspace_name="str", + kusto_pool_name="str", + principal_assignment_name="str", + resource_group_name=resource_group.name, + api_version="2021-06-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_private_link_resources_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_private_link_resources_operations.py new file mode 100644 index 000000000000..059a8c233129 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_private_link_resources_operations.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.synapse import SynapseManagementClient + +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 TestSynapseManagementKustoPoolPrivateLinkResourcesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_kusto_pool_private_link_resources_list(self, resource_group): + response = self.client.kusto_pool_private_link_resources.list( + resource_group_name=resource_group.name, + workspace_name="str", + kusto_pool_name="str", + api_version="2021-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_private_link_resources_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_private_link_resources_operations_async.py new file mode 100644 index 000000000000..780ea1f8acc7 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pool_private_link_resources_operations_async.py @@ -0,0 +1,33 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementKustoPoolPrivateLinkResourcesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_kusto_pool_private_link_resources_list(self, resource_group): + response = self.client.kusto_pool_private_link_resources.list( + resource_group_name=resource_group.name, + workspace_name="str", + kusto_pool_name="str", + api_version="2021-06-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pools_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pools_operations.py new file mode 100644 index 000000000000..585421b1d651 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pools_operations.py @@ -0,0 +1,260 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementKustoPoolsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_kusto_pools_list_skus(self, resource_group): + response = self.client.kusto_pools.list_skus( + api_version="2021-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_kusto_pools_check_name_availability(self, resource_group): + response = self.client.kusto_pools.check_name_availability( + location="str", + kusto_pool_name={"name": "str", "type": "Microsoft.Synapse/workspaces/kustoPools"}, + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_kusto_pools_list_by_workspace(self, resource_group): + response = self.client.kusto_pools.list_by_workspace( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_kusto_pools_get(self, resource_group): + response = self.client.kusto_pools.get( + workspace_name="str", + kusto_pool_name="str", + resource_group_name=resource_group.name, + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_kusto_pools_begin_create_or_update(self, resource_group): + response = self.client.kusto_pools.begin_create_or_update( + workspace_name="str", + resource_group_name=resource_group.name, + kusto_pool_name="str", + parameters={ + "location": "str", + "sku": {"name": "str", "size": "str", "capacity": 0}, + "dataIngestionUri": "str", + "enablePurge": False, + "enableStreamingIngest": False, + "etag": "str", + "id": "str", + "languageExtensions": {"value": [{"languageExtensionName": "str"}]}, + "name": "str", + "optimizedAutoscale": {"isEnabled": bool, "maximum": 0, "minimum": 0, "version": 0}, + "provisioningState": "str", + "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"}, + "type": "str", + "uri": "str", + "workspaceUID": "str", + }, + api_version="2021-06-01-preview", + ).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_kusto_pools_begin_update(self, resource_group): + response = self.client.kusto_pools.begin_update( + workspace_name="str", + resource_group_name=resource_group.name, + kusto_pool_name="str", + parameters={ + "dataIngestionUri": "str", + "enablePurge": False, + "enableStreamingIngest": False, + "id": "str", + "languageExtensions": {"value": [{"languageExtensionName": "str"}]}, + "name": "str", + "optimizedAutoscale": {"isEnabled": bool, "maximum": 0, "minimum": 0, "version": 0}, + "provisioningState": "str", + "sku": {"name": "str", "size": "str", "capacity": 0}, + "state": "str", + "stateReason": "str", + "tags": {"str": "str"}, + "type": "str", + "uri": "str", + "workspaceUID": "str", + }, + api_version="2021-06-01-preview", + ).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_kusto_pools_begin_delete(self, resource_group): + response = self.client.kusto_pools.begin_delete( + workspace_name="str", + resource_group_name=resource_group.name, + kusto_pool_name="str", + api_version="2021-06-01-preview", + ).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_kusto_pools_begin_stop(self, resource_group): + response = self.client.kusto_pools.begin_stop( + workspace_name="str", + kusto_pool_name="str", + resource_group_name=resource_group.name, + api_version="2021-06-01-preview", + ).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_kusto_pools_begin_start(self, resource_group): + response = self.client.kusto_pools.begin_start( + workspace_name="str", + kusto_pool_name="str", + resource_group_name=resource_group.name, + api_version="2021-06-01-preview", + ).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_kusto_pools_list_skus_by_resource(self, resource_group): + response = self.client.kusto_pools.list_skus_by_resource( + workspace_name="str", + kusto_pool_name="str", + resource_group_name=resource_group.name, + api_version="2021-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_kusto_pools_list_language_extensions(self, resource_group): + response = self.client.kusto_pools.list_language_extensions( + workspace_name="str", + kusto_pool_name="str", + resource_group_name=resource_group.name, + api_version="2021-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_kusto_pools_begin_add_language_extensions(self, resource_group): + response = self.client.kusto_pools.begin_add_language_extensions( + workspace_name="str", + kusto_pool_name="str", + resource_group_name=resource_group.name, + language_extensions_to_add={"value": [{"languageExtensionName": "str"}]}, + api_version="2021-06-01-preview", + ).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_kusto_pools_begin_remove_language_extensions(self, resource_group): + response = self.client.kusto_pools.begin_remove_language_extensions( + workspace_name="str", + kusto_pool_name="str", + resource_group_name=resource_group.name, + language_extensions_to_remove={"value": [{"languageExtensionName": "str"}]}, + api_version="2021-06-01-preview", + ).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_kusto_pools_list_follower_databases(self, resource_group): + response = self.client.kusto_pools.list_follower_databases( + workspace_name="str", + kusto_pool_name="str", + resource_group_name=resource_group.name, + api_version="2021-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_kusto_pools_begin_detach_follower_databases(self, resource_group): + response = self.client.kusto_pools.begin_detach_follower_databases( + workspace_name="str", + kusto_pool_name="str", + resource_group_name=resource_group.name, + follower_database_to_remove={ + "attachedDatabaseConfigurationName": "str", + "clusterResourceId": "str", + "databaseName": "str", + }, + api_version="2021-06-01-preview", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pools_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pools_operations_async.py new file mode 100644 index 000000000000..bab9e83f2604 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_kusto_pools_operations_async.py @@ -0,0 +1,277 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementKustoPoolsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_kusto_pools_list_skus(self, resource_group): + response = self.client.kusto_pools.list_skus( + api_version="2021-06-01-preview", + ) + 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_kusto_pools_check_name_availability(self, resource_group): + response = await self.client.kusto_pools.check_name_availability( + location="str", + kusto_pool_name={"name": "str", "type": "Microsoft.Synapse/workspaces/kustoPools"}, + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_kusto_pools_list_by_workspace(self, resource_group): + response = await self.client.kusto_pools.list_by_workspace( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_kusto_pools_get(self, resource_group): + response = await self.client.kusto_pools.get( + workspace_name="str", + kusto_pool_name="str", + resource_group_name=resource_group.name, + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_kusto_pools_begin_create_or_update(self, resource_group): + response = await ( + await self.client.kusto_pools.begin_create_or_update( + workspace_name="str", + resource_group_name=resource_group.name, + kusto_pool_name="str", + parameters={ + "location": "str", + "sku": {"name": "str", "size": "str", "capacity": 0}, + "dataIngestionUri": "str", + "enablePurge": False, + "enableStreamingIngest": False, + "etag": "str", + "id": "str", + "languageExtensions": {"value": [{"languageExtensionName": "str"}]}, + "name": "str", + "optimizedAutoscale": {"isEnabled": bool, "maximum": 0, "minimum": 0, "version": 0}, + "provisioningState": "str", + "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"}, + "type": "str", + "uri": "str", + "workspaceUID": "str", + }, + api_version="2021-06-01-preview", + ) + ).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_kusto_pools_begin_update(self, resource_group): + response = await ( + await self.client.kusto_pools.begin_update( + workspace_name="str", + resource_group_name=resource_group.name, + kusto_pool_name="str", + parameters={ + "dataIngestionUri": "str", + "enablePurge": False, + "enableStreamingIngest": False, + "id": "str", + "languageExtensions": {"value": [{"languageExtensionName": "str"}]}, + "name": "str", + "optimizedAutoscale": {"isEnabled": bool, "maximum": 0, "minimum": 0, "version": 0}, + "provisioningState": "str", + "sku": {"name": "str", "size": "str", "capacity": 0}, + "state": "str", + "stateReason": "str", + "tags": {"str": "str"}, + "type": "str", + "uri": "str", + "workspaceUID": "str", + }, + api_version="2021-06-01-preview", + ) + ).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_kusto_pools_begin_delete(self, resource_group): + response = await ( + await self.client.kusto_pools.begin_delete( + workspace_name="str", + resource_group_name=resource_group.name, + kusto_pool_name="str", + api_version="2021-06-01-preview", + ) + ).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_kusto_pools_begin_stop(self, resource_group): + response = await ( + await self.client.kusto_pools.begin_stop( + workspace_name="str", + kusto_pool_name="str", + resource_group_name=resource_group.name, + api_version="2021-06-01-preview", + ) + ).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_kusto_pools_begin_start(self, resource_group): + response = await ( + await self.client.kusto_pools.begin_start( + workspace_name="str", + kusto_pool_name="str", + resource_group_name=resource_group.name, + api_version="2021-06-01-preview", + ) + ).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_kusto_pools_list_skus_by_resource(self, resource_group): + response = self.client.kusto_pools.list_skus_by_resource( + workspace_name="str", + kusto_pool_name="str", + resource_group_name=resource_group.name, + api_version="2021-06-01-preview", + ) + 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_kusto_pools_list_language_extensions(self, resource_group): + response = self.client.kusto_pools.list_language_extensions( + workspace_name="str", + kusto_pool_name="str", + resource_group_name=resource_group.name, + api_version="2021-06-01-preview", + ) + 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_kusto_pools_begin_add_language_extensions(self, resource_group): + response = await ( + await self.client.kusto_pools.begin_add_language_extensions( + workspace_name="str", + kusto_pool_name="str", + resource_group_name=resource_group.name, + language_extensions_to_add={"value": [{"languageExtensionName": "str"}]}, + api_version="2021-06-01-preview", + ) + ).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_kusto_pools_begin_remove_language_extensions(self, resource_group): + response = await ( + await self.client.kusto_pools.begin_remove_language_extensions( + workspace_name="str", + kusto_pool_name="str", + resource_group_name=resource_group.name, + language_extensions_to_remove={"value": [{"languageExtensionName": "str"}]}, + api_version="2021-06-01-preview", + ) + ).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_kusto_pools_list_follower_databases(self, resource_group): + response = self.client.kusto_pools.list_follower_databases( + workspace_name="str", + kusto_pool_name="str", + resource_group_name=resource_group.name, + api_version="2021-06-01-preview", + ) + 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_kusto_pools_begin_detach_follower_databases(self, resource_group): + response = await ( + await self.client.kusto_pools.begin_detach_follower_databases( + workspace_name="str", + kusto_pool_name="str", + resource_group_name=resource_group.name, + follower_database_to_remove={ + "attachedDatabaseConfigurationName": "str", + "clusterResourceId": "str", + "databaseName": "str", + }, + api_version="2021-06-01-preview", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_libraries_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_libraries_operations.py new file mode 100644 index 000000000000..480869995cb7 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_libraries_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.synapse import SynapseManagementClient + +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 TestSynapseManagementLibrariesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_libraries_list_by_workspace(self, resource_group): + response = self.client.libraries.list_by_workspace( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_libraries_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_libraries_operations_async.py new file mode 100644 index 000000000000..37b1dfa33221 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_libraries_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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementLibrariesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_libraries_list_by_workspace(self, resource_group): + response = self.client.libraries.list_by_workspace( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_library_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_library_operations.py new file mode 100644 index 000000000000..6a1b7c66ea66 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_library_operations.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.synapse import SynapseManagementClient + +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 TestSynapseManagementLibraryOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_library_get(self, resource_group): + response = self.client.library.get( + resource_group_name=resource_group.name, + library_name="str", + workspace_name="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_library_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_library_operations_async.py new file mode 100644 index 000000000000..2132b5e0c619 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_library_operations_async.py @@ -0,0 +1,33 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementLibraryOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_library_get(self, resource_group): + response = await self.client.library.get( + resource_group_name=resource_group.name, + library_name="str", + workspace_name="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_operations.py new file mode 100644 index 000000000000..f56ba3f38d36 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_operations.py @@ -0,0 +1,64 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_operations_check_name_availability(self, resource_group): + response = self.client.operations.check_name_availability( + request={"name": "str", "type": "str"}, + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_operations_list(self, resource_group): + response = self.client.operations.list() + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_operations_get_location_header_result(self, resource_group): + response = self.client.operations.get_location_header_result( + resource_group_name=resource_group.name, + workspace_name="str", + operation_id="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_operations_get_azure_async_header_result(self, resource_group): + response = self.client.operations.get_azure_async_header_result( + resource_group_name=resource_group.name, + workspace_name="str", + operation_id="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_operations_async.py new file mode 100644 index 000000000000..7870c68606a7 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_operations_async.py @@ -0,0 +1,65 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_operations_check_name_availability(self, resource_group): + response = await self.client.operations.check_name_availability( + request={"name": "str", "type": "str"}, + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_operations_list(self, resource_group): + response = await self.client.operations.list() + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_operations_get_location_header_result(self, resource_group): + response = await self.client.operations.get_location_header_result( + resource_group_name=resource_group.name, + workspace_name="str", + operation_id="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_operations_get_azure_async_header_result(self, resource_group): + response = await self.client.operations.get_azure_async_header_result( + resource_group_name=resource_group.name, + workspace_name="str", + operation_id="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_private_endpoint_connections_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..001f06ae94fb --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_private_endpoint_connections_operations.py @@ -0,0 +1,78 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementPrivateEndpointConnectionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_endpoint_connections_get(self, resource_group): + response = self.client.private_endpoint_connections.get( + resource_group_name=resource_group.name, + workspace_name="str", + private_endpoint_connection_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_endpoint_connections_begin_create(self, resource_group): + response = self.client.private_endpoint_connections.begin_create( + resource_group_name=resource_group.name, + workspace_name="str", + private_endpoint_connection_name="str", + request={ + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": {"actionsRequired": "str", "description": "str", "status": "str"}, + "provisioningState": "str", + "type": "str", + }, + api_version="2021-06-01", + ).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_private_endpoint_connections_begin_delete(self, resource_group): + response = self.client.private_endpoint_connections.begin_delete( + resource_group_name=resource_group.name, + workspace_name="str", + private_endpoint_connection_name="str", + api_version="2021-06-01", + ).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_private_endpoint_connections_list(self, resource_group): + response = self.client.private_endpoint_connections.list( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_private_endpoint_connections_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_private_endpoint_connections_operations_async.py new file mode 100644 index 000000000000..c2427a67918b --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_private_endpoint_connections_operations_async.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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementPrivateEndpointConnectionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_endpoint_connections_get(self, resource_group): + response = await self.client.private_endpoint_connections.get( + resource_group_name=resource_group.name, + workspace_name="str", + private_endpoint_connection_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_endpoint_connections_begin_create(self, resource_group): + response = await ( + await self.client.private_endpoint_connections.begin_create( + resource_group_name=resource_group.name, + workspace_name="str", + private_endpoint_connection_name="str", + request={ + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + "type": "str", + }, + api_version="2021-06-01", + ) + ).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_private_endpoint_connections_begin_delete(self, resource_group): + response = await ( + await self.client.private_endpoint_connections.begin_delete( + resource_group_name=resource_group.name, + workspace_name="str", + private_endpoint_connection_name="str", + api_version="2021-06-01", + ) + ).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_private_endpoint_connections_list(self, resource_group): + response = self.client.private_endpoint_connections.list( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_private_endpoint_connections_private_link_hub_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_private_endpoint_connections_private_link_hub_operations.py new file mode 100644 index 000000000000..753eb12fb5ff --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_private_endpoint_connections_private_link_hub_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.synapse import SynapseManagementClient + +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 TestSynapseManagementPrivateEndpointConnectionsPrivateLinkHubOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_endpoint_connections_private_link_hub_list(self, resource_group): + response = self.client.private_endpoint_connections_private_link_hub.list( + resource_group_name=resource_group.name, + private_link_hub_name="str", + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_endpoint_connections_private_link_hub_get(self, resource_group): + response = self.client.private_endpoint_connections_private_link_hub.get( + resource_group_name=resource_group.name, + private_link_hub_name="str", + private_endpoint_connection_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_private_endpoint_connections_private_link_hub_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_private_endpoint_connections_private_link_hub_operations_async.py new file mode 100644 index 000000000000..94262a13b9f0 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_private_endpoint_connections_private_link_hub_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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementPrivateEndpointConnectionsPrivateLinkHubOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_endpoint_connections_private_link_hub_list(self, resource_group): + response = self.client.private_endpoint_connections_private_link_hub.list( + resource_group_name=resource_group.name, + private_link_hub_name="str", + api_version="2021-06-01", + ) + 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_private_endpoint_connections_private_link_hub_get(self, resource_group): + response = await self.client.private_endpoint_connections_private_link_hub.get( + resource_group_name=resource_group.name, + private_link_hub_name="str", + private_endpoint_connection_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_private_link_hub_private_link_resources_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_private_link_hub_private_link_resources_operations.py new file mode 100644 index 000000000000..7e2680aba08e --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_private_link_hub_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.synapse import SynapseManagementClient + +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 TestSynapseManagementPrivateLinkHubPrivateLinkResourcesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_link_hub_private_link_resources_list(self, resource_group): + response = self.client.private_link_hub_private_link_resources.list( + resource_group_name=resource_group.name, + private_link_hub_name="str", + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_link_hub_private_link_resources_get(self, resource_group): + response = self.client.private_link_hub_private_link_resources.get( + resource_group_name=resource_group.name, + private_link_hub_name="str", + private_link_resource_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_private_link_hub_private_link_resources_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_private_link_hub_private_link_resources_operations_async.py new file mode 100644 index 000000000000..3771755dacb1 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_private_link_hub_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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementPrivateLinkHubPrivateLinkResourcesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_link_hub_private_link_resources_list(self, resource_group): + response = self.client.private_link_hub_private_link_resources.list( + resource_group_name=resource_group.name, + private_link_hub_name="str", + api_version="2021-06-01", + ) + 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_private_link_hub_private_link_resources_get(self, resource_group): + response = await self.client.private_link_hub_private_link_resources.get( + resource_group_name=resource_group.name, + private_link_hub_name="str", + private_link_resource_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_private_link_hubs_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_private_link_hubs_operations.py new file mode 100644 index 000000000000..05fb8af2a210 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_private_link_hubs_operations.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.synapse import SynapseManagementClient + +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 TestSynapseManagementPrivateLinkHubsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_link_hubs_list_by_resource_group(self, resource_group): + response = self.client.private_link_hubs.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_link_hubs_get(self, resource_group): + response = self.client.private_link_hubs.get( + resource_group_name=resource_group.name, + private_link_hub_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_link_hubs_update(self, resource_group): + response = self.client.private_link_hubs.update( + resource_group_name=resource_group.name, + private_link_hub_name="str", + private_link_hub_patch_info={"tags": {"str": "str"}}, + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_link_hubs_create_or_update(self, resource_group): + response = self.client.private_link_hubs.create_or_update( + resource_group_name=resource_group.name, + private_link_hub_name="str", + private_link_hub_info={ + "location": "str", + "id": "str", + "name": "str", + "privateEndpointConnections": [ + { + "id": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + } + ], + "provisioningState": "str", + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_link_hubs_begin_delete(self, resource_group): + response = self.client.private_link_hubs.begin_delete( + resource_group_name=resource_group.name, + private_link_hub_name="str", + api_version="2021-06-01", + ).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_private_link_hubs_list(self, resource_group): + response = self.client.private_link_hubs.list( + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_private_link_hubs_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_private_link_hubs_operations_async.py new file mode 100644 index 000000000000..1dface52a258 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_private_link_hubs_operations_async.py @@ -0,0 +1,112 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementPrivateLinkHubsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_link_hubs_list_by_resource_group(self, resource_group): + response = self.client.private_link_hubs.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2021-06-01", + ) + 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_private_link_hubs_get(self, resource_group): + response = await self.client.private_link_hubs.get( + resource_group_name=resource_group.name, + private_link_hub_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_link_hubs_update(self, resource_group): + response = await self.client.private_link_hubs.update( + resource_group_name=resource_group.name, + private_link_hub_name="str", + private_link_hub_patch_info={"tags": {"str": "str"}}, + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_link_hubs_create_or_update(self, resource_group): + response = await self.client.private_link_hubs.create_or_update( + resource_group_name=resource_group.name, + private_link_hub_name="str", + private_link_hub_info={ + "location": "str", + "id": "str", + "name": "str", + "privateEndpointConnections": [ + { + "id": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + } + ], + "provisioningState": "str", + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_link_hubs_begin_delete(self, resource_group): + response = await ( + await self.client.private_link_hubs.begin_delete( + resource_group_name=resource_group.name, + private_link_hub_name="str", + api_version="2021-06-01", + ) + ).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_private_link_hubs_list(self, resource_group): + response = self.client.private_link_hubs.list( + api_version="2021-06-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_private_link_resources_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_private_link_resources_operations.py new file mode 100644 index 000000000000..7f97df171603 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_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.synapse import SynapseManagementClient + +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 TestSynapseManagementPrivateLinkResourcesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_link_resources_list(self, resource_group): + response = self.client.private_link_resources.list( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_link_resources_get(self, resource_group): + response = self.client.private_link_resources.get( + resource_group_name=resource_group.name, + workspace_name="str", + private_link_resource_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_private_link_resources_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_private_link_resources_operations_async.py new file mode 100644 index 000000000000..32c07d47d34f --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementPrivateLinkResourcesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_link_resources_list(self, resource_group): + response = self.client.private_link_resources.list( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + 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_private_link_resources_get(self, resource_group): + response = await self.client.private_link_resources.get( + resource_group_name=resource_group.name, + workspace_name="str", + private_link_resource_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_restorable_dropped_sql_pools_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_restorable_dropped_sql_pools_operations.py new file mode 100644 index 000000000000..2f76a54818ca --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_restorable_dropped_sql_pools_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.synapse import SynapseManagementClient + +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 TestSynapseManagementRestorableDroppedSqlPoolsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_restorable_dropped_sql_pools_get(self, resource_group): + response = self.client.restorable_dropped_sql_pools.get( + resource_group_name=resource_group.name, + workspace_name="str", + restorable_dropped_sql_pool_id="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_restorable_dropped_sql_pools_list_by_workspace(self, resource_group): + response = self.client.restorable_dropped_sql_pools.list_by_workspace( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_restorable_dropped_sql_pools_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_restorable_dropped_sql_pools_operations_async.py new file mode 100644 index 000000000000..ce758d2176dc --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_restorable_dropped_sql_pools_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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementRestorableDroppedSqlPoolsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_restorable_dropped_sql_pools_get(self, resource_group): + response = await self.client.restorable_dropped_sql_pools.get( + resource_group_name=resource_group.name, + workspace_name="str", + restorable_dropped_sql_pool_id="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_restorable_dropped_sql_pools_list_by_workspace(self, resource_group): + response = self.client.restorable_dropped_sql_pools.list_by_workspace( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_spark_configuration_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_spark_configuration_operations.py new file mode 100644 index 000000000000..d9f5a4e3998c --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_spark_configuration_operations.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.synapse import SynapseManagementClient + +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 TestSynapseManagementSparkConfigurationOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_spark_configuration_get(self, resource_group): + response = self.client.spark_configuration.get( + resource_group_name=resource_group.name, + spark_configuration_name="str", + workspace_name="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_spark_configuration_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_spark_configuration_operations_async.py new file mode 100644 index 000000000000..bf5153e39dfe --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_spark_configuration_operations_async.py @@ -0,0 +1,33 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementSparkConfigurationOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_spark_configuration_get(self, resource_group): + response = await self.client.spark_configuration.get( + resource_group_name=resource_group.name, + spark_configuration_name="str", + workspace_name="str", + api_version="2021-06-01-preview", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_spark_configurations_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_spark_configurations_operations.py new file mode 100644 index 000000000000..8a9a3cebd6a0 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_spark_configurations_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.synapse import SynapseManagementClient + +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 TestSynapseManagementSparkConfigurationsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_spark_configurations_list_by_workspace(self, resource_group): + response = self.client.spark_configurations.list_by_workspace( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_spark_configurations_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_spark_configurations_operations_async.py new file mode 100644 index 000000000000..8e961e7e2c81 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_spark_configurations_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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementSparkConfigurationsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_spark_configurations_list_by_workspace(self, resource_group): + response = self.client.spark_configurations.list_by_workspace( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_blob_auditing_policies_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_blob_auditing_policies_operations.py new file mode 100644 index 000000000000..6adf0afaeb93 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_blob_auditing_policies_operations.py @@ -0,0 +1,74 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementSqlPoolBlobAuditingPoliciesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_blob_auditing_policies_get(self, resource_group): + response = self.client.sql_pool_blob_auditing_policies.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + blob_auditing_policy_name="default", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_blob_auditing_policies_create_or_update(self, resource_group): + response = self.client.sql_pool_blob_auditing_policies.create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + parameters={ + "auditActionsAndGroups": ["str"], + "id": "str", + "isAzureMonitorTargetEnabled": False, + "isStorageSecondaryKeyInUse": bool, + "kind": "str", + "name": "str", + "retentionDays": 0, + "state": "str", + "storageAccountAccessKey": "str", + "storageAccountSubscriptionId": "str", + "storageEndpoint": "str", + "type": "str", + }, + api_version="2021-06-01", + blob_auditing_policy_name="default", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_blob_auditing_policies_list_by_sql_pool(self, resource_group): + response = self.client.sql_pool_blob_auditing_policies.list_by_sql_pool( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_blob_auditing_policies_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_blob_auditing_policies_operations_async.py new file mode 100644 index 000000000000..8287733edda3 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_blob_auditing_policies_operations_async.py @@ -0,0 +1,75 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementSqlPoolBlobAuditingPoliciesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_blob_auditing_policies_get(self, resource_group): + response = await self.client.sql_pool_blob_auditing_policies.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + blob_auditing_policy_name="default", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_blob_auditing_policies_create_or_update(self, resource_group): + response = await self.client.sql_pool_blob_auditing_policies.create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + parameters={ + "auditActionsAndGroups": ["str"], + "id": "str", + "isAzureMonitorTargetEnabled": False, + "isStorageSecondaryKeyInUse": bool, + "kind": "str", + "name": "str", + "retentionDays": 0, + "state": "str", + "storageAccountAccessKey": "str", + "storageAccountSubscriptionId": "str", + "storageEndpoint": "str", + "type": "str", + }, + api_version="2021-06-01", + blob_auditing_policy_name="default", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_blob_auditing_policies_list_by_sql_pool(self, resource_group): + response = self.client.sql_pool_blob_auditing_policies.list_by_sql_pool( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_columns_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_columns_operations.py new file mode 100644 index 000000000000..2213225a1ef5 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_columns_operations.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 pytest +from azure.mgmt.synapse import SynapseManagementClient + +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 TestSynapseManagementSqlPoolColumnsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_columns_get(self, resource_group): + response = self.client.sql_pool_columns.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + schema_name="str", + table_name="str", + column_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_columns_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_columns_operations_async.py new file mode 100644 index 000000000000..05bc5560029f --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_columns_operations_async.py @@ -0,0 +1,36 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementSqlPoolColumnsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_columns_get(self, resource_group): + response = await self.client.sql_pool_columns.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + schema_name="str", + table_name="str", + column_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_connection_policies_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_connection_policies_operations.py new file mode 100644 index 000000000000..d2af3b360bd1 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_connection_policies_operations.py @@ -0,0 +1,33 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementSqlPoolConnectionPoliciesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_connection_policies_get(self, resource_group): + response = self.client.sql_pool_connection_policies.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + connection_policy_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_connection_policies_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_connection_policies_operations_async.py new file mode 100644 index 000000000000..419948eb52b7 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_connection_policies_operations_async.py @@ -0,0 +1,34 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementSqlPoolConnectionPoliciesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_connection_policies_get(self, resource_group): + response = await self.client.sql_pool_connection_policies.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + connection_policy_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_data_warehouse_user_activities_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_data_warehouse_user_activities_operations.py new file mode 100644 index 000000000000..1d41452fffd7 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_data_warehouse_user_activities_operations.py @@ -0,0 +1,33 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementSqlPoolDataWarehouseUserActivitiesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_data_warehouse_user_activities_get(self, resource_group): + response = self.client.sql_pool_data_warehouse_user_activities.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + data_warehouse_user_activity_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_data_warehouse_user_activities_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_data_warehouse_user_activities_operations_async.py new file mode 100644 index 000000000000..77af0ace0ef0 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_data_warehouse_user_activities_operations_async.py @@ -0,0 +1,34 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementSqlPoolDataWarehouseUserActivitiesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_data_warehouse_user_activities_get(self, resource_group): + response = await self.client.sql_pool_data_warehouse_user_activities.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + data_warehouse_user_activity_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_geo_backup_policies_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_geo_backup_policies_operations.py new file mode 100644 index 000000000000..6f627a0b6230 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_geo_backup_policies_operations.py @@ -0,0 +1,69 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementSqlPoolGeoBackupPoliciesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_geo_backup_policies_list(self, resource_group): + response = self.client.sql_pool_geo_backup_policies.list( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_geo_backup_policies_create_or_update(self, resource_group): + response = self.client.sql_pool_geo_backup_policies.create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + geo_backup_policy_name="str", + parameters={ + "state": "str", + "id": "str", + "kind": "str", + "location": "str", + "name": "str", + "storageType": "str", + "type": "str", + }, + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_geo_backup_policies_get(self, resource_group): + response = self.client.sql_pool_geo_backup_policies.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + geo_backup_policy_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_geo_backup_policies_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_geo_backup_policies_operations_async.py new file mode 100644 index 000000000000..27c5224a24fc --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_geo_backup_policies_operations_async.py @@ -0,0 +1,70 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementSqlPoolGeoBackupPoliciesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_geo_backup_policies_list(self, resource_group): + response = self.client.sql_pool_geo_backup_policies.list( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ) + 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_sql_pool_geo_backup_policies_create_or_update(self, resource_group): + response = await self.client.sql_pool_geo_backup_policies.create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + geo_backup_policy_name="str", + parameters={ + "state": "str", + "id": "str", + "kind": "str", + "location": "str", + "name": "str", + "storageType": "str", + "type": "str", + }, + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_geo_backup_policies_get(self, resource_group): + response = await self.client.sql_pool_geo_backup_policies.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + geo_backup_policy_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_maintenance_window_options_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_maintenance_window_options_operations.py new file mode 100644 index 000000000000..b0d811bf74d5 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_maintenance_window_options_operations.py @@ -0,0 +1,33 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementSqlPoolMaintenanceWindowOptionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_maintenance_window_options_get(self, resource_group): + response = self.client.sql_pool_maintenance_window_options.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + maintenance_window_options_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_maintenance_window_options_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_maintenance_window_options_operations_async.py new file mode 100644 index 000000000000..ed94a02a6525 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_maintenance_window_options_operations_async.py @@ -0,0 +1,34 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementSqlPoolMaintenanceWindowOptionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_maintenance_window_options_get(self, resource_group): + response = await self.client.sql_pool_maintenance_window_options.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + maintenance_window_options_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_maintenance_windows_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_maintenance_windows_operations.py new file mode 100644 index 000000000000..f7259ea694ef --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_maintenance_windows_operations.py @@ -0,0 +1,53 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementSqlPoolMaintenanceWindowsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_maintenance_windows_get(self, resource_group): + response = self.client.sql_pool_maintenance_windows.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + maintenance_window_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_maintenance_windows_create_or_update(self, resource_group): + response = self.client.sql_pool_maintenance_windows.create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + maintenance_window_name="str", + parameters={ + "id": "str", + "name": "str", + "timeRanges": [{"dayOfWeek": "str", "duration": "str", "startTime": "str"}], + "type": "str", + }, + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_maintenance_windows_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_maintenance_windows_operations_async.py new file mode 100644 index 000000000000..75e5e4629250 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_maintenance_windows_operations_async.py @@ -0,0 +1,54 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementSqlPoolMaintenanceWindowsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_maintenance_windows_get(self, resource_group): + response = await self.client.sql_pool_maintenance_windows.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + maintenance_window_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_maintenance_windows_create_or_update(self, resource_group): + response = await self.client.sql_pool_maintenance_windows.create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + maintenance_window_name="str", + parameters={ + "id": "str", + "name": "str", + "timeRanges": [{"dayOfWeek": "str", "duration": "str", "startTime": "str"}], + "type": "str", + }, + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_metadata_sync_configs_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_metadata_sync_configs_operations.py new file mode 100644 index 000000000000..354d563bca33 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_metadata_sync_configs_operations.py @@ -0,0 +1,52 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementSqlPoolMetadataSyncConfigsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_metadata_sync_configs_get(self, resource_group): + response = self.client.sql_pool_metadata_sync_configs.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_metadata_sync_configs_create(self, resource_group): + response = self.client.sql_pool_metadata_sync_configs.create( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + metadata_sync_configuration={ + "enabled": bool, + "id": "str", + "name": "str", + "syncIntervalInMinutes": 0, + "type": "str", + }, + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_metadata_sync_configs_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_metadata_sync_configs_operations_async.py new file mode 100644 index 000000000000..2e17fe7008c4 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_metadata_sync_configs_operations_async.py @@ -0,0 +1,53 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementSqlPoolMetadataSyncConfigsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_metadata_sync_configs_get(self, resource_group): + response = await self.client.sql_pool_metadata_sync_configs.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_metadata_sync_configs_create(self, resource_group): + response = await self.client.sql_pool_metadata_sync_configs.create( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + metadata_sync_configuration={ + "enabled": bool, + "id": "str", + "name": "str", + "syncIntervalInMinutes": 0, + "type": "str", + }, + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_operation_results_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_operation_results_operations.py new file mode 100644 index 000000000000..a6aaeb8eaedb --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_operation_results_operations.py @@ -0,0 +1,33 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementSqlPoolOperationResultsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_operation_results_get_location_header_result(self, resource_group): + response = self.client.sql_pool_operation_results.get_location_header_result( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + operation_id="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_operation_results_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_operation_results_operations_async.py new file mode 100644 index 000000000000..128297c87f03 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_operation_results_operations_async.py @@ -0,0 +1,34 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementSqlPoolOperationResultsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_operation_results_get_location_header_result(self, resource_group): + response = await self.client.sql_pool_operation_results.get_location_header_result( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + operation_id="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_operations_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_operations_operations.py new file mode 100644 index 000000000000..81a15f379127 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_operations_operations.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.synapse import SynapseManagementClient + +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 TestSynapseManagementSqlPoolOperationsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_operations_list(self, resource_group): + response = self.client.sql_pool_operations.list( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_operations_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_operations_operations_async.py new file mode 100644 index 000000000000..53cc9ac2e4ce --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_operations_operations_async.py @@ -0,0 +1,33 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementSqlPoolOperationsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_operations_list(self, resource_group): + response = self.client.sql_pool_operations.list( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_recommended_sensitivity_labels_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_recommended_sensitivity_labels_operations.py new file mode 100644 index 000000000000..e73f66bd97fe --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_recommended_sensitivity_labels_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.synapse import SynapseManagementClient + +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 TestSynapseManagementSqlPoolRecommendedSensitivityLabelsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_recommended_sensitivity_labels_update(self, resource_group): + response = self.client.sql_pool_recommended_sensitivity_labels.update( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + parameters={ + "operations": [ + { + "column": "str", + "id": "str", + "name": "str", + "op": "str", + "schema": "str", + "table": "str", + "type": "str", + } + ] + }, + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_recommended_sensitivity_labels_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_recommended_sensitivity_labels_operations_async.py new file mode 100644 index 000000000000..c1a42a302431 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_recommended_sensitivity_labels_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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementSqlPoolRecommendedSensitivityLabelsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_recommended_sensitivity_labels_update(self, resource_group): + response = await self.client.sql_pool_recommended_sensitivity_labels.update( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + parameters={ + "operations": [ + { + "column": "str", + "id": "str", + "name": "str", + "op": "str", + "schema": "str", + "table": "str", + "type": "str", + } + ] + }, + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_replication_links_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_replication_links_operations.py new file mode 100644 index 000000000000..bb6cc179b86d --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_replication_links_operations.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.synapse import SynapseManagementClient + +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 TestSynapseManagementSqlPoolReplicationLinksOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_replication_links_list(self, resource_group): + response = self.client.sql_pool_replication_links.list( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_replication_links_get_by_name(self, resource_group): + response = self.client.sql_pool_replication_links.get_by_name( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + link_id="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_replication_links_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_replication_links_operations_async.py new file mode 100644 index 000000000000..76227bd35be5 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_replication_links_operations_async.py @@ -0,0 +1,47 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementSqlPoolReplicationLinksOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_replication_links_list(self, resource_group): + response = self.client.sql_pool_replication_links.list( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ) + 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_sql_pool_replication_links_get_by_name(self, resource_group): + response = await self.client.sql_pool_replication_links.get_by_name( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + link_id="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_restore_points_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_restore_points_operations.py new file mode 100644 index 000000000000..6b88da061c93 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_restore_points_operations.py @@ -0,0 +1,74 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementSqlPoolRestorePointsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_restore_points_list(self, resource_group): + response = self.client.sql_pool_restore_points.list( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_restore_points_begin_create(self, resource_group): + response = self.client.sql_pool_restore_points.begin_create( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + parameters={"restorePointLabel": "str"}, + api_version="2021-06-01", + ).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_sql_pool_restore_points_get(self, resource_group): + response = self.client.sql_pool_restore_points.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + restore_point_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_restore_points_delete(self, resource_group): + response = self.client.sql_pool_restore_points.delete( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + restore_point_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_restore_points_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_restore_points_operations_async.py new file mode 100644 index 000000000000..427d32033e4e --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_restore_points_operations_async.py @@ -0,0 +1,77 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementSqlPoolRestorePointsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_restore_points_list(self, resource_group): + response = self.client.sql_pool_restore_points.list( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ) + 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_sql_pool_restore_points_begin_create(self, resource_group): + response = await ( + await self.client.sql_pool_restore_points.begin_create( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + parameters={"restorePointLabel": "str"}, + api_version="2021-06-01", + ) + ).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_sql_pool_restore_points_get(self, resource_group): + response = await self.client.sql_pool_restore_points.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + restore_point_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_restore_points_delete(self, resource_group): + response = await self.client.sql_pool_restore_points.delete( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + restore_point_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_schemas_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_schemas_operations.py new file mode 100644 index 000000000000..a25909ded268 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_schemas_operations.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.synapse import SynapseManagementClient + +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 TestSynapseManagementSqlPoolSchemasOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_schemas_list(self, resource_group): + response = self.client.sql_pool_schemas.list( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_schemas_get(self, resource_group): + response = self.client.sql_pool_schemas.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + schema_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_schemas_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_schemas_operations_async.py new file mode 100644 index 000000000000..c0322bba58bd --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_schemas_operations_async.py @@ -0,0 +1,47 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementSqlPoolSchemasOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_schemas_list(self, resource_group): + response = self.client.sql_pool_schemas.list( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ) + 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_sql_pool_schemas_get(self, resource_group): + response = await self.client.sql_pool_schemas.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + schema_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_security_alert_policies_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_security_alert_policies_operations.py new file mode 100644 index 000000000000..afcb386f0caf --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_security_alert_policies_operations.py @@ -0,0 +1,73 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementSqlPoolSecurityAlertPoliciesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_security_alert_policies_list(self, resource_group): + response = self.client.sql_pool_security_alert_policies.list( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_security_alert_policies_get(self, resource_group): + response = self.client.sql_pool_security_alert_policies.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + security_alert_policy_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_security_alert_policies_create_or_update(self, resource_group): + response = self.client.sql_pool_security_alert_policies.create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + security_alert_policy_name="str", + parameters={ + "creationTime": "2020-02-20 00:00:00", + "disabledAlerts": ["str"], + "emailAccountAdmins": bool, + "emailAddresses": ["str"], + "id": "str", + "name": "str", + "retentionDays": 0, + "state": "str", + "storageAccountAccessKey": "str", + "storageEndpoint": "str", + "type": "str", + }, + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_security_alert_policies_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_security_alert_policies_operations_async.py new file mode 100644 index 000000000000..100b48d80a99 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_security_alert_policies_operations_async.py @@ -0,0 +1,74 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementSqlPoolSecurityAlertPoliciesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_security_alert_policies_list(self, resource_group): + response = self.client.sql_pool_security_alert_policies.list( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ) + 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_sql_pool_security_alert_policies_get(self, resource_group): + response = await self.client.sql_pool_security_alert_policies.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + security_alert_policy_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_security_alert_policies_create_or_update(self, resource_group): + response = await self.client.sql_pool_security_alert_policies.create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + security_alert_policy_name="str", + parameters={ + "creationTime": "2020-02-20 00:00:00", + "disabledAlerts": ["str"], + "emailAccountAdmins": bool, + "emailAddresses": ["str"], + "id": "str", + "name": "str", + "retentionDays": 0, + "state": "str", + "storageAccountAccessKey": "str", + "storageEndpoint": "str", + "type": "str", + }, + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_sensitivity_labels_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_sensitivity_labels_operations.py new file mode 100644 index 000000000000..a165923876d3 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_sensitivity_labels_operations.py @@ -0,0 +1,186 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementSqlPoolSensitivityLabelsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_sensitivity_labels_list_current(self, resource_group): + response = self.client.sql_pool_sensitivity_labels.list_current( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_sensitivity_labels_update(self, resource_group): + response = self.client.sql_pool_sensitivity_labels.update( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + parameters={ + "operations": [ + { + "column": "str", + "id": "str", + "name": "str", + "op": "str", + "schema": "str", + "sensitivityLabel": { + "columnName": "str", + "id": "str", + "informationType": "str", + "informationTypeId": "str", + "isDisabled": bool, + "labelId": "str", + "labelName": "str", + "managedBy": "str", + "name": "str", + "rank": "str", + "schemaName": "str", + "tableName": "str", + "type": "str", + }, + "table": "str", + "type": "str", + } + ] + }, + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_sensitivity_labels_list_recommended(self, resource_group): + response = self.client.sql_pool_sensitivity_labels.list_recommended( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_sensitivity_labels_create_or_update(self, resource_group): + response = self.client.sql_pool_sensitivity_labels.create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + schema_name="str", + table_name="str", + column_name="str", + parameters={ + "columnName": "str", + "id": "str", + "informationType": "str", + "informationTypeId": "str", + "isDisabled": bool, + "labelId": "str", + "labelName": "str", + "managedBy": "str", + "name": "str", + "rank": "str", + "schemaName": "str", + "tableName": "str", + "type": "str", + }, + api_version="2021-06-01", + sensitivity_label_source="current", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_sensitivity_labels_delete(self, resource_group): + response = self.client.sql_pool_sensitivity_labels.delete( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + schema_name="str", + table_name="str", + column_name="str", + api_version="2021-06-01", + sensitivity_label_source="current", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_sensitivity_labels_get(self, resource_group): + response = self.client.sql_pool_sensitivity_labels.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + schema_name="str", + table_name="str", + column_name="str", + sensitivity_label_source="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_sensitivity_labels_enable_recommendation(self, resource_group): + response = self.client.sql_pool_sensitivity_labels.enable_recommendation( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + schema_name="str", + table_name="str", + column_name="str", + api_version="2021-06-01", + sensitivity_label_source="recommended", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_sensitivity_labels_disable_recommendation(self, resource_group): + response = self.client.sql_pool_sensitivity_labels.disable_recommendation( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + schema_name="str", + table_name="str", + column_name="str", + api_version="2021-06-01", + sensitivity_label_source="recommended", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_sensitivity_labels_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_sensitivity_labels_operations_async.py new file mode 100644 index 000000000000..5d882fa9b198 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_sensitivity_labels_operations_async.py @@ -0,0 +1,187 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementSqlPoolSensitivityLabelsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_sensitivity_labels_list_current(self, resource_group): + response = self.client.sql_pool_sensitivity_labels.list_current( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ) + 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_sql_pool_sensitivity_labels_update(self, resource_group): + response = await self.client.sql_pool_sensitivity_labels.update( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + parameters={ + "operations": [ + { + "column": "str", + "id": "str", + "name": "str", + "op": "str", + "schema": "str", + "sensitivityLabel": { + "columnName": "str", + "id": "str", + "informationType": "str", + "informationTypeId": "str", + "isDisabled": bool, + "labelId": "str", + "labelName": "str", + "managedBy": "str", + "name": "str", + "rank": "str", + "schemaName": "str", + "tableName": "str", + "type": "str", + }, + "table": "str", + "type": "str", + } + ] + }, + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_sensitivity_labels_list_recommended(self, resource_group): + response = self.client.sql_pool_sensitivity_labels.list_recommended( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ) + 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_sql_pool_sensitivity_labels_create_or_update(self, resource_group): + response = await self.client.sql_pool_sensitivity_labels.create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + schema_name="str", + table_name="str", + column_name="str", + parameters={ + "columnName": "str", + "id": "str", + "informationType": "str", + "informationTypeId": "str", + "isDisabled": bool, + "labelId": "str", + "labelName": "str", + "managedBy": "str", + "name": "str", + "rank": "str", + "schemaName": "str", + "tableName": "str", + "type": "str", + }, + api_version="2021-06-01", + sensitivity_label_source="current", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_sensitivity_labels_delete(self, resource_group): + response = await self.client.sql_pool_sensitivity_labels.delete( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + schema_name="str", + table_name="str", + column_name="str", + api_version="2021-06-01", + sensitivity_label_source="current", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_sensitivity_labels_get(self, resource_group): + response = await self.client.sql_pool_sensitivity_labels.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + schema_name="str", + table_name="str", + column_name="str", + sensitivity_label_source="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_sensitivity_labels_enable_recommendation(self, resource_group): + response = await self.client.sql_pool_sensitivity_labels.enable_recommendation( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + schema_name="str", + table_name="str", + column_name="str", + api_version="2021-06-01", + sensitivity_label_source="recommended", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_sensitivity_labels_disable_recommendation(self, resource_group): + response = await self.client.sql_pool_sensitivity_labels.disable_recommendation( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + schema_name="str", + table_name="str", + column_name="str", + api_version="2021-06-01", + sensitivity_label_source="recommended", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_table_columns_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_table_columns_operations.py new file mode 100644 index 000000000000..686c7ef4d585 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_table_columns_operations.py @@ -0,0 +1,34 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementSqlPoolTableColumnsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_table_columns_list_by_table_name(self, resource_group): + response = self.client.sql_pool_table_columns.list_by_table_name( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + schema_name="str", + table_name="str", + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_table_columns_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_table_columns_operations_async.py new file mode 100644 index 000000000000..bb66274ab992 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_table_columns_operations_async.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 pytest +from azure.mgmt.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementSqlPoolTableColumnsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_table_columns_list_by_table_name(self, resource_group): + response = self.client.sql_pool_table_columns.list_by_table_name( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + schema_name="str", + table_name="str", + api_version="2021-06-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_tables_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_tables_operations.py new file mode 100644 index 000000000000..2303c73667d8 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_tables_operations.py @@ -0,0 +1,48 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementSqlPoolTablesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_tables_list_by_schema(self, resource_group): + response = self.client.sql_pool_tables.list_by_schema( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + schema_name="str", + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_tables_get(self, resource_group): + response = self.client.sql_pool_tables.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + schema_name="str", + table_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_tables_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_tables_operations_async.py new file mode 100644 index 000000000000..498b565dd291 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_tables_operations_async.py @@ -0,0 +1,49 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementSqlPoolTablesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_tables_list_by_schema(self, resource_group): + response = self.client.sql_pool_tables.list_by_schema( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + schema_name="str", + api_version="2021-06-01", + ) + 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_sql_pool_tables_get(self, resource_group): + response = await self.client.sql_pool_tables.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + schema_name="str", + table_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_transparent_data_encryptions_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_transparent_data_encryptions_operations.py new file mode 100644 index 000000000000..36252a63a2c2 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_transparent_data_encryptions_operations.py @@ -0,0 +1,61 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementSqlPoolTransparentDataEncryptionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_transparent_data_encryptions_get(self, resource_group): + response = self.client.sql_pool_transparent_data_encryptions.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + transparent_data_encryption_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_transparent_data_encryptions_create_or_update(self, resource_group): + response = self.client.sql_pool_transparent_data_encryptions.create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + transparent_data_encryption_name="str", + parameters={"id": "str", "location": "str", "name": "str", "status": "str", "type": "str"}, + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_transparent_data_encryptions_list(self, resource_group): + response = self.client.sql_pool_transparent_data_encryptions.list( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_transparent_data_encryptions_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_transparent_data_encryptions_operations_async.py new file mode 100644 index 000000000000..f45454fb67a0 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_transparent_data_encryptions_operations_async.py @@ -0,0 +1,62 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementSqlPoolTransparentDataEncryptionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_transparent_data_encryptions_get(self, resource_group): + response = await self.client.sql_pool_transparent_data_encryptions.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + transparent_data_encryption_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_transparent_data_encryptions_create_or_update(self, resource_group): + response = await self.client.sql_pool_transparent_data_encryptions.create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + transparent_data_encryption_name="str", + parameters={"id": "str", "location": "str", "name": "str", "status": "str", "type": "str"}, + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_transparent_data_encryptions_list(self, resource_group): + response = self.client.sql_pool_transparent_data_encryptions.list( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_usages_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_usages_operations.py new file mode 100644 index 000000000000..4bfe80e2312a --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_usages_operations.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.synapse import SynapseManagementClient + +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 TestSynapseManagementSqlPoolUsagesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_usages_list(self, resource_group): + response = self.client.sql_pool_usages.list( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_usages_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_usages_operations_async.py new file mode 100644 index 000000000000..55e6a9f4e701 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_usages_operations_async.py @@ -0,0 +1,33 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementSqlPoolUsagesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_usages_list(self, resource_group): + response = self.client.sql_pool_usages.list( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_vulnerability_assessment_rule_baselines_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_vulnerability_assessment_rule_baselines_operations.py new file mode 100644 index 000000000000..07e8f7c48a82 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_vulnerability_assessment_rule_baselines_operations.py @@ -0,0 +1,68 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementSqlPoolVulnerabilityAssessmentRuleBaselinesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_vulnerability_assessment_rule_baselines_create_or_update(self, resource_group): + response = self.client.sql_pool_vulnerability_assessment_rule_baselines.create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + vulnerability_assessment_name="str", + rule_id="str", + baseline_name="str", + parameters={"baselineResults": [{"result": ["str"]}], "id": "str", "name": "str", "type": "str"}, + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_vulnerability_assessment_rule_baselines_delete(self, resource_group): + response = self.client.sql_pool_vulnerability_assessment_rule_baselines.delete( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + vulnerability_assessment_name="str", + rule_id="str", + baseline_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_vulnerability_assessment_rule_baselines_get(self, resource_group): + response = self.client.sql_pool_vulnerability_assessment_rule_baselines.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + vulnerability_assessment_name="str", + rule_id="str", + baseline_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_vulnerability_assessment_rule_baselines_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_vulnerability_assessment_rule_baselines_operations_async.py new file mode 100644 index 000000000000..8ad0ea575aae --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_vulnerability_assessment_rule_baselines_operations_async.py @@ -0,0 +1,69 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementSqlPoolVulnerabilityAssessmentRuleBaselinesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_vulnerability_assessment_rule_baselines_create_or_update(self, resource_group): + response = await self.client.sql_pool_vulnerability_assessment_rule_baselines.create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + vulnerability_assessment_name="str", + rule_id="str", + baseline_name="str", + parameters={"baselineResults": [{"result": ["str"]}], "id": "str", "name": "str", "type": "str"}, + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_vulnerability_assessment_rule_baselines_delete(self, resource_group): + response = await self.client.sql_pool_vulnerability_assessment_rule_baselines.delete( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + vulnerability_assessment_name="str", + rule_id="str", + baseline_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_vulnerability_assessment_rule_baselines_get(self, resource_group): + response = await self.client.sql_pool_vulnerability_assessment_rule_baselines.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + vulnerability_assessment_name="str", + rule_id="str", + baseline_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_vulnerability_assessment_scans_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_vulnerability_assessment_scans_operations.py new file mode 100644 index 000000000000..604faa273837 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_vulnerability_assessment_scans_operations.py @@ -0,0 +1,78 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementSqlPoolVulnerabilityAssessmentScansOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_vulnerability_assessment_scans_list(self, resource_group): + response = self.client.sql_pool_vulnerability_assessment_scans.list( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + vulnerability_assessment_name="str", + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_vulnerability_assessment_scans_begin_initiate_scan(self, resource_group): + response = self.client.sql_pool_vulnerability_assessment_scans.begin_initiate_scan( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + vulnerability_assessment_name="str", + scan_id="str", + api_version="2021-06-01", + ).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_sql_pool_vulnerability_assessment_scans_export(self, resource_group): + response = self.client.sql_pool_vulnerability_assessment_scans.export( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + vulnerability_assessment_name="str", + scan_id="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_vulnerability_assessment_scans_get(self, resource_group): + response = self.client.sql_pool_vulnerability_assessment_scans.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + vulnerability_assessment_name="str", + scan_id="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_vulnerability_assessment_scans_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_vulnerability_assessment_scans_operations_async.py new file mode 100644 index 000000000000..445518d58ec7 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_vulnerability_assessment_scans_operations_async.py @@ -0,0 +1,81 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementSqlPoolVulnerabilityAssessmentScansOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_vulnerability_assessment_scans_list(self, resource_group): + response = self.client.sql_pool_vulnerability_assessment_scans.list( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + vulnerability_assessment_name="str", + api_version="2021-06-01", + ) + 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_sql_pool_vulnerability_assessment_scans_begin_initiate_scan(self, resource_group): + response = await ( + await self.client.sql_pool_vulnerability_assessment_scans.begin_initiate_scan( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + vulnerability_assessment_name="str", + scan_id="str", + api_version="2021-06-01", + ) + ).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_sql_pool_vulnerability_assessment_scans_export(self, resource_group): + response = await self.client.sql_pool_vulnerability_assessment_scans.export( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + vulnerability_assessment_name="str", + scan_id="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_vulnerability_assessment_scans_get(self, resource_group): + response = await self.client.sql_pool_vulnerability_assessment_scans.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + vulnerability_assessment_name="str", + scan_id="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_vulnerability_assessments_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_vulnerability_assessments_operations.py new file mode 100644 index 000000000000..1d598d0d40d4 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_vulnerability_assessments_operations.py @@ -0,0 +1,83 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementSqlPoolVulnerabilityAssessmentsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_vulnerability_assessments_list(self, resource_group): + response = self.client.sql_pool_vulnerability_assessments.list( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_vulnerability_assessments_get(self, resource_group): + response = self.client.sql_pool_vulnerability_assessments.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + vulnerability_assessment_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_vulnerability_assessments_create_or_update(self, resource_group): + response = self.client.sql_pool_vulnerability_assessments.create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + vulnerability_assessment_name="str", + parameters={ + "id": "str", + "name": "str", + "recurringScans": {"emailSubscriptionAdmins": True, "emails": ["str"], "isEnabled": bool}, + "storageAccountAccessKey": "str", + "storageContainerPath": "str", + "storageContainerSasKey": "str", + "type": "str", + }, + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_vulnerability_assessments_delete(self, resource_group): + response = self.client.sql_pool_vulnerability_assessments.delete( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + vulnerability_assessment_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_vulnerability_assessments_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_vulnerability_assessments_operations_async.py new file mode 100644 index 000000000000..4b6d50202323 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_vulnerability_assessments_operations_async.py @@ -0,0 +1,84 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementSqlPoolVulnerabilityAssessmentsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_vulnerability_assessments_list(self, resource_group): + response = self.client.sql_pool_vulnerability_assessments.list( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ) + 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_sql_pool_vulnerability_assessments_get(self, resource_group): + response = await self.client.sql_pool_vulnerability_assessments.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + vulnerability_assessment_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_vulnerability_assessments_create_or_update(self, resource_group): + response = await self.client.sql_pool_vulnerability_assessments.create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + vulnerability_assessment_name="str", + parameters={ + "id": "str", + "name": "str", + "recurringScans": {"emailSubscriptionAdmins": True, "emails": ["str"], "isEnabled": bool}, + "storageAccountAccessKey": "str", + "storageContainerPath": "str", + "storageContainerSasKey": "str", + "type": "str", + }, + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_vulnerability_assessments_delete(self, resource_group): + response = await self.client.sql_pool_vulnerability_assessments.delete( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + vulnerability_assessment_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_workload_classifier_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_workload_classifier_operations.py new file mode 100644 index 000000000000..afe909e1c259 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_workload_classifier_operations.py @@ -0,0 +1,89 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementSqlPoolWorkloadClassifierOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_workload_classifier_get(self, resource_group): + response = self.client.sql_pool_workload_classifier.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + workload_group_name="str", + workload_classifier_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_workload_classifier_begin_create_or_update(self, resource_group): + response = self.client.sql_pool_workload_classifier.begin_create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + workload_group_name="str", + workload_classifier_name="str", + parameters={ + "context": "str", + "endTime": "str", + "id": "str", + "importance": "str", + "label": "str", + "memberName": "str", + "name": "str", + "startTime": "str", + "type": "str", + }, + api_version="2021-06-01", + ).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_sql_pool_workload_classifier_begin_delete(self, resource_group): + response = self.client.sql_pool_workload_classifier.begin_delete( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + workload_group_name="str", + workload_classifier_name="str", + api_version="2021-06-01", + ).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_sql_pool_workload_classifier_list(self, resource_group): + response = self.client.sql_pool_workload_classifier.list( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + workload_group_name="str", + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_workload_classifier_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_workload_classifier_operations_async.py new file mode 100644 index 000000000000..f0520f56dcb3 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_workload_classifier_operations_async.py @@ -0,0 +1,94 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementSqlPoolWorkloadClassifierOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_workload_classifier_get(self, resource_group): + response = await self.client.sql_pool_workload_classifier.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + workload_group_name="str", + workload_classifier_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_workload_classifier_begin_create_or_update(self, resource_group): + response = await ( + await self.client.sql_pool_workload_classifier.begin_create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + workload_group_name="str", + workload_classifier_name="str", + parameters={ + "context": "str", + "endTime": "str", + "id": "str", + "importance": "str", + "label": "str", + "memberName": "str", + "name": "str", + "startTime": "str", + "type": "str", + }, + api_version="2021-06-01", + ) + ).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_sql_pool_workload_classifier_begin_delete(self, resource_group): + response = await ( + await self.client.sql_pool_workload_classifier.begin_delete( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + workload_group_name="str", + workload_classifier_name="str", + api_version="2021-06-01", + ) + ).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_sql_pool_workload_classifier_list(self, resource_group): + response = self.client.sql_pool_workload_classifier.list( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + workload_group_name="str", + api_version="2021-06-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_workload_group_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_workload_group_operations.py new file mode 100644 index 000000000000..19ec086aa6d0 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_workload_group_operations.py @@ -0,0 +1,85 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementSqlPoolWorkloadGroupOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_workload_group_get(self, resource_group): + response = self.client.sql_pool_workload_group.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + workload_group_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pool_workload_group_begin_create_or_update(self, resource_group): + response = self.client.sql_pool_workload_group.begin_create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + workload_group_name="str", + parameters={ + "id": "str", + "importance": "str", + "maxResourcePercent": 0, + "maxResourcePercentPerRequest": 0.0, + "minResourcePercent": 0, + "minResourcePercentPerRequest": 0.0, + "name": "str", + "queryExecutionTimeout": 0, + "type": "str", + }, + api_version="2021-06-01", + ).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_sql_pool_workload_group_begin_delete(self, resource_group): + response = self.client.sql_pool_workload_group.begin_delete( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + workload_group_name="str", + api_version="2021-06-01", + ).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_sql_pool_workload_group_list(self, resource_group): + response = self.client.sql_pool_workload_group.list( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_workload_group_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_workload_group_operations_async.py new file mode 100644 index 000000000000..03999af77241 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pool_workload_group_operations_async.py @@ -0,0 +1,90 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementSqlPoolWorkloadGroupOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_workload_group_get(self, resource_group): + response = await self.client.sql_pool_workload_group.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + workload_group_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pool_workload_group_begin_create_or_update(self, resource_group): + response = await ( + await self.client.sql_pool_workload_group.begin_create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + workload_group_name="str", + parameters={ + "id": "str", + "importance": "str", + "maxResourcePercent": 0, + "maxResourcePercentPerRequest": 0.0, + "minResourcePercent": 0, + "minResourcePercentPerRequest": 0.0, + "name": "str", + "queryExecutionTimeout": 0, + "type": "str", + }, + api_version="2021-06-01", + ) + ).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_sql_pool_workload_group_begin_delete(self, resource_group): + response = await ( + await self.client.sql_pool_workload_group.begin_delete( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + workload_group_name="str", + api_version="2021-06-01", + ) + ).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_sql_pool_workload_group_list(self, resource_group): + response = self.client.sql_pool_workload_group.list( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pools_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pools_operations.py new file mode 100644 index 000000000000..f554b8cd37d1 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pools_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.synapse import SynapseManagementClient + +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 TestSynapseManagementSqlPoolsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pools_get(self, resource_group): + response = self.client.sql_pools.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pools_begin_update(self, resource_group): + response = self.client.sql_pools.begin_update( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + sql_pool_info={ + "collation": "", + "createMode": "str", + "creationDate": "2020-02-20 00:00:00", + "location": "str", + "maxSizeBytes": 0, + "provisioningState": "str", + "recoverableDatabaseId": "str", + "restorePointInTime": "2020-02-20 00:00:00", + "sku": {"capacity": 0, "name": "str", "tier": "str"}, + "sourceDatabaseDeletionDate": "2020-02-20 00:00:00", + "sourceDatabaseId": "str", + "status": "str", + "storageAccountType": "GRS", + "tags": {"str": "str"}, + }, + api_version="2021-06-01", + ).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_sql_pools_begin_create(self, resource_group): + response = self.client.sql_pools.begin_create( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + sql_pool_info={ + "location": "str", + "collation": "", + "createMode": "str", + "creationDate": "2020-02-20 00:00:00", + "id": "str", + "maxSizeBytes": 0, + "name": "str", + "provisioningState": "str", + "recoverableDatabaseId": "str", + "restorePointInTime": "2020-02-20 00:00:00", + "sku": {"capacity": 0, "name": "str", "tier": "str"}, + "sourceDatabaseDeletionDate": "2020-02-20 00:00:00", + "sourceDatabaseId": "str", + "status": "str", + "storageAccountType": "GRS", + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2021-06-01", + ).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_sql_pools_begin_delete(self, resource_group): + response = self.client.sql_pools.begin_delete( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ).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_sql_pools_list_by_workspace(self, resource_group): + response = self.client.sql_pools.list_by_workspace( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_sql_pools_begin_pause(self, resource_group): + response = self.client.sql_pools.begin_pause( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ).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_sql_pools_begin_resume(self, resource_group): + response = self.client.sql_pools.begin_resume( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pools_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pools_operations_async.py new file mode 100644 index 000000000000..f173ff447045 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_sql_pools_operations_async.py @@ -0,0 +1,155 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementSqlPoolsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pools_get(self, resource_group): + response = await self.client.sql_pools.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_sql_pools_begin_update(self, resource_group): + response = await ( + await self.client.sql_pools.begin_update( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + sql_pool_info={ + "collation": "", + "createMode": "str", + "creationDate": "2020-02-20 00:00:00", + "location": "str", + "maxSizeBytes": 0, + "provisioningState": "str", + "recoverableDatabaseId": "str", + "restorePointInTime": "2020-02-20 00:00:00", + "sku": {"capacity": 0, "name": "str", "tier": "str"}, + "sourceDatabaseDeletionDate": "2020-02-20 00:00:00", + "sourceDatabaseId": "str", + "status": "str", + "storageAccountType": "GRS", + "tags": {"str": "str"}, + }, + api_version="2021-06-01", + ) + ).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_sql_pools_begin_create(self, resource_group): + response = await ( + await self.client.sql_pools.begin_create( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + sql_pool_info={ + "location": "str", + "collation": "", + "createMode": "str", + "creationDate": "2020-02-20 00:00:00", + "id": "str", + "maxSizeBytes": 0, + "name": "str", + "provisioningState": "str", + "recoverableDatabaseId": "str", + "restorePointInTime": "2020-02-20 00:00:00", + "sku": {"capacity": 0, "name": "str", "tier": "str"}, + "sourceDatabaseDeletionDate": "2020-02-20 00:00:00", + "sourceDatabaseId": "str", + "status": "str", + "storageAccountType": "GRS", + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2021-06-01", + ) + ).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_sql_pools_begin_delete(self, resource_group): + response = await ( + await self.client.sql_pools.begin_delete( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ) + ).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_sql_pools_list_by_workspace(self, resource_group): + response = self.client.sql_pools.list_by_workspace( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + 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_sql_pools_begin_pause(self, resource_group): + response = await ( + await self.client.sql_pools.begin_pause( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ) + ).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_sql_pools_begin_resume(self, resource_group): + response = await ( + await self.client.sql_pools.begin_resume( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_aad_admins_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_aad_admins_operations.py new file mode 100644 index 000000000000..b97b5a3f0089 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_aad_admins_operations.py @@ -0,0 +1,64 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementWorkspaceAadAdminsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_aad_admins_get(self, resource_group): + response = self.client.workspace_aad_admins.get( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_aad_admins_begin_create_or_update(self, resource_group): + response = self.client.workspace_aad_admins.begin_create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + aad_admin_info={ + "administratorType": "str", + "id": "str", + "login": "str", + "name": "str", + "sid": "str", + "tenantId": "str", + "type": "str", + }, + api_version="2021-06-01", + ).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_workspace_aad_admins_begin_delete(self, resource_group): + response = self.client.workspace_aad_admins.begin_delete( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_aad_admins_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_aad_admins_operations_async.py new file mode 100644 index 000000000000..5098d96c503c --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_aad_admins_operations_async.py @@ -0,0 +1,69 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementWorkspaceAadAdminsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_aad_admins_get(self, resource_group): + response = await self.client.workspace_aad_admins.get( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_aad_admins_begin_create_or_update(self, resource_group): + response = await ( + await self.client.workspace_aad_admins.begin_create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + aad_admin_info={ + "administratorType": "str", + "id": "str", + "login": "str", + "name": "str", + "sid": "str", + "tenantId": "str", + "type": "str", + }, + api_version="2021-06-01", + ) + ).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_workspace_aad_admins_begin_delete(self, resource_group): + response = await ( + await self.client.workspace_aad_admins.begin_delete( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_identity_sql_control_settings_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_identity_sql_control_settings_operations.py new file mode 100644 index 000000000000..799287eb91e1 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_identity_sql_control_settings_operations.py @@ -0,0 +1,49 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementWorkspaceManagedIdentitySqlControlSettingsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_managed_identity_sql_control_settings_get(self, resource_group): + response = self.client.workspace_managed_identity_sql_control_settings.get( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_managed_identity_sql_control_settings_begin_create_or_update(self, resource_group): + response = self.client.workspace_managed_identity_sql_control_settings.begin_create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + managed_identity_sql_control_settings={ + "grantSqlControlToManagedIdentity": {"actualState": "str", "desiredState": "str"}, + "id": "str", + "name": "str", + "type": "str", + }, + api_version="2021-06-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_identity_sql_control_settings_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_identity_sql_control_settings_operations_async.py new file mode 100644 index 000000000000..c1627bdae8db --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_identity_sql_control_settings_operations_async.py @@ -0,0 +1,52 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementWorkspaceManagedIdentitySqlControlSettingsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_managed_identity_sql_control_settings_get(self, resource_group): + response = await self.client.workspace_managed_identity_sql_control_settings.get( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_managed_identity_sql_control_settings_begin_create_or_update(self, resource_group): + response = await ( + await self.client.workspace_managed_identity_sql_control_settings.begin_create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + managed_identity_sql_control_settings={ + "grantSqlControlToManagedIdentity": {"actualState": "str", "desiredState": "str"}, + "id": "str", + "name": "str", + "type": "str", + }, + api_version="2021-06-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_blob_auditing_policies_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_blob_auditing_policies_operations.py new file mode 100644 index 000000000000..e0271754acbc --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_blob_auditing_policies_operations.py @@ -0,0 +1,72 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementWorkspaceManagedSqlServerBlobAuditingPoliciesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_managed_sql_server_blob_auditing_policies_get(self, resource_group): + response = self.client.workspace_managed_sql_server_blob_auditing_policies.get( + resource_group_name=resource_group.name, + workspace_name="str", + blob_auditing_policy_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_managed_sql_server_blob_auditing_policies_begin_create_or_update(self, resource_group): + response = self.client.workspace_managed_sql_server_blob_auditing_policies.begin_create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + blob_auditing_policy_name="str", + parameters={ + "auditActionsAndGroups": ["str"], + "id": "str", + "isAzureMonitorTargetEnabled": bool, + "isDevopsAuditEnabled": bool, + "isStorageSecondaryKeyInUse": bool, + "name": "str", + "queueDelayMs": 0, + "retentionDays": 0, + "state": "str", + "storageAccountAccessKey": "str", + "storageAccountSubscriptionId": "str", + "storageEndpoint": "str", + "type": "str", + }, + api_version="2021-06-01", + ).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_workspace_managed_sql_server_blob_auditing_policies_list_by_workspace(self, resource_group): + response = self.client.workspace_managed_sql_server_blob_auditing_policies.list_by_workspace( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_blob_auditing_policies_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_blob_auditing_policies_operations_async.py new file mode 100644 index 000000000000..b4c2ef47dcce --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_blob_auditing_policies_operations_async.py @@ -0,0 +1,75 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementWorkspaceManagedSqlServerBlobAuditingPoliciesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_managed_sql_server_blob_auditing_policies_get(self, resource_group): + response = await self.client.workspace_managed_sql_server_blob_auditing_policies.get( + resource_group_name=resource_group.name, + workspace_name="str", + blob_auditing_policy_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_managed_sql_server_blob_auditing_policies_begin_create_or_update(self, resource_group): + response = await ( + await self.client.workspace_managed_sql_server_blob_auditing_policies.begin_create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + blob_auditing_policy_name="str", + parameters={ + "auditActionsAndGroups": ["str"], + "id": "str", + "isAzureMonitorTargetEnabled": bool, + "isDevopsAuditEnabled": bool, + "isStorageSecondaryKeyInUse": bool, + "name": "str", + "queueDelayMs": 0, + "retentionDays": 0, + "state": "str", + "storageAccountAccessKey": "str", + "storageAccountSubscriptionId": "str", + "storageEndpoint": "str", + "type": "str", + }, + api_version="2021-06-01", + ) + ).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_workspace_managed_sql_server_blob_auditing_policies_list_by_workspace(self, resource_group): + response = self.client.workspace_managed_sql_server_blob_auditing_policies.list_by_workspace( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_dedicated_sql_minimal_tls_settings_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_dedicated_sql_minimal_tls_settings_operations.py new file mode 100644 index 000000000000..c9de2015ef71 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_dedicated_sql_minimal_tls_settings_operations.py @@ -0,0 +1,58 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementWorkspaceManagedSqlServerDedicatedSQLMinimalTlsSettingsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_managed_sql_server_dedicated_sql_minimal_tls_settings_begin_update(self, resource_group): + response = self.client.workspace_managed_sql_server_dedicated_sql_minimal_tls_settings.begin_update( + resource_group_name=resource_group.name, + workspace_name="str", + dedicated_sq_lminimal_tls_settings_name="str", + parameters={"id": "str", "location": "str", "minimalTlsVersion": "str", "name": "str", "type": "str"}, + api_version="2021-06-01", + ).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_workspace_managed_sql_server_dedicated_sql_minimal_tls_settings_get(self, resource_group): + response = self.client.workspace_managed_sql_server_dedicated_sql_minimal_tls_settings.get( + resource_group_name=resource_group.name, + workspace_name="str", + dedicated_sq_lminimal_tls_settings_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_managed_sql_server_dedicated_sql_minimal_tls_settings_list(self, resource_group): + response = self.client.workspace_managed_sql_server_dedicated_sql_minimal_tls_settings.list( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_dedicated_sql_minimal_tls_settings_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_dedicated_sql_minimal_tls_settings_operations_async.py new file mode 100644 index 000000000000..1dc1db4e367d --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_dedicated_sql_minimal_tls_settings_operations_async.py @@ -0,0 +1,63 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementWorkspaceManagedSqlServerDedicatedSQLMinimalTlsSettingsOperationsAsync( + AzureMgmtRecordedTestCase +): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_managed_sql_server_dedicated_sql_minimal_tls_settings_begin_update(self, resource_group): + response = await ( + await self.client.workspace_managed_sql_server_dedicated_sql_minimal_tls_settings.begin_update( + resource_group_name=resource_group.name, + workspace_name="str", + dedicated_sq_lminimal_tls_settings_name="str", + parameters={"id": "str", "location": "str", "minimalTlsVersion": "str", "name": "str", "type": "str"}, + api_version="2021-06-01", + ) + ).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_workspace_managed_sql_server_dedicated_sql_minimal_tls_settings_get(self, resource_group): + response = await self.client.workspace_managed_sql_server_dedicated_sql_minimal_tls_settings.get( + resource_group_name=resource_group.name, + workspace_name="str", + dedicated_sq_lminimal_tls_settings_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_managed_sql_server_dedicated_sql_minimal_tls_settings_list(self, resource_group): + response = self.client.workspace_managed_sql_server_dedicated_sql_minimal_tls_settings.list( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_encryption_protector_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_encryption_protector_operations.py new file mode 100644 index 000000000000..3ac6604b6a27 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_encryption_protector_operations.py @@ -0,0 +1,82 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementWorkspaceManagedSqlServerEncryptionProtectorOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_managed_sql_server_encryption_protector_get(self, resource_group): + response = self.client.workspace_managed_sql_server_encryption_protector.get( + resource_group_name=resource_group.name, + workspace_name="str", + encryption_protector_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_managed_sql_server_encryption_protector_begin_create_or_update(self, resource_group): + response = self.client.workspace_managed_sql_server_encryption_protector.begin_create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + encryption_protector_name="str", + parameters={ + "id": "str", + "kind": "str", + "location": "str", + "name": "str", + "serverKeyName": "str", + "serverKeyType": "str", + "subregion": "str", + "thumbprint": "str", + "type": "str", + "uri": "str", + }, + api_version="2021-06-01", + ).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_workspace_managed_sql_server_encryption_protector_list(self, resource_group): + response = self.client.workspace_managed_sql_server_encryption_protector.list( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_managed_sql_server_encryption_protector_begin_revalidate(self, resource_group): + response = self.client.workspace_managed_sql_server_encryption_protector.begin_revalidate( + resource_group_name=resource_group.name, + workspace_name="str", + encryption_protector_name="str", + api_version="2021-06-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_encryption_protector_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_encryption_protector_operations_async.py new file mode 100644 index 000000000000..b2d55fcdd5cf --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_encryption_protector_operations_async.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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementWorkspaceManagedSqlServerEncryptionProtectorOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_managed_sql_server_encryption_protector_get(self, resource_group): + response = await self.client.workspace_managed_sql_server_encryption_protector.get( + resource_group_name=resource_group.name, + workspace_name="str", + encryption_protector_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_managed_sql_server_encryption_protector_begin_create_or_update(self, resource_group): + response = await ( + await self.client.workspace_managed_sql_server_encryption_protector.begin_create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + encryption_protector_name="str", + parameters={ + "id": "str", + "kind": "str", + "location": "str", + "name": "str", + "serverKeyName": "str", + "serverKeyType": "str", + "subregion": "str", + "thumbprint": "str", + "type": "str", + "uri": "str", + }, + api_version="2021-06-01", + ) + ).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_workspace_managed_sql_server_encryption_protector_list(self, resource_group): + response = self.client.workspace_managed_sql_server_encryption_protector.list( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + 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_workspace_managed_sql_server_encryption_protector_begin_revalidate(self, resource_group): + response = await ( + await self.client.workspace_managed_sql_server_encryption_protector.begin_revalidate( + resource_group_name=resource_group.name, + workspace_name="str", + encryption_protector_name="str", + api_version="2021-06-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_extended_blob_auditing_policies_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_extended_blob_auditing_policies_operations.py new file mode 100644 index 000000000000..7bef48306fb7 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_extended_blob_auditing_policies_operations.py @@ -0,0 +1,73 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementWorkspaceManagedSqlServerExtendedBlobAuditingPoliciesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_managed_sql_server_extended_blob_auditing_policies_get(self, resource_group): + response = self.client.workspace_managed_sql_server_extended_blob_auditing_policies.get( + resource_group_name=resource_group.name, + workspace_name="str", + blob_auditing_policy_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_managed_sql_server_extended_blob_auditing_policies_begin_create_or_update(self, resource_group): + response = self.client.workspace_managed_sql_server_extended_blob_auditing_policies.begin_create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + blob_auditing_policy_name="str", + parameters={ + "auditActionsAndGroups": ["str"], + "id": "str", + "isAzureMonitorTargetEnabled": bool, + "isDevopsAuditEnabled": bool, + "isStorageSecondaryKeyInUse": bool, + "name": "str", + "predicateExpression": "str", + "queueDelayMs": 0, + "retentionDays": 0, + "state": "str", + "storageAccountAccessKey": "str", + "storageAccountSubscriptionId": "str", + "storageEndpoint": "str", + "type": "str", + }, + api_version="2021-06-01", + ).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_workspace_managed_sql_server_extended_blob_auditing_policies_list_by_workspace(self, resource_group): + response = self.client.workspace_managed_sql_server_extended_blob_auditing_policies.list_by_workspace( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_extended_blob_auditing_policies_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_extended_blob_auditing_policies_operations_async.py new file mode 100644 index 000000000000..8dfae4a6e02f --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_extended_blob_auditing_policies_operations_async.py @@ -0,0 +1,80 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementWorkspaceManagedSqlServerExtendedBlobAuditingPoliciesOperationsAsync( + AzureMgmtRecordedTestCase +): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_managed_sql_server_extended_blob_auditing_policies_get(self, resource_group): + response = await self.client.workspace_managed_sql_server_extended_blob_auditing_policies.get( + resource_group_name=resource_group.name, + workspace_name="str", + blob_auditing_policy_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_managed_sql_server_extended_blob_auditing_policies_begin_create_or_update( + self, resource_group + ): + response = await ( + await self.client.workspace_managed_sql_server_extended_blob_auditing_policies.begin_create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + blob_auditing_policy_name="str", + parameters={ + "auditActionsAndGroups": ["str"], + "id": "str", + "isAzureMonitorTargetEnabled": bool, + "isDevopsAuditEnabled": bool, + "isStorageSecondaryKeyInUse": bool, + "name": "str", + "predicateExpression": "str", + "queueDelayMs": 0, + "retentionDays": 0, + "state": "str", + "storageAccountAccessKey": "str", + "storageAccountSubscriptionId": "str", + "storageEndpoint": "str", + "type": "str", + }, + api_version="2021-06-01", + ) + ).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_workspace_managed_sql_server_extended_blob_auditing_policies_list_by_workspace(self, resource_group): + response = self.client.workspace_managed_sql_server_extended_blob_auditing_policies.list_by_workspace( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_recoverable_sql_pools_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_recoverable_sql_pools_operations.py new file mode 100644 index 000000000000..595a1fb9edb3 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_recoverable_sql_pools_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.synapse import SynapseManagementClient + +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 TestSynapseManagementWorkspaceManagedSqlServerRecoverableSqlPoolsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_managed_sql_server_recoverable_sql_pools_list(self, resource_group): + response = self.client.workspace_managed_sql_server_recoverable_sql_pools.list( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_managed_sql_server_recoverable_sql_pools_get(self, resource_group): + response = self.client.workspace_managed_sql_server_recoverable_sql_pools.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_recoverable_sql_pools_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_recoverable_sql_pools_operations_async.py new file mode 100644 index 000000000000..2befdbece3c4 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_recoverable_sql_pools_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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementWorkspaceManagedSqlServerRecoverableSqlPoolsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_managed_sql_server_recoverable_sql_pools_list(self, resource_group): + response = self.client.workspace_managed_sql_server_recoverable_sql_pools.list( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + 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_workspace_managed_sql_server_recoverable_sql_pools_get(self, resource_group): + response = await self.client.workspace_managed_sql_server_recoverable_sql_pools.get( + resource_group_name=resource_group.name, + workspace_name="str", + sql_pool_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_security_alert_policy_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_security_alert_policy_operations.py new file mode 100644 index 000000000000..ebea2f70217c --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_security_alert_policy_operations.py @@ -0,0 +1,70 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementWorkspaceManagedSqlServerSecurityAlertPolicyOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_managed_sql_server_security_alert_policy_get(self, resource_group): + response = self.client.workspace_managed_sql_server_security_alert_policy.get( + resource_group_name=resource_group.name, + workspace_name="str", + security_alert_policy_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_managed_sql_server_security_alert_policy_begin_create_or_update(self, resource_group): + response = self.client.workspace_managed_sql_server_security_alert_policy.begin_create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + security_alert_policy_name="str", + parameters={ + "creationTime": "2020-02-20 00:00:00", + "disabledAlerts": ["str"], + "emailAccountAdmins": bool, + "emailAddresses": ["str"], + "id": "str", + "name": "str", + "retentionDays": 0, + "state": "str", + "storageAccountAccessKey": "str", + "storageEndpoint": "str", + "type": "str", + }, + api_version="2021-06-01", + ).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_workspace_managed_sql_server_security_alert_policy_list(self, resource_group): + response = self.client.workspace_managed_sql_server_security_alert_policy.list( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_security_alert_policy_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_security_alert_policy_operations_async.py new file mode 100644 index 000000000000..a6eae8cdc5fe --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_security_alert_policy_operations_async.py @@ -0,0 +1,73 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementWorkspaceManagedSqlServerSecurityAlertPolicyOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_managed_sql_server_security_alert_policy_get(self, resource_group): + response = await self.client.workspace_managed_sql_server_security_alert_policy.get( + resource_group_name=resource_group.name, + workspace_name="str", + security_alert_policy_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_managed_sql_server_security_alert_policy_begin_create_or_update(self, resource_group): + response = await ( + await self.client.workspace_managed_sql_server_security_alert_policy.begin_create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + security_alert_policy_name="str", + parameters={ + "creationTime": "2020-02-20 00:00:00", + "disabledAlerts": ["str"], + "emailAccountAdmins": bool, + "emailAddresses": ["str"], + "id": "str", + "name": "str", + "retentionDays": 0, + "state": "str", + "storageAccountAccessKey": "str", + "storageEndpoint": "str", + "type": "str", + }, + api_version="2021-06-01", + ) + ).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_workspace_managed_sql_server_security_alert_policy_list(self, resource_group): + response = self.client.workspace_managed_sql_server_security_alert_policy.list( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_usages_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_usages_operations.py new file mode 100644 index 000000000000..861471f17621 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_usages_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.synapse import SynapseManagementClient + +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 TestSynapseManagementWorkspaceManagedSqlServerUsagesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_managed_sql_server_usages_list(self, resource_group): + response = self.client.workspace_managed_sql_server_usages.list( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_usages_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_usages_operations_async.py new file mode 100644 index 000000000000..849888b18546 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_usages_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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementWorkspaceManagedSqlServerUsagesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_managed_sql_server_usages_list(self, resource_group): + response = self.client.workspace_managed_sql_server_usages.list( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_vulnerability_assessments_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_vulnerability_assessments_operations.py new file mode 100644 index 000000000000..d3955570cf95 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_vulnerability_assessments_operations.py @@ -0,0 +1,79 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementWorkspaceManagedSqlServerVulnerabilityAssessmentsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_managed_sql_server_vulnerability_assessments_get(self, resource_group): + response = self.client.workspace_managed_sql_server_vulnerability_assessments.get( + resource_group_name=resource_group.name, + workspace_name="str", + vulnerability_assessment_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_managed_sql_server_vulnerability_assessments_create_or_update(self, resource_group): + response = self.client.workspace_managed_sql_server_vulnerability_assessments.create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + vulnerability_assessment_name="str", + parameters={ + "id": "str", + "name": "str", + "recurringScans": {"emailSubscriptionAdmins": True, "emails": ["str"], "isEnabled": bool}, + "storageAccountAccessKey": "str", + "storageContainerPath": "str", + "storageContainerSasKey": "str", + "type": "str", + }, + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_managed_sql_server_vulnerability_assessments_delete(self, resource_group): + response = self.client.workspace_managed_sql_server_vulnerability_assessments.delete( + resource_group_name=resource_group.name, + workspace_name="str", + vulnerability_assessment_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_managed_sql_server_vulnerability_assessments_list(self, resource_group): + response = self.client.workspace_managed_sql_server_vulnerability_assessments.list( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_vulnerability_assessments_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_vulnerability_assessments_operations_async.py new file mode 100644 index 000000000000..6b137f2a1fa0 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_managed_sql_server_vulnerability_assessments_operations_async.py @@ -0,0 +1,80 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementWorkspaceManagedSqlServerVulnerabilityAssessmentsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_managed_sql_server_vulnerability_assessments_get(self, resource_group): + response = await self.client.workspace_managed_sql_server_vulnerability_assessments.get( + resource_group_name=resource_group.name, + workspace_name="str", + vulnerability_assessment_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_managed_sql_server_vulnerability_assessments_create_or_update(self, resource_group): + response = await self.client.workspace_managed_sql_server_vulnerability_assessments.create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + vulnerability_assessment_name="str", + parameters={ + "id": "str", + "name": "str", + "recurringScans": {"emailSubscriptionAdmins": True, "emails": ["str"], "isEnabled": bool}, + "storageAccountAccessKey": "str", + "storageContainerPath": "str", + "storageContainerSasKey": "str", + "type": "str", + }, + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_managed_sql_server_vulnerability_assessments_delete(self, resource_group): + response = await self.client.workspace_managed_sql_server_vulnerability_assessments.delete( + resource_group_name=resource_group.name, + workspace_name="str", + vulnerability_assessment_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_managed_sql_server_vulnerability_assessments_list(self, resource_group): + response = self.client.workspace_managed_sql_server_vulnerability_assessments.list( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_sql_aad_admins_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_sql_aad_admins_operations.py new file mode 100644 index 000000000000..6755bc80425e --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_sql_aad_admins_operations.py @@ -0,0 +1,64 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementWorkspaceSqlAadAdminsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_sql_aad_admins_get(self, resource_group): + response = self.client.workspace_sql_aad_admins.get( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_sql_aad_admins_begin_create_or_update(self, resource_group): + response = self.client.workspace_sql_aad_admins.begin_create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + aad_admin_info={ + "administratorType": "str", + "id": "str", + "login": "str", + "name": "str", + "sid": "str", + "tenantId": "str", + "type": "str", + }, + api_version="2021-06-01", + ).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_workspace_sql_aad_admins_begin_delete(self, resource_group): + response = self.client.workspace_sql_aad_admins.begin_delete( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_sql_aad_admins_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_sql_aad_admins_operations_async.py new file mode 100644 index 000000000000..1d2c7c7f2ac7 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspace_sql_aad_admins_operations_async.py @@ -0,0 +1,69 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementWorkspaceSqlAadAdminsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_sql_aad_admins_get(self, resource_group): + response = await self.client.workspace_sql_aad_admins.get( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_sql_aad_admins_begin_create_or_update(self, resource_group): + response = await ( + await self.client.workspace_sql_aad_admins.begin_create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + aad_admin_info={ + "administratorType": "str", + "id": "str", + "login": "str", + "name": "str", + "sid": "str", + "tenantId": "str", + "type": "str", + }, + api_version="2021-06-01", + ) + ).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_workspace_sql_aad_admins_begin_delete(self, resource_group): + response = await ( + await self.client.workspace_sql_aad_admins.begin_delete( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspaces_operations.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspaces_operations.py new file mode 100644 index 000000000000..2aca2a4b6525 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspaces_operations.py @@ -0,0 +1,198 @@ +# 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.synapse import SynapseManagementClient + +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 TestSynapseManagementWorkspacesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspaces_list_by_resource_group(self, resource_group): + response = self.client.workspaces.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspaces_get(self, resource_group): + response = self.client.workspaces.get( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspaces_begin_update(self, resource_group): + response = self.client.workspaces.begin_update( + resource_group_name=resource_group.name, + workspace_name="str", + workspace_patch_info={ + "encryption": { + "cmk": { + "kekIdentity": {"useSystemAssignedIdentity": {}, "userAssignedIdentity": "str"}, + "key": {"keyVaultUrl": "str", "name": "str"}, + "status": "str", + }, + "doubleEncryptionEnabled": bool, + }, + "identity": { + "principalId": "str", + "tenantId": "str", + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "managedVirtualNetworkSettings": { + "allowedAadTenantIdsForLinking": ["str"], + "linkedAccessCheckOnTargetResource": bool, + "preventDataExfiltration": bool, + }, + "provisioningState": "str", + "publicNetworkAccess": "str", + "purviewConfiguration": {"purviewResourceId": "str"}, + "sqlAdministratorLoginPassword": "str", + "tags": {"str": "str"}, + "workspaceRepositoryConfiguration": { + "accountName": "str", + "collaborationBranch": "str", + "hostName": "str", + "lastCommitId": "str", + "projectName": "str", + "repositoryName": "str", + "rootFolder": "str", + "tenantId": "str", + "type": "str", + }, + }, + api_version="2021-06-01", + ).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_workspaces_begin_create_or_update(self, resource_group): + response = self.client.workspaces.begin_create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + workspace_info={ + "location": "str", + "adlaResourceId": "str", + "azureADOnlyAuthentication": bool, + "connectivityEndpoints": {"str": "str"}, + "cspWorkspaceAdminProperties": {"initialWorkspaceAdminObjectId": "str"}, + "defaultDataLakeStorage": { + "accountUrl": "str", + "createManagedPrivateEndpoint": bool, + "filesystem": "str", + "resourceId": "str", + }, + "encryption": { + "cmk": { + "kekIdentity": {"useSystemAssignedIdentity": {}, "userAssignedIdentity": "str"}, + "key": {"keyVaultUrl": "str", "name": "str"}, + "status": "str", + }, + "doubleEncryptionEnabled": bool, + }, + "extraProperties": {}, + "id": "str", + "identity": { + "principalId": "str", + "tenantId": "str", + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "managedResourceGroupName": "str", + "managedVirtualNetwork": "str", + "managedVirtualNetworkSettings": { + "allowedAadTenantIdsForLinking": ["str"], + "linkedAccessCheckOnTargetResource": bool, + "preventDataExfiltration": bool, + }, + "name": "str", + "privateEndpointConnections": [ + { + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + "type": "str", + } + ], + "provisioningState": "str", + "publicNetworkAccess": "str", + "purviewConfiguration": {"purviewResourceId": "str"}, + "settings": {"str": {}}, + "sqlAdministratorLogin": "str", + "sqlAdministratorLoginPassword": "str", + "tags": {"str": "str"}, + "trustedServiceBypassEnabled": False, + "type": "str", + "virtualNetworkProfile": {"computeSubnetId": "str"}, + "workspaceRepositoryConfiguration": { + "accountName": "str", + "collaborationBranch": "str", + "hostName": "str", + "lastCommitId": "str", + "projectName": "str", + "repositoryName": "str", + "rootFolder": "str", + "tenantId": "str", + "type": "str", + }, + "workspaceUID": "str", + }, + api_version="2021-06-01", + ).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_workspaces_begin_delete(self, resource_group): + response = self.client.workspaces.begin_delete( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ).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_workspaces_list(self, resource_group): + response = self.client.workspaces.list( + api_version="2021-06-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspaces_operations_async.py b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspaces_operations_async.py new file mode 100644 index 000000000000..5d3b78841203 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/generated_tests/test_synapse_management_workspaces_operations_async.py @@ -0,0 +1,205 @@ +# 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.synapse.aio import SynapseManagementClient + +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 TestSynapseManagementWorkspacesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(SynapseManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspaces_list_by_resource_group(self, resource_group): + response = self.client.workspaces.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2021-06-01", + ) + 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_workspaces_get(self, resource_group): + response = await self.client.workspaces.get( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspaces_begin_update(self, resource_group): + response = await ( + await self.client.workspaces.begin_update( + resource_group_name=resource_group.name, + workspace_name="str", + workspace_patch_info={ + "encryption": { + "cmk": { + "kekIdentity": {"useSystemAssignedIdentity": {}, "userAssignedIdentity": "str"}, + "key": {"keyVaultUrl": "str", "name": "str"}, + "status": "str", + }, + "doubleEncryptionEnabled": bool, + }, + "identity": { + "principalId": "str", + "tenantId": "str", + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "managedVirtualNetworkSettings": { + "allowedAadTenantIdsForLinking": ["str"], + "linkedAccessCheckOnTargetResource": bool, + "preventDataExfiltration": bool, + }, + "provisioningState": "str", + "publicNetworkAccess": "str", + "purviewConfiguration": {"purviewResourceId": "str"}, + "sqlAdministratorLoginPassword": "str", + "tags": {"str": "str"}, + "workspaceRepositoryConfiguration": { + "accountName": "str", + "collaborationBranch": "str", + "hostName": "str", + "lastCommitId": "str", + "projectName": "str", + "repositoryName": "str", + "rootFolder": "str", + "tenantId": "str", + "type": "str", + }, + }, + api_version="2021-06-01", + ) + ).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_workspaces_begin_create_or_update(self, resource_group): + response = await ( + await self.client.workspaces.begin_create_or_update( + resource_group_name=resource_group.name, + workspace_name="str", + workspace_info={ + "location": "str", + "adlaResourceId": "str", + "azureADOnlyAuthentication": bool, + "connectivityEndpoints": {"str": "str"}, + "cspWorkspaceAdminProperties": {"initialWorkspaceAdminObjectId": "str"}, + "defaultDataLakeStorage": { + "accountUrl": "str", + "createManagedPrivateEndpoint": bool, + "filesystem": "str", + "resourceId": "str", + }, + "encryption": { + "cmk": { + "kekIdentity": {"useSystemAssignedIdentity": {}, "userAssignedIdentity": "str"}, + "key": {"keyVaultUrl": "str", "name": "str"}, + "status": "str", + }, + "doubleEncryptionEnabled": bool, + }, + "extraProperties": {}, + "id": "str", + "identity": { + "principalId": "str", + "tenantId": "str", + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "managedResourceGroupName": "str", + "managedVirtualNetwork": "str", + "managedVirtualNetworkSettings": { + "allowedAadTenantIdsForLinking": ["str"], + "linkedAccessCheckOnTargetResource": bool, + "preventDataExfiltration": bool, + }, + "name": "str", + "privateEndpointConnections": [ + { + "id": "str", + "name": "str", + "privateEndpoint": {"id": "str"}, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "provisioningState": "str", + "type": "str", + } + ], + "provisioningState": "str", + "publicNetworkAccess": "str", + "purviewConfiguration": {"purviewResourceId": "str"}, + "settings": {"str": {}}, + "sqlAdministratorLogin": "str", + "sqlAdministratorLoginPassword": "str", + "tags": {"str": "str"}, + "trustedServiceBypassEnabled": False, + "type": "str", + "virtualNetworkProfile": {"computeSubnetId": "str"}, + "workspaceRepositoryConfiguration": { + "accountName": "str", + "collaborationBranch": "str", + "hostName": "str", + "lastCommitId": "str", + "projectName": "str", + "repositoryName": "str", + "rootFolder": "str", + "tenantId": "str", + "type": "str", + }, + "workspaceUID": "str", + }, + api_version="2021-06-01", + ) + ).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_workspaces_begin_delete(self, resource_group): + response = await ( + await self.client.workspaces.begin_delete( + resource_group_name=resource_group.name, + workspace_name="str", + api_version="2021-06-01", + ) + ).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_workspaces_list(self, resource_group): + response = self.client.workspaces.list( + api_version="2021-06-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/synapse/azure-mgmt-synapse/setup.py b/sdk/synapse/azure-mgmt-synapse/setup.py index 673385f12a57..da6d42d05bf2 100644 --- a/sdk/synapse/azure-mgmt-synapse/setup.py +++ b/sdk/synapse/azure-mgmt-synapse/setup.py @@ -1,10 +1,10 @@ #!/usr/bin/env python -#------------------------------------------------------------------------- +# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. -#-------------------------------------------------------------------------- +# -------------------------------------------------------------------------- import re import os.path @@ -16,64 +16,68 @@ PACKAGE_PPRINT_NAME = "Synapse Management" # a-b-c => a/b/c -package_folder_path = PACKAGE_NAME.replace('-', '/') +package_folder_path = PACKAGE_NAME.replace("-", "/") # a-b-c => a.b.c -namespace_name = PACKAGE_NAME.replace('-', '.') +namespace_name = PACKAGE_NAME.replace("-", ".") # Version extraction inspired from 'requests' -with open(os.path.join(package_folder_path, 'version.py') - if os.path.exists(os.path.join(package_folder_path, 'version.py')) - else os.path.join(package_folder_path, '_version.py'), 'r') as fd: - version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', - fd.read(), re.MULTILINE).group(1) +with open( + os.path.join(package_folder_path, "version.py") + if os.path.exists(os.path.join(package_folder_path, "version.py")) + else os.path.join(package_folder_path, "_version.py"), + "r", +) as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) if not version: - raise RuntimeError('Cannot find version information') + raise RuntimeError("Cannot find version information") -with open('README.md', encoding='utf-8') as f: +with open("README.md", encoding="utf-8") as f: readme = f.read() -with open('CHANGELOG.md', encoding='utf-8') as f: +with open("CHANGELOG.md", encoding="utf-8") as f: changelog = f.read() setup( name=PACKAGE_NAME, version=version, - description='Microsoft Azure {} Client Library for Python'.format(PACKAGE_PPRINT_NAME), - long_description=readme + '\n\n' + changelog, - long_description_content_type='text/markdown', - license='MIT License', - author='Microsoft Corporation', - author_email='azpysdkhelp@microsoft.com', - url='https://github.com/Azure/azure-sdk-for-python', + description="Microsoft Azure {} Client Library for Python".format(PACKAGE_PPRINT_NAME), + long_description=readme + "\n\n" + changelog, + long_description_content_type="text/markdown", + license="MIT License", + author="Microsoft Corporation", + author_email="azpysdkhelp@microsoft.com", + url="https://github.com/Azure/azure-sdk-for-python", keywords="azure, azure sdk", # update with search keywords relevant to the azure service / product classifiers=[ - 'Development Status :: 4 - Beta', - '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', - 'License :: OSI Approved :: MIT License', + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "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, - packages=find_packages(exclude=[ - 'tests', - # Exclude packages that will be covered by PEP420 or nspkg - 'azure', - 'azure.mgmt', - ]), + packages=find_packages( + exclude=[ + "tests", + # Exclude packages that will be covered by PEP420 or nspkg + "azure", + "azure.mgmt", + ] + ), include_package_data=True, package_data={ - 'pytyped': ['py.typed'], + "pytyped": ["py.typed"], }, install_requires=[ - "msrest>=0.7.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", )