diff --git a/sdk/synapse/azure-mgmt-synapse/_meta.json b/sdk/synapse/azure-mgmt-synapse/_meta.json index 45c61c5c4d73..701bc4d2c760 100644 --- a/sdk/synapse/azure-mgmt-synapse/_meta.json +++ b/sdk/synapse/azure-mgmt-synapse/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.7.2", + "autorest": "3.8.4", "use": [ - "@autorest/python@5.13.0", - "@autorest/modelerfour@4.19.3" + "@autorest/python@6.1.5", + "@autorest/modelerfour@4.23.5" ], - "commit": "256b8ec7d045dbe2daf91030b0d6b7f09c8e42d9", + "commit": "9ee3036eb1d63919b2f5a013cc772a6ce4ffd647", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/synapse/resource-manager/readme.md --multiapi --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.13.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "autorest_command": "autorest specification/synapse/resource-manager/readme.md --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.1.5 --use=@autorest/modelerfour@4.23.5 --version=3.8.4 --version-tolerant=False", "readme": "specification/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 fd66306bc5da..bc0d4597f3ed 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/__init__.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['SynapseManagementClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["SynapseManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_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 b39bef0d7be5..80f3ec09adad 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/_configuration.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/_configuration.py @@ -25,18 +25,13 @@ class SynapseManagementClientConfiguration(Configuration): # pylint: disable=to Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + 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.") @@ -45,23 +40,24 @@ def __init__( self.credential = credential 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.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-synapse/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/_patch.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/_patch.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/_serialization.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/_serialization.py new file mode 100644 index 000000000000..7c1dedb5133d --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/_serialization.py @@ -0,0 +1,1970 @@ +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# pylint: skip-file + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs + +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote # type: ignore +import xml.etree.ElementTree as ET + +import isodate + +from typing import Dict, Any, cast, TYPE_CHECKING + +from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback + +_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") + +if TYPE_CHECKING: + from typing import Optional, Union, AnyStr, IO, Mapping + + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data, content_type=None): + # type: (Optional[Union[AnyStr, IO]], Optional[str]) -> Any + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + """ + if hasattr(data, "read"): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding="utf-8-sig") + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError: + # It might be because the server has an issue, and returned JSON with + # content-type XML.... + # So let's try a JSON load, and if it's still broken + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # The function hack is because Py2.7 messes up with exception + # context otherwise. + _LOGGER.critical("Wasn't XML not JSON, failing") + raise_with_traceback(DeserializationError, "XML is invalid") + raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) + + @classmethod + def deserialize_from_http_generics(cls, body_bytes, headers): + # type: (Optional[Union[AnyStr, IO]], Mapping) -> Any + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + """ + # Try to use content-type from headers if available + content_type = None + if "content-type" in headers: + content_type = headers["content-type"].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + + +try: + basestring # type: ignore + unicode_str = unicode # type: ignore +except NameError: + basestring = str # type: ignore + unicode_str = str # type: ignore + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + + +class UTC(datetime.tzinfo): + """Time Zone info for handling UTC""" + + def utcoffset(self, dt): + """UTF offset for UTC is 0.""" + return datetime.timedelta(0) + + def tzname(self, dt): + """Timestamp representation.""" + return "Z" + + def dst(self, dt): + """No daylight saving for UTC.""" + return datetime.timedelta(hours=1) + + +try: + from datetime import timezone as _FixedOffset +except ImportError: # Python 2.7 + + class _FixedOffset(datetime.tzinfo): # type: ignore + """Fixed offset in minutes east from UTC. + Copy/pasted from Python doc + :param datetime.timedelta offset: offset in timedelta format + """ + + def __init__(self, offset): + self.__offset = offset + + def utcoffset(self, dt): + return self.__offset + + def tzname(self, dt): + return str(self.__offset.total_seconds() / 3600) + + def __repr__(self): + return "".format(self.tzname(None)) + + def dst(self, dt): + return datetime.timedelta(0) + + def __getinitargs__(self): + return (self.__offset,) + + +try: + from datetime import timezone + + TZ_UTC = timezone.utc # type: ignore +except ImportError: + TZ_UTC = UTC() # type: ignore + +_FLATTEN = re.compile(r"(? y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0, + } + + def __init__(self, classes=None): + self.serialize_type = { + "iso-8601": Serializer.serialize_iso, + "rfc-1123": Serializer.serialize_rfc, + "unix-time": Serializer.serialize_unix, + "duration": Serializer.serialize_duration, + "date": Serializer.serialize_date, + "time": Serializer.serialize_time, + "decimal": Serializer.serialize_decimal, + "long": Serializer.serialize_long, + "bytearray": Serializer.serialize_bytearray, + "base64": Serializer.serialize_base64, + "object": self.serialize_object, + "[]": self.serialize_iter, + "{}": self.serialize_dict, + } + self.dependencies = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize(self, target_obj, data_type=None, **kwargs): + """Serialize data into a string according to type. + + :param target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises: SerializationError if serialization fails. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data(target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data(target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() + try: + attributes = target_obj._attribute_map + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get(attr_name, {}).get("readonly", False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == "": + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) + + if is_xml_model_serialization: + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + xml_prefix = xml_desc.get("prefix", None) + xml_ns = xml_desc.get("ns", None) + if xml_desc.get("attr", False): + if xml_ns: + ET.register_namespace(xml_prefix, xml_ns) + xml_name = "{}{}".format(xml_ns, xml_name) + serialized.set(xml_name, new_attr) + continue + if xml_desc.get("text", False): + serialized.text = new_attr + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) + elif isinstance(new_attr, ET.Element): + # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. + if "name" not in getattr(orig_attr, "_xml_map", {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) + else: # That's a basic type + # Integrate namespace if necessary + local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) + local_node.text = unicode_str(new_attr) + serialized.append(local_node) + else: # JSON + for k in reversed(keys): + unflattened = {k: new_attr} + new_attr = unflattened + + _new_attr = new_attr + _serialized = serialized + for k in keys: + if k not in _serialized: + _serialized.update(_new_attr) + _new_attr = _new_attr[k] + _serialized = _serialized[k] + except ValueError: + continue + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) + raise_with_traceback(SerializationError, msg, err) + else: + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises: SerializationError if serialization fails. + :raises: ValueError if data is None + """ + + # Just in case this is a dict + internal_data_type = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + data = deserializer._deserialize(data_type, data) + except DeserializationError as err: + raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + # Treat the list aside, since we don't want to encode the div separator + if data_type.startswith("["): + internal_data_type = data_type[1:-1] + data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] + if not kwargs.get("skip_quote", False): + data = [quote(str(d), safe="") for d in data] + return str(self.serialize_iter(data, internal_data_type, **kwargs)) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + if data_type in ["[str]"]: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :param bool required: Whether it's essential that the data not be + empty or None + :raises: AttributeError if required data is None. + :raises: ValueError if data is None + :raises: SerializationError if serialization fails. + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + elif data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise_with_traceback(SerializationError, msg.format(data, data_type), err) + else: + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param data: Object to be serialized. + :param str data_type: Type of object in the iterable. + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == "str": + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param data: Object to be serialized. + :rtype: str + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + else: + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list attr: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param bool required: Whether the objects in the iterable must + not be None or empty. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + :rtype: list, str + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError: + serialized.append(None) + + if div: + serialized = ["" if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if "xml" in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get("xml", {}) + xml_name = xml_desc.get("name") + if not xml_name: + xml_name = serialization_ctxt["key"] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :param bool required: Whether the objects in the dictionary must + not be None or empty. + :rtype: dict + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + + if "xml" in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt["xml"] + xml_name = xml_desc["name"] + + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) + if obj_type is _long_type: + return self.serialize_long(attr) + if obj_type is unicode_str: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + elif obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object(obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) + return result + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) + + @staticmethod + def serialize_bytearray(attr, **kwargs): + """Serialize bytearray into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): + """Serialize str into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + encoded = b64encode(attr).decode("ascii") + return encoded.strip("=").replace("+", "-").replace("/", "_") + + @staticmethod + def serialize_decimal(attr, **kwargs): + """Serialize Decimal object to float. + + :param attr: Object to be serialized. + :rtype: float + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): + """Serialize long (Py2) or int (Py3). + + :param attr: Object to be serialized. + :rtype: int/long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: TypeError if format invalid. + """ + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError: + raise TypeError("RFC1123 object must be valid Datetime object.") + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], + utc.tm_mday, + Serializer.months[utc.tm_mon], + utc.tm_year, + utc.tm_hour, + utc.tm_min, + utc.tm_sec, + ) + + @staticmethod + def serialize_iso(attr, **kwargs): + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: SerializationError if format invalid. + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") + if microseconds: + microseconds = "." + microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec + ) + return date + microseconds + "Z" + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise_with_traceback(SerializationError, msg, err) + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise_with_traceback(TypeError, msg, err) + + @staticmethod + def serialize_unix(attr, **kwargs): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises: SerializationError if format invalid + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError: + raise TypeError("Unix time object must be valid Datetime object.") + + +def rest_key_extractor(attr, attr_desc, data): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = ".".join(dict_keys[1:]) + + return working_data.get(key) + + +def rest_key_case_insensitive_extractor(attr, attr_desc, data): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = ".".join(dict_keys[1:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + + +def last_rest_key_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key.""" + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + xml_name = internal_type_xml_map.get("name", internal_type.__name__) + xml_ns = internal_type_xml_map.get("ns", None) + if xml_ns: + xml_name = "{}{}".format(xml_ns, xml_name) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + + # Look for a children + is_iter_type = attr_desc["type"].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # Integrate namespace if necessary + xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) + if xml_ns: + xml_name = "{}{}".format(xml_ns, xml_name) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and "name" in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + else: + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + else: # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name + ) + ) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + + +class Deserializer(object): + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") + + def __init__(self, classes=None): + self.deserialize_type = { + "iso-8601": Deserializer.deserialize_iso, + "rfc-1123": Deserializer.deserialize_rfc, + "unix-time": Deserializer.deserialize_unix, + "duration": Deserializer.deserialize_duration, + "date": Deserializer.deserialize_date, + "time": Deserializer.deserialize_time, + "decimal": Deserializer.deserialize_decimal, + "long": Deserializer.deserialize_long, + "bytearray": Deserializer.deserialize_bytearray, + "base64": Deserializer.deserialize_base64, + "object": self.deserialize_object, + "[]": self.deserialize_iter, + "{}": self.deserialize_dict, + } + self.deserialize_expected_types = { + "duration": (isodate.Duration, datetime.timedelta), + "iso-8601": (datetime.datetime), + } + self.dependencies = dict(classes) if classes else {} + self.key_extractors = [rest_key_extractor, xml_key_extractor] + # Additional properties only works if the "rest_key_extractor" is used to + # extract the keys. Making it to work whatever the key extractor is too much + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] + try: + for attr, mapconfig in data._attribute_map.items(): + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig["type"] + internal_data_type = local_type.strip("[]{}") + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr(data, attr, self._deserialize(local_type, value)) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, basestring): + return self.deserialize_data(data, response) + elif isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None: + return data + try: + attributes = response._attribute_map + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == "": + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip("[]{}") + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ( + "Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" + ) + _LOGGER.warning(msg, found_value, key_extractor, attr) + continue + raw_value = found_value + + value = self.deserialize_data(raw_value, attr_desc["type"]) + d_attrs[attr] = value + except (AttributeError, TypeError, KeyError) as err: + msg = "Unable to deserialize to object: " + class_name + raise_with_traceback(DeserializationError, msg, err) + else: + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = { + _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) + for desc in attribute_map.values() + if desc["key"] != "" + } + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + Once classification has been determined, initialize object. + + :param str target: The target object type to deserialize to. + :param str/dict data: The response data to deseralize. + """ + if target is None: + return None, None + + if isinstance(target, basestring): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + a deserialization error. + + :param str target_obj: The target object type to deserialize to. + :param str/dict data: The response data to deseralize. + :param str content_type: Swagger "produces" if available. + """ + try: + return self(target_obj, data, content_type=content_type) + except: + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param raw_data: Data to be processed. + :param content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + # Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) + + # Assume this enough to recognize requests.Response without importing it. + if hasattr(raw_data, "_content_consumed"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) + + if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): + return RawDeserializer.deserialize_from_text(raw_data, content_type) + return raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param response: The response model class. + :param d_attrs: The deserialized response attributes. + """ + if callable(response): + subtype = getattr(response, "_subtype_map", {}) + try: + readonly = [k for k, v in response._validation.items() if v.get("readonly")] + const = [k for k, v in response._validation.items() if v.get("constant")] + kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) + raise DeserializationError(msg + str(err)) + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) + + def deserialize_data(self, data, data_type): + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise_with_traceback(DeserializationError, msg, err) + else: + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :rtype: dict + :raises: TypeError if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, basestring): + return self.deserialize_basic(attr, "str") + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object(value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object(obj, **kwargs)) + except ValueError: + pass + return deserialized + + else: + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :rtype: str, int, float or bool + :raises: TypeError if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return "" + else: + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == "bool": + if attr in [True, False, 1, 0]: + return bool(attr) + elif isinstance(attr, basestring): + if attr.lower() in ["true", "1"]: + return True + elif attr.lower() in ["false", "0"]: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == "str": + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): + return data + except NameError: + return str(data) + else: + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + data = data.value + if isinstance(data, int): + # Workaround. We might consider remove it in the future. + # https://github.com/Azure/azure-rest-api-specs/issues/141 + try: + return list(enum_obj.__members__.values())[data] + except IndexError: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = "=" * (3 - (len(attr) + 3) % 4) + attr = attr + padding + encoded = attr.replace("-", "+").replace("_", "/") + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :rtype: Decimal + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(attr) + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise_with_traceback(DeserializationError, msg, err) + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :rtype: long or int + :raises: ValueError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :rtype: TimeDelta + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise_with_traceback(DeserializationError, msg, err) + else: + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :rtype: Date + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + return isodate.parse_date(attr, defaultmonth=None, defaultday=None) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) + date_obj = datetime.datetime( + *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :rtype: Datetime + :raises: DeserializationError if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) + try: + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj diff --git a/sdk/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 d087e633477c..d08e0bad4ff8 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 @@ -9,20 +9,94 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models from ._configuration import SynapseManagementClientConfiguration -from .operations import AzureADOnlyAuthenticationsOperations, BigDataPoolsOperations, DataMaskingPoliciesOperations, DataMaskingRulesOperations, ExtendedSqlPoolBlobAuditingPoliciesOperations, IntegrationRuntimeAuthKeysOperations, IntegrationRuntimeConnectionInfosOperations, IntegrationRuntimeCredentialsOperations, IntegrationRuntimeMonitoringDataOperations, IntegrationRuntimeNodeIpAddressOperations, IntegrationRuntimeNodesOperations, IntegrationRuntimeObjectMetadataOperations, IntegrationRuntimeStatusOperations, IntegrationRuntimesOperations, IpFirewallRulesOperations, KeysOperations, KustoOperationsOperations, KustoPoolAttachedDatabaseConfigurationsOperations, KustoPoolChildResourceOperations, KustoPoolDataConnectionsOperations, KustoPoolDatabasePrincipalAssignmentsOperations, KustoPoolDatabasesOperations, KustoPoolPrincipalAssignmentsOperations, KustoPoolsOperations, LibrariesOperations, LibraryOperations, Operations, PrivateEndpointConnectionsOperations, PrivateEndpointConnectionsPrivateLinkHubOperations, PrivateLinkHubPrivateLinkResourcesOperations, PrivateLinkHubsOperations, PrivateLinkResourcesOperations, RestorableDroppedSqlPoolsOperations, SparkConfigurationOperations, SparkConfigurationsOperations, SqlPoolBlobAuditingPoliciesOperations, SqlPoolColumnsOperations, SqlPoolConnectionPoliciesOperations, SqlPoolDataWarehouseUserActivitiesOperations, SqlPoolGeoBackupPoliciesOperations, SqlPoolMaintenanceWindowOptionsOperations, SqlPoolMaintenanceWindowsOperations, SqlPoolMetadataSyncConfigsOperations, SqlPoolOperationResultsOperations, SqlPoolOperationsOperations, SqlPoolRecommendedSensitivityLabelsOperations, SqlPoolReplicationLinksOperations, SqlPoolRestorePointsOperations, SqlPoolSchemasOperations, SqlPoolSecurityAlertPoliciesOperations, SqlPoolSensitivityLabelsOperations, SqlPoolTableColumnsOperations, SqlPoolTablesOperations, SqlPoolTransparentDataEncryptionsOperations, SqlPoolUsagesOperations, SqlPoolVulnerabilityAssessmentRuleBaselinesOperations, SqlPoolVulnerabilityAssessmentScansOperations, SqlPoolVulnerabilityAssessmentsOperations, SqlPoolWorkloadClassifierOperations, SqlPoolWorkloadGroupOperations, SqlPoolsOperations, WorkspaceAadAdminsOperations, WorkspaceManagedIdentitySqlControlSettingsOperations, WorkspaceManagedSqlServerBlobAuditingPoliciesOperations, WorkspaceManagedSqlServerDedicatedSQLMinimalTlsSettingsOperations, WorkspaceManagedSqlServerEncryptionProtectorOperations, WorkspaceManagedSqlServerExtendedBlobAuditingPoliciesOperations, WorkspaceManagedSqlServerRecoverableSqlPoolsOperations, WorkspaceManagedSqlServerSecurityAlertPolicyOperations, WorkspaceManagedSqlServerUsagesOperations, WorkspaceManagedSqlServerVulnerabilityAssessmentsOperations, WorkspaceSqlAadAdminsOperations, WorkspacesOperations +from ._serialization import Deserializer, Serializer +from .operations import ( + AzureADOnlyAuthenticationsOperations, + BigDataPoolsOperations, + DataMaskingPoliciesOperations, + DataMaskingRulesOperations, + ExtendedSqlPoolBlobAuditingPoliciesOperations, + IntegrationRuntimeAuthKeysOperations, + IntegrationRuntimeConnectionInfosOperations, + IntegrationRuntimeCredentialsOperations, + IntegrationRuntimeMonitoringDataOperations, + IntegrationRuntimeNodeIpAddressOperations, + IntegrationRuntimeNodesOperations, + IntegrationRuntimeObjectMetadataOperations, + IntegrationRuntimeStatusOperations, + IntegrationRuntimesOperations, + IpFirewallRulesOperations, + KeysOperations, + KustoOperationsOperations, + KustoPoolAttachedDatabaseConfigurationsOperations, + KustoPoolChildResourceOperations, + KustoPoolDataConnectionsOperations, + KustoPoolDatabasePrincipalAssignmentsOperations, + KustoPoolDatabasesOperations, + KustoPoolPrincipalAssignmentsOperations, + KustoPoolsOperations, + LibrariesOperations, + LibraryOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateEndpointConnectionsPrivateLinkHubOperations, + PrivateLinkHubPrivateLinkResourcesOperations, + PrivateLinkHubsOperations, + PrivateLinkResourcesOperations, + RestorableDroppedSqlPoolsOperations, + SparkConfigurationOperations, + SparkConfigurationsOperations, + SqlPoolBlobAuditingPoliciesOperations, + SqlPoolColumnsOperations, + SqlPoolConnectionPoliciesOperations, + SqlPoolDataWarehouseUserActivitiesOperations, + SqlPoolGeoBackupPoliciesOperations, + SqlPoolMaintenanceWindowOptionsOperations, + SqlPoolMaintenanceWindowsOperations, + SqlPoolMetadataSyncConfigsOperations, + SqlPoolOperationResultsOperations, + SqlPoolOperationsOperations, + SqlPoolRecommendedSensitivityLabelsOperations, + SqlPoolReplicationLinksOperations, + SqlPoolRestorePointsOperations, + SqlPoolSchemasOperations, + SqlPoolSecurityAlertPoliciesOperations, + SqlPoolSensitivityLabelsOperations, + SqlPoolTableColumnsOperations, + SqlPoolTablesOperations, + SqlPoolTransparentDataEncryptionsOperations, + SqlPoolUsagesOperations, + SqlPoolVulnerabilityAssessmentRuleBaselinesOperations, + SqlPoolVulnerabilityAssessmentScansOperations, + SqlPoolVulnerabilityAssessmentsOperations, + SqlPoolWorkloadClassifierOperations, + SqlPoolWorkloadGroupOperations, + SqlPoolsOperations, + WorkspaceAadAdminsOperations, + WorkspaceManagedIdentitySqlControlSettingsOperations, + WorkspaceManagedSqlServerBlobAuditingPoliciesOperations, + WorkspaceManagedSqlServerDedicatedSQLMinimalTlsSettingsOperations, + WorkspaceManagedSqlServerEncryptionProtectorOperations, + WorkspaceManagedSqlServerExtendedBlobAuditingPoliciesOperations, + WorkspaceManagedSqlServerRecoverableSqlPoolsOperations, + WorkspaceManagedSqlServerSecurityAlertPolicyOperations, + WorkspaceManagedSqlServerUsagesOperations, + WorkspaceManagedSqlServerVulnerabilityAssessmentsOperations, + WorkspaceSqlAadAdminsOperations, + WorkspacesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class SynapseManagementClient: # pylint: disable=too-many-instance-attributes + +class SynapseManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Azure Synapse Analytics Management Client. :ivar azure_ad_only_authentications: AzureADOnlyAuthenticationsOperations operations @@ -238,9 +312,9 @@ class SynapseManagementClient: # pylint: disable=too-many-instance-attributes KustoPoolDatabasePrincipalAssignmentsOperations operations :vartype kusto_pool_database_principal_assignments: azure.mgmt.synapse.operations.KustoPoolDatabasePrincipalAssignmentsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -255,93 +329,224 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = SynapseManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = SynapseManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.azure_ad_only_authentications = AzureADOnlyAuthenticationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.azure_ad_only_authentications = AzureADOnlyAuthenticationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.ip_firewall_rules = IpFirewallRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.ip_firewall_rules = IpFirewallRulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.keys = KeysOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_hub_private_link_resources = PrivateLinkHubPrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_hubs = PrivateLinkHubsOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections_private_link_hub = PrivateEndpointConnectionsPrivateLinkHubOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_link_hub_private_link_resources = PrivateLinkHubPrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_link_hubs = PrivateLinkHubsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_endpoint_connections_private_link_hub = PrivateEndpointConnectionsPrivateLinkHubOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.sql_pools = SqlPoolsOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_metadata_sync_configs = SqlPoolMetadataSyncConfigsOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_operation_results = SqlPoolOperationResultsOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_geo_backup_policies = SqlPoolGeoBackupPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_data_warehouse_user_activities = SqlPoolDataWarehouseUserActivitiesOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_restore_points = SqlPoolRestorePointsOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_replication_links = SqlPoolReplicationLinksOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_maintenance_windows = SqlPoolMaintenanceWindowsOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_maintenance_window_options = SqlPoolMaintenanceWindowOptionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_transparent_data_encryptions = SqlPoolTransparentDataEncryptionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_blob_auditing_policies = SqlPoolBlobAuditingPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_operations = SqlPoolOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.sql_pool_metadata_sync_configs = SqlPoolMetadataSyncConfigsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_pool_operation_results = SqlPoolOperationResultsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_pool_geo_backup_policies = SqlPoolGeoBackupPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_pool_data_warehouse_user_activities = SqlPoolDataWarehouseUserActivitiesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_pool_restore_points = SqlPoolRestorePointsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_pool_replication_links = SqlPoolReplicationLinksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_pool_maintenance_windows = SqlPoolMaintenanceWindowsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_pool_maintenance_window_options = SqlPoolMaintenanceWindowOptionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_pool_transparent_data_encryptions = SqlPoolTransparentDataEncryptionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_pool_blob_auditing_policies = SqlPoolBlobAuditingPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_pool_operations = SqlPoolOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.sql_pool_usages = SqlPoolUsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_sensitivity_labels = SqlPoolSensitivityLabelsOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_recommended_sensitivity_labels = SqlPoolRecommendedSensitivityLabelsOperations(self._client, self._config, self._serialize, self._deserialize) + self.sql_pool_sensitivity_labels = SqlPoolSensitivityLabelsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_pool_recommended_sensitivity_labels = SqlPoolRecommendedSensitivityLabelsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.sql_pool_schemas = SqlPoolSchemasOperations(self._client, self._config, self._serialize, self._deserialize) self.sql_pool_tables = SqlPoolTablesOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_table_columns = SqlPoolTableColumnsOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_connection_policies = SqlPoolConnectionPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_vulnerability_assessments = SqlPoolVulnerabilityAssessmentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_vulnerability_assessment_scans = SqlPoolVulnerabilityAssessmentScansOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_security_alert_policies = SqlPoolSecurityAlertPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_vulnerability_assessment_rule_baselines = SqlPoolVulnerabilityAssessmentRuleBaselinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.extended_sql_pool_blob_auditing_policies = ExtendedSqlPoolBlobAuditingPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.data_masking_policies = DataMaskingPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.data_masking_rules = DataMaskingRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.sql_pool_table_columns = SqlPoolTableColumnsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_pool_connection_policies = SqlPoolConnectionPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_pool_vulnerability_assessments = SqlPoolVulnerabilityAssessmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_pool_vulnerability_assessment_scans = SqlPoolVulnerabilityAssessmentScansOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_pool_security_alert_policies = SqlPoolSecurityAlertPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_pool_vulnerability_assessment_rule_baselines = SqlPoolVulnerabilityAssessmentRuleBaselinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.extended_sql_pool_blob_auditing_policies = ExtendedSqlPoolBlobAuditingPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.data_masking_policies = DataMaskingPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.data_masking_rules = DataMaskingRulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.sql_pool_columns = SqlPoolColumnsOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_workload_group = SqlPoolWorkloadGroupOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_workload_classifier = SqlPoolWorkloadClassifierOperations(self._client, self._config, self._serialize, self._deserialize) - self.workspace_managed_sql_server_blob_auditing_policies = WorkspaceManagedSqlServerBlobAuditingPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.workspace_managed_sql_server_extended_blob_auditing_policies = WorkspaceManagedSqlServerExtendedBlobAuditingPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.workspace_managed_sql_server_security_alert_policy = WorkspaceManagedSqlServerSecurityAlertPolicyOperations(self._client, self._config, self._serialize, self._deserialize) - self.workspace_managed_sql_server_vulnerability_assessments = WorkspaceManagedSqlServerVulnerabilityAssessmentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.workspace_managed_sql_server_encryption_protector = WorkspaceManagedSqlServerEncryptionProtectorOperations(self._client, self._config, self._serialize, self._deserialize) - self.workspace_managed_sql_server_usages = WorkspaceManagedSqlServerUsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.workspace_managed_sql_server_recoverable_sql_pools = WorkspaceManagedSqlServerRecoverableSqlPoolsOperations(self._client, self._config, self._serialize, self._deserialize) - self.workspace_managed_sql_server_dedicated_sql_minimal_tls_settings = WorkspaceManagedSqlServerDedicatedSQLMinimalTlsSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.sql_pool_workload_group = SqlPoolWorkloadGroupOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_pool_workload_classifier = SqlPoolWorkloadClassifierOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_managed_sql_server_blob_auditing_policies = ( + WorkspaceManagedSqlServerBlobAuditingPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + ) + self.workspace_managed_sql_server_extended_blob_auditing_policies = ( + WorkspaceManagedSqlServerExtendedBlobAuditingPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + ) + self.workspace_managed_sql_server_security_alert_policy = ( + WorkspaceManagedSqlServerSecurityAlertPolicyOperations( + self._client, self._config, self._serialize, self._deserialize + ) + ) + self.workspace_managed_sql_server_vulnerability_assessments = ( + WorkspaceManagedSqlServerVulnerabilityAssessmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + ) + self.workspace_managed_sql_server_encryption_protector = WorkspaceManagedSqlServerEncryptionProtectorOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_managed_sql_server_usages = WorkspaceManagedSqlServerUsagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_managed_sql_server_recoverable_sql_pools = ( + WorkspaceManagedSqlServerRecoverableSqlPoolsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + ) + self.workspace_managed_sql_server_dedicated_sql_minimal_tls_settings = ( + WorkspaceManagedSqlServerDedicatedSQLMinimalTlsSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + ) self.workspaces = WorkspacesOperations(self._client, self._config, self._serialize, self._deserialize) - self.workspace_aad_admins = WorkspaceAadAdminsOperations(self._client, self._config, self._serialize, self._deserialize) - self.workspace_sql_aad_admins = WorkspaceSqlAadAdminsOperations(self._client, self._config, self._serialize, self._deserialize) - self.workspace_managed_identity_sql_control_settings = WorkspaceManagedIdentitySqlControlSettingsOperations(self._client, self._config, self._serialize, self._deserialize) - self.restorable_dropped_sql_pools = RestorableDroppedSqlPoolsOperations(self._client, self._config, self._serialize, self._deserialize) + self.workspace_aad_admins = WorkspaceAadAdminsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_sql_aad_admins = WorkspaceSqlAadAdminsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_managed_identity_sql_control_settings = WorkspaceManagedIdentitySqlControlSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.restorable_dropped_sql_pools = RestorableDroppedSqlPoolsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.big_data_pools = BigDataPoolsOperations(self._client, self._config, self._serialize, self._deserialize) self.library = LibraryOperations(self._client, self._config, self._serialize, self._deserialize) self.libraries = LibrariesOperations(self._client, self._config, self._serialize, self._deserialize) - self.integration_runtimes = IntegrationRuntimesOperations(self._client, self._config, self._serialize, self._deserialize) - self.integration_runtime_node_ip_address = IntegrationRuntimeNodeIpAddressOperations(self._client, self._config, self._serialize, self._deserialize) - self.integration_runtime_object_metadata = IntegrationRuntimeObjectMetadataOperations(self._client, self._config, self._serialize, self._deserialize) - self.integration_runtime_nodes = IntegrationRuntimeNodesOperations(self._client, self._config, self._serialize, self._deserialize) - self.integration_runtime_credentials = IntegrationRuntimeCredentialsOperations(self._client, self._config, self._serialize, self._deserialize) - self.integration_runtime_connection_infos = IntegrationRuntimeConnectionInfosOperations(self._client, self._config, self._serialize, self._deserialize) - self.integration_runtime_auth_keys = IntegrationRuntimeAuthKeysOperations(self._client, self._config, self._serialize, self._deserialize) - self.integration_runtime_monitoring_data = IntegrationRuntimeMonitoringDataOperations(self._client, self._config, self._serialize, self._deserialize) - self.integration_runtime_status = IntegrationRuntimeStatusOperations(self._client, self._config, self._serialize, self._deserialize) - self.spark_configuration = SparkConfigurationOperations(self._client, self._config, self._serialize, self._deserialize) - self.spark_configurations = SparkConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.kusto_operations = KustoOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.integration_runtimes = IntegrationRuntimesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.integration_runtime_node_ip_address = IntegrationRuntimeNodeIpAddressOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.integration_runtime_object_metadata = IntegrationRuntimeObjectMetadataOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.integration_runtime_nodes = IntegrationRuntimeNodesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.integration_runtime_credentials = IntegrationRuntimeCredentialsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.integration_runtime_connection_infos = IntegrationRuntimeConnectionInfosOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.integration_runtime_auth_keys = IntegrationRuntimeAuthKeysOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.integration_runtime_monitoring_data = IntegrationRuntimeMonitoringDataOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.integration_runtime_status = IntegrationRuntimeStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.spark_configuration = SparkConfigurationOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.spark_configurations = SparkConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.kusto_operations = KustoOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.kusto_pools = KustoPoolsOperations(self._client, self._config, self._serialize, self._deserialize) - self.kusto_pool_child_resource = KustoPoolChildResourceOperations(self._client, self._config, self._serialize, self._deserialize) - self.kusto_pool_attached_database_configurations = KustoPoolAttachedDatabaseConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.kusto_pool_databases = KustoPoolDatabasesOperations(self._client, self._config, self._serialize, self._deserialize) - self.kusto_pool_data_connections = KustoPoolDataConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.kusto_pool_principal_assignments = KustoPoolPrincipalAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.kusto_pool_database_principal_assignments = KustoPoolDatabasePrincipalAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.kusto_pool_child_resource = KustoPoolChildResourceOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.kusto_pool_attached_database_configurations = KustoPoolAttachedDatabaseConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.kusto_pool_databases = KustoPoolDatabasesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.kusto_pool_data_connections = KustoPoolDataConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.kusto_pool_principal_assignments = KustoPoolPrincipalAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.kusto_pool_database_principal_assignments = KustoPoolDatabasePrincipalAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -350,7 +555,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/_vendor.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/_vendor.py +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/_version.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/_version.py index 7a9c1bff5507..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.0b5" +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 e7037d2468da..a07439a33a54 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 @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._synapse_management_client import SynapseManagementClient -__all__ = ['SynapseManagementClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["SynapseManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_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 0f8ff9326a9a..9a0dcc6811dd 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 @@ -25,18 +25,13 @@ class SynapseManagementClientConfiguration(Configuration): # pylint: disable=to Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + 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.") @@ -45,22 +40,21 @@ def __init__( self.credential = credential 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.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-synapse/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/_patch.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/_patch.py index 74e48ecd07cf..f99e77fef986 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 @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/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 f483e6644d59..8c70aa8eaef1 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 @@ -9,20 +9,94 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from .._serialization import Deserializer, Serializer from ._configuration import SynapseManagementClientConfiguration -from .operations import AzureADOnlyAuthenticationsOperations, BigDataPoolsOperations, DataMaskingPoliciesOperations, DataMaskingRulesOperations, ExtendedSqlPoolBlobAuditingPoliciesOperations, IntegrationRuntimeAuthKeysOperations, IntegrationRuntimeConnectionInfosOperations, IntegrationRuntimeCredentialsOperations, IntegrationRuntimeMonitoringDataOperations, IntegrationRuntimeNodeIpAddressOperations, IntegrationRuntimeNodesOperations, IntegrationRuntimeObjectMetadataOperations, IntegrationRuntimeStatusOperations, IntegrationRuntimesOperations, IpFirewallRulesOperations, KeysOperations, KustoOperationsOperations, KustoPoolAttachedDatabaseConfigurationsOperations, KustoPoolChildResourceOperations, KustoPoolDataConnectionsOperations, KustoPoolDatabasePrincipalAssignmentsOperations, KustoPoolDatabasesOperations, KustoPoolPrincipalAssignmentsOperations, KustoPoolsOperations, LibrariesOperations, LibraryOperations, Operations, PrivateEndpointConnectionsOperations, PrivateEndpointConnectionsPrivateLinkHubOperations, PrivateLinkHubPrivateLinkResourcesOperations, PrivateLinkHubsOperations, PrivateLinkResourcesOperations, RestorableDroppedSqlPoolsOperations, SparkConfigurationOperations, SparkConfigurationsOperations, SqlPoolBlobAuditingPoliciesOperations, SqlPoolColumnsOperations, SqlPoolConnectionPoliciesOperations, SqlPoolDataWarehouseUserActivitiesOperations, SqlPoolGeoBackupPoliciesOperations, SqlPoolMaintenanceWindowOptionsOperations, SqlPoolMaintenanceWindowsOperations, SqlPoolMetadataSyncConfigsOperations, SqlPoolOperationResultsOperations, SqlPoolOperationsOperations, SqlPoolRecommendedSensitivityLabelsOperations, SqlPoolReplicationLinksOperations, SqlPoolRestorePointsOperations, SqlPoolSchemasOperations, SqlPoolSecurityAlertPoliciesOperations, SqlPoolSensitivityLabelsOperations, SqlPoolTableColumnsOperations, SqlPoolTablesOperations, SqlPoolTransparentDataEncryptionsOperations, SqlPoolUsagesOperations, SqlPoolVulnerabilityAssessmentRuleBaselinesOperations, SqlPoolVulnerabilityAssessmentScansOperations, SqlPoolVulnerabilityAssessmentsOperations, SqlPoolWorkloadClassifierOperations, SqlPoolWorkloadGroupOperations, SqlPoolsOperations, WorkspaceAadAdminsOperations, WorkspaceManagedIdentitySqlControlSettingsOperations, WorkspaceManagedSqlServerBlobAuditingPoliciesOperations, WorkspaceManagedSqlServerDedicatedSQLMinimalTlsSettingsOperations, WorkspaceManagedSqlServerEncryptionProtectorOperations, WorkspaceManagedSqlServerExtendedBlobAuditingPoliciesOperations, WorkspaceManagedSqlServerRecoverableSqlPoolsOperations, WorkspaceManagedSqlServerSecurityAlertPolicyOperations, WorkspaceManagedSqlServerUsagesOperations, WorkspaceManagedSqlServerVulnerabilityAssessmentsOperations, WorkspaceSqlAadAdminsOperations, WorkspacesOperations +from .operations import ( + AzureADOnlyAuthenticationsOperations, + BigDataPoolsOperations, + DataMaskingPoliciesOperations, + DataMaskingRulesOperations, + ExtendedSqlPoolBlobAuditingPoliciesOperations, + IntegrationRuntimeAuthKeysOperations, + IntegrationRuntimeConnectionInfosOperations, + IntegrationRuntimeCredentialsOperations, + IntegrationRuntimeMonitoringDataOperations, + IntegrationRuntimeNodeIpAddressOperations, + IntegrationRuntimeNodesOperations, + IntegrationRuntimeObjectMetadataOperations, + IntegrationRuntimeStatusOperations, + IntegrationRuntimesOperations, + IpFirewallRulesOperations, + KeysOperations, + KustoOperationsOperations, + KustoPoolAttachedDatabaseConfigurationsOperations, + KustoPoolChildResourceOperations, + KustoPoolDataConnectionsOperations, + KustoPoolDatabasePrincipalAssignmentsOperations, + KustoPoolDatabasesOperations, + KustoPoolPrincipalAssignmentsOperations, + KustoPoolsOperations, + LibrariesOperations, + LibraryOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateEndpointConnectionsPrivateLinkHubOperations, + PrivateLinkHubPrivateLinkResourcesOperations, + PrivateLinkHubsOperations, + PrivateLinkResourcesOperations, + RestorableDroppedSqlPoolsOperations, + SparkConfigurationOperations, + SparkConfigurationsOperations, + SqlPoolBlobAuditingPoliciesOperations, + SqlPoolColumnsOperations, + SqlPoolConnectionPoliciesOperations, + SqlPoolDataWarehouseUserActivitiesOperations, + SqlPoolGeoBackupPoliciesOperations, + SqlPoolMaintenanceWindowOptionsOperations, + SqlPoolMaintenanceWindowsOperations, + SqlPoolMetadataSyncConfigsOperations, + SqlPoolOperationResultsOperations, + SqlPoolOperationsOperations, + SqlPoolRecommendedSensitivityLabelsOperations, + SqlPoolReplicationLinksOperations, + SqlPoolRestorePointsOperations, + SqlPoolSchemasOperations, + SqlPoolSecurityAlertPoliciesOperations, + SqlPoolSensitivityLabelsOperations, + SqlPoolTableColumnsOperations, + SqlPoolTablesOperations, + SqlPoolTransparentDataEncryptionsOperations, + SqlPoolUsagesOperations, + SqlPoolVulnerabilityAssessmentRuleBaselinesOperations, + SqlPoolVulnerabilityAssessmentScansOperations, + SqlPoolVulnerabilityAssessmentsOperations, + SqlPoolWorkloadClassifierOperations, + SqlPoolWorkloadGroupOperations, + SqlPoolsOperations, + WorkspaceAadAdminsOperations, + WorkspaceManagedIdentitySqlControlSettingsOperations, + WorkspaceManagedSqlServerBlobAuditingPoliciesOperations, + WorkspaceManagedSqlServerDedicatedSQLMinimalTlsSettingsOperations, + WorkspaceManagedSqlServerEncryptionProtectorOperations, + WorkspaceManagedSqlServerExtendedBlobAuditingPoliciesOperations, + WorkspaceManagedSqlServerRecoverableSqlPoolsOperations, + WorkspaceManagedSqlServerSecurityAlertPolicyOperations, + WorkspaceManagedSqlServerUsagesOperations, + WorkspaceManagedSqlServerVulnerabilityAssessmentsOperations, + WorkspaceSqlAadAdminsOperations, + WorkspacesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class SynapseManagementClient: # pylint: disable=too-many-instance-attributes + +class SynapseManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Azure Synapse Analytics Management Client. :ivar azure_ad_only_authentications: AzureADOnlyAuthenticationsOperations operations @@ -242,9 +316,9 @@ class SynapseManagementClient: # pylint: disable=too-many-instance-attributes KustoPoolDatabasePrincipalAssignmentsOperations operations :vartype kusto_pool_database_principal_assignments: azure.mgmt.synapse.aio.operations.KustoPoolDatabasePrincipalAssignmentsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -259,93 +333,224 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = SynapseManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = SynapseManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.azure_ad_only_authentications = AzureADOnlyAuthenticationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.azure_ad_only_authentications = AzureADOnlyAuthenticationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.ip_firewall_rules = IpFirewallRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.ip_firewall_rules = IpFirewallRulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.keys = KeysOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_hub_private_link_resources = PrivateLinkHubPrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_hubs = PrivateLinkHubsOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections_private_link_hub = PrivateEndpointConnectionsPrivateLinkHubOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_link_hub_private_link_resources = PrivateLinkHubPrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_link_hubs = PrivateLinkHubsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_endpoint_connections_private_link_hub = PrivateEndpointConnectionsPrivateLinkHubOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.sql_pools = SqlPoolsOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_metadata_sync_configs = SqlPoolMetadataSyncConfigsOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_operation_results = SqlPoolOperationResultsOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_geo_backup_policies = SqlPoolGeoBackupPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_data_warehouse_user_activities = SqlPoolDataWarehouseUserActivitiesOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_restore_points = SqlPoolRestorePointsOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_replication_links = SqlPoolReplicationLinksOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_maintenance_windows = SqlPoolMaintenanceWindowsOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_maintenance_window_options = SqlPoolMaintenanceWindowOptionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_transparent_data_encryptions = SqlPoolTransparentDataEncryptionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_blob_auditing_policies = SqlPoolBlobAuditingPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_operations = SqlPoolOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.sql_pool_metadata_sync_configs = SqlPoolMetadataSyncConfigsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_pool_operation_results = SqlPoolOperationResultsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_pool_geo_backup_policies = SqlPoolGeoBackupPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_pool_data_warehouse_user_activities = SqlPoolDataWarehouseUserActivitiesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_pool_restore_points = SqlPoolRestorePointsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_pool_replication_links = SqlPoolReplicationLinksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_pool_maintenance_windows = SqlPoolMaintenanceWindowsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_pool_maintenance_window_options = SqlPoolMaintenanceWindowOptionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_pool_transparent_data_encryptions = SqlPoolTransparentDataEncryptionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_pool_blob_auditing_policies = SqlPoolBlobAuditingPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_pool_operations = SqlPoolOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.sql_pool_usages = SqlPoolUsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_sensitivity_labels = SqlPoolSensitivityLabelsOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_recommended_sensitivity_labels = SqlPoolRecommendedSensitivityLabelsOperations(self._client, self._config, self._serialize, self._deserialize) + self.sql_pool_sensitivity_labels = SqlPoolSensitivityLabelsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_pool_recommended_sensitivity_labels = SqlPoolRecommendedSensitivityLabelsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.sql_pool_schemas = SqlPoolSchemasOperations(self._client, self._config, self._serialize, self._deserialize) self.sql_pool_tables = SqlPoolTablesOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_table_columns = SqlPoolTableColumnsOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_connection_policies = SqlPoolConnectionPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_vulnerability_assessments = SqlPoolVulnerabilityAssessmentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_vulnerability_assessment_scans = SqlPoolVulnerabilityAssessmentScansOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_security_alert_policies = SqlPoolSecurityAlertPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_vulnerability_assessment_rule_baselines = SqlPoolVulnerabilityAssessmentRuleBaselinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.extended_sql_pool_blob_auditing_policies = ExtendedSqlPoolBlobAuditingPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.data_masking_policies = DataMaskingPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.data_masking_rules = DataMaskingRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.sql_pool_table_columns = SqlPoolTableColumnsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_pool_connection_policies = SqlPoolConnectionPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_pool_vulnerability_assessments = SqlPoolVulnerabilityAssessmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_pool_vulnerability_assessment_scans = SqlPoolVulnerabilityAssessmentScansOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_pool_security_alert_policies = SqlPoolSecurityAlertPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_pool_vulnerability_assessment_rule_baselines = SqlPoolVulnerabilityAssessmentRuleBaselinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.extended_sql_pool_blob_auditing_policies = ExtendedSqlPoolBlobAuditingPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.data_masking_policies = DataMaskingPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.data_masking_rules = DataMaskingRulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.sql_pool_columns = SqlPoolColumnsOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_workload_group = SqlPoolWorkloadGroupOperations(self._client, self._config, self._serialize, self._deserialize) - self.sql_pool_workload_classifier = SqlPoolWorkloadClassifierOperations(self._client, self._config, self._serialize, self._deserialize) - self.workspace_managed_sql_server_blob_auditing_policies = WorkspaceManagedSqlServerBlobAuditingPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.workspace_managed_sql_server_extended_blob_auditing_policies = WorkspaceManagedSqlServerExtendedBlobAuditingPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.workspace_managed_sql_server_security_alert_policy = WorkspaceManagedSqlServerSecurityAlertPolicyOperations(self._client, self._config, self._serialize, self._deserialize) - self.workspace_managed_sql_server_vulnerability_assessments = WorkspaceManagedSqlServerVulnerabilityAssessmentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.workspace_managed_sql_server_encryption_protector = WorkspaceManagedSqlServerEncryptionProtectorOperations(self._client, self._config, self._serialize, self._deserialize) - self.workspace_managed_sql_server_usages = WorkspaceManagedSqlServerUsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.workspace_managed_sql_server_recoverable_sql_pools = WorkspaceManagedSqlServerRecoverableSqlPoolsOperations(self._client, self._config, self._serialize, self._deserialize) - self.workspace_managed_sql_server_dedicated_sql_minimal_tls_settings = WorkspaceManagedSqlServerDedicatedSQLMinimalTlsSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.sql_pool_workload_group = SqlPoolWorkloadGroupOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.sql_pool_workload_classifier = SqlPoolWorkloadClassifierOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_managed_sql_server_blob_auditing_policies = ( + WorkspaceManagedSqlServerBlobAuditingPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + ) + self.workspace_managed_sql_server_extended_blob_auditing_policies = ( + WorkspaceManagedSqlServerExtendedBlobAuditingPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + ) + self.workspace_managed_sql_server_security_alert_policy = ( + WorkspaceManagedSqlServerSecurityAlertPolicyOperations( + self._client, self._config, self._serialize, self._deserialize + ) + ) + self.workspace_managed_sql_server_vulnerability_assessments = ( + WorkspaceManagedSqlServerVulnerabilityAssessmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + ) + self.workspace_managed_sql_server_encryption_protector = WorkspaceManagedSqlServerEncryptionProtectorOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_managed_sql_server_usages = WorkspaceManagedSqlServerUsagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_managed_sql_server_recoverable_sql_pools = ( + WorkspaceManagedSqlServerRecoverableSqlPoolsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + ) + self.workspace_managed_sql_server_dedicated_sql_minimal_tls_settings = ( + WorkspaceManagedSqlServerDedicatedSQLMinimalTlsSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + ) self.workspaces = WorkspacesOperations(self._client, self._config, self._serialize, self._deserialize) - self.workspace_aad_admins = WorkspaceAadAdminsOperations(self._client, self._config, self._serialize, self._deserialize) - self.workspace_sql_aad_admins = WorkspaceSqlAadAdminsOperations(self._client, self._config, self._serialize, self._deserialize) - self.workspace_managed_identity_sql_control_settings = WorkspaceManagedIdentitySqlControlSettingsOperations(self._client, self._config, self._serialize, self._deserialize) - self.restorable_dropped_sql_pools = RestorableDroppedSqlPoolsOperations(self._client, self._config, self._serialize, self._deserialize) + self.workspace_aad_admins = WorkspaceAadAdminsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_sql_aad_admins = WorkspaceSqlAadAdminsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_managed_identity_sql_control_settings = WorkspaceManagedIdentitySqlControlSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.restorable_dropped_sql_pools = RestorableDroppedSqlPoolsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.big_data_pools = BigDataPoolsOperations(self._client, self._config, self._serialize, self._deserialize) self.library = LibraryOperations(self._client, self._config, self._serialize, self._deserialize) self.libraries = LibrariesOperations(self._client, self._config, self._serialize, self._deserialize) - self.integration_runtimes = IntegrationRuntimesOperations(self._client, self._config, self._serialize, self._deserialize) - self.integration_runtime_node_ip_address = IntegrationRuntimeNodeIpAddressOperations(self._client, self._config, self._serialize, self._deserialize) - self.integration_runtime_object_metadata = IntegrationRuntimeObjectMetadataOperations(self._client, self._config, self._serialize, self._deserialize) - self.integration_runtime_nodes = IntegrationRuntimeNodesOperations(self._client, self._config, self._serialize, self._deserialize) - self.integration_runtime_credentials = IntegrationRuntimeCredentialsOperations(self._client, self._config, self._serialize, self._deserialize) - self.integration_runtime_connection_infos = IntegrationRuntimeConnectionInfosOperations(self._client, self._config, self._serialize, self._deserialize) - self.integration_runtime_auth_keys = IntegrationRuntimeAuthKeysOperations(self._client, self._config, self._serialize, self._deserialize) - self.integration_runtime_monitoring_data = IntegrationRuntimeMonitoringDataOperations(self._client, self._config, self._serialize, self._deserialize) - self.integration_runtime_status = IntegrationRuntimeStatusOperations(self._client, self._config, self._serialize, self._deserialize) - self.spark_configuration = SparkConfigurationOperations(self._client, self._config, self._serialize, self._deserialize) - self.spark_configurations = SparkConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.kusto_operations = KustoOperationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.integration_runtimes = IntegrationRuntimesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.integration_runtime_node_ip_address = IntegrationRuntimeNodeIpAddressOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.integration_runtime_object_metadata = IntegrationRuntimeObjectMetadataOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.integration_runtime_nodes = IntegrationRuntimeNodesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.integration_runtime_credentials = IntegrationRuntimeCredentialsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.integration_runtime_connection_infos = IntegrationRuntimeConnectionInfosOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.integration_runtime_auth_keys = IntegrationRuntimeAuthKeysOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.integration_runtime_monitoring_data = IntegrationRuntimeMonitoringDataOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.integration_runtime_status = IntegrationRuntimeStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.spark_configuration = SparkConfigurationOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.spark_configurations = SparkConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.kusto_operations = KustoOperationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.kusto_pools = KustoPoolsOperations(self._client, self._config, self._serialize, self._deserialize) - self.kusto_pool_child_resource = KustoPoolChildResourceOperations(self._client, self._config, self._serialize, self._deserialize) - self.kusto_pool_attached_database_configurations = KustoPoolAttachedDatabaseConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.kusto_pool_databases = KustoPoolDatabasesOperations(self._client, self._config, self._serialize, self._deserialize) - self.kusto_pool_data_connections = KustoPoolDataConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.kusto_pool_principal_assignments = KustoPoolPrincipalAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.kusto_pool_database_principal_assignments = KustoPoolDatabasePrincipalAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) - + self.kusto_pool_child_resource = KustoPoolChildResourceOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.kusto_pool_attached_database_configurations = KustoPoolAttachedDatabaseConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.kusto_pool_databases = KustoPoolDatabasesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.kusto_pool_data_connections = KustoPoolDataConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.kusto_pool_principal_assignments = KustoPoolPrincipalAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.kusto_pool_database_principal_assignments = KustoPoolDatabasePrincipalAssignmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -354,7 +559,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/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 20541b1ecb35..1c679de80542 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 @@ -14,7 +14,9 @@ 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 ._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 @@ -37,25 +39,43 @@ 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 ._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_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 ._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 ._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 @@ -80,78 +100,84 @@ from ._kusto_pool_principal_assignments_operations import KustoPoolPrincipalAssignmentsOperations from ._kusto_pool_database_principal_assignments_operations import KustoPoolDatabasePrincipalAssignmentsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AzureADOnlyAuthenticationsOperations', - 'Operations', - 'IpFirewallRulesOperations', - 'KeysOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'PrivateLinkHubPrivateLinkResourcesOperations', - 'PrivateLinkHubsOperations', - 'PrivateEndpointConnectionsPrivateLinkHubOperations', - 'SqlPoolsOperations', - 'SqlPoolMetadataSyncConfigsOperations', - 'SqlPoolOperationResultsOperations', - 'SqlPoolGeoBackupPoliciesOperations', - 'SqlPoolDataWarehouseUserActivitiesOperations', - 'SqlPoolRestorePointsOperations', - 'SqlPoolReplicationLinksOperations', - 'SqlPoolMaintenanceWindowsOperations', - 'SqlPoolMaintenanceWindowOptionsOperations', - 'SqlPoolTransparentDataEncryptionsOperations', - 'SqlPoolBlobAuditingPoliciesOperations', - 'SqlPoolOperationsOperations', - 'SqlPoolUsagesOperations', - 'SqlPoolSensitivityLabelsOperations', - 'SqlPoolRecommendedSensitivityLabelsOperations', - 'SqlPoolSchemasOperations', - 'SqlPoolTablesOperations', - 'SqlPoolTableColumnsOperations', - 'SqlPoolConnectionPoliciesOperations', - 'SqlPoolVulnerabilityAssessmentsOperations', - 'SqlPoolVulnerabilityAssessmentScansOperations', - 'SqlPoolSecurityAlertPoliciesOperations', - 'SqlPoolVulnerabilityAssessmentRuleBaselinesOperations', - 'ExtendedSqlPoolBlobAuditingPoliciesOperations', - 'DataMaskingPoliciesOperations', - 'DataMaskingRulesOperations', - 'SqlPoolColumnsOperations', - 'SqlPoolWorkloadGroupOperations', - 'SqlPoolWorkloadClassifierOperations', - 'WorkspaceManagedSqlServerBlobAuditingPoliciesOperations', - 'WorkspaceManagedSqlServerExtendedBlobAuditingPoliciesOperations', - 'WorkspaceManagedSqlServerSecurityAlertPolicyOperations', - 'WorkspaceManagedSqlServerVulnerabilityAssessmentsOperations', - 'WorkspaceManagedSqlServerEncryptionProtectorOperations', - 'WorkspaceManagedSqlServerUsagesOperations', - 'WorkspaceManagedSqlServerRecoverableSqlPoolsOperations', - 'WorkspaceManagedSqlServerDedicatedSQLMinimalTlsSettingsOperations', - 'WorkspacesOperations', - 'WorkspaceAadAdminsOperations', - 'WorkspaceSqlAadAdminsOperations', - 'WorkspaceManagedIdentitySqlControlSettingsOperations', - 'RestorableDroppedSqlPoolsOperations', - 'BigDataPoolsOperations', - 'LibraryOperations', - 'LibrariesOperations', - 'IntegrationRuntimesOperations', - 'IntegrationRuntimeNodeIpAddressOperations', - 'IntegrationRuntimeObjectMetadataOperations', - 'IntegrationRuntimeNodesOperations', - 'IntegrationRuntimeCredentialsOperations', - 'IntegrationRuntimeConnectionInfosOperations', - 'IntegrationRuntimeAuthKeysOperations', - 'IntegrationRuntimeMonitoringDataOperations', - 'IntegrationRuntimeStatusOperations', - 'SparkConfigurationOperations', - 'SparkConfigurationsOperations', - 'KustoOperationsOperations', - 'KustoPoolsOperations', - 'KustoPoolChildResourceOperations', - 'KustoPoolAttachedDatabaseConfigurationsOperations', - 'KustoPoolDatabasesOperations', - 'KustoPoolDataConnectionsOperations', - 'KustoPoolPrincipalAssignmentsOperations', - 'KustoPoolDatabasePrincipalAssignmentsOperations', + "AzureADOnlyAuthenticationsOperations", + "Operations", + "IpFirewallRulesOperations", + "KeysOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "PrivateLinkHubPrivateLinkResourcesOperations", + "PrivateLinkHubsOperations", + "PrivateEndpointConnectionsPrivateLinkHubOperations", + "SqlPoolsOperations", + "SqlPoolMetadataSyncConfigsOperations", + "SqlPoolOperationResultsOperations", + "SqlPoolGeoBackupPoliciesOperations", + "SqlPoolDataWarehouseUserActivitiesOperations", + "SqlPoolRestorePointsOperations", + "SqlPoolReplicationLinksOperations", + "SqlPoolMaintenanceWindowsOperations", + "SqlPoolMaintenanceWindowOptionsOperations", + "SqlPoolTransparentDataEncryptionsOperations", + "SqlPoolBlobAuditingPoliciesOperations", + "SqlPoolOperationsOperations", + "SqlPoolUsagesOperations", + "SqlPoolSensitivityLabelsOperations", + "SqlPoolRecommendedSensitivityLabelsOperations", + "SqlPoolSchemasOperations", + "SqlPoolTablesOperations", + "SqlPoolTableColumnsOperations", + "SqlPoolConnectionPoliciesOperations", + "SqlPoolVulnerabilityAssessmentsOperations", + "SqlPoolVulnerabilityAssessmentScansOperations", + "SqlPoolSecurityAlertPoliciesOperations", + "SqlPoolVulnerabilityAssessmentRuleBaselinesOperations", + "ExtendedSqlPoolBlobAuditingPoliciesOperations", + "DataMaskingPoliciesOperations", + "DataMaskingRulesOperations", + "SqlPoolColumnsOperations", + "SqlPoolWorkloadGroupOperations", + "SqlPoolWorkloadClassifierOperations", + "WorkspaceManagedSqlServerBlobAuditingPoliciesOperations", + "WorkspaceManagedSqlServerExtendedBlobAuditingPoliciesOperations", + "WorkspaceManagedSqlServerSecurityAlertPolicyOperations", + "WorkspaceManagedSqlServerVulnerabilityAssessmentsOperations", + "WorkspaceManagedSqlServerEncryptionProtectorOperations", + "WorkspaceManagedSqlServerUsagesOperations", + "WorkspaceManagedSqlServerRecoverableSqlPoolsOperations", + "WorkspaceManagedSqlServerDedicatedSQLMinimalTlsSettingsOperations", + "WorkspacesOperations", + "WorkspaceAadAdminsOperations", + "WorkspaceSqlAadAdminsOperations", + "WorkspaceManagedIdentitySqlControlSettingsOperations", + "RestorableDroppedSqlPoolsOperations", + "BigDataPoolsOperations", + "LibraryOperations", + "LibrariesOperations", + "IntegrationRuntimesOperations", + "IntegrationRuntimeNodeIpAddressOperations", + "IntegrationRuntimeObjectMetadataOperations", + "IntegrationRuntimeNodesOperations", + "IntegrationRuntimeCredentialsOperations", + "IntegrationRuntimeConnectionInfosOperations", + "IntegrationRuntimeAuthKeysOperations", + "IntegrationRuntimeMonitoringDataOperations", + "IntegrationRuntimeStatusOperations", + "SparkConfigurationOperations", + "SparkConfigurationsOperations", + "KustoOperationsOperations", + "KustoPoolsOperations", + "KustoPoolChildResourceOperations", + "KustoPoolAttachedDatabaseConfigurationsOperations", + "KustoPoolDatabasesOperations", + "KustoPoolDataConnectionsOperations", + "KustoPoolPrincipalAssignmentsOperations", + "KustoPoolDatabasePrincipalAssignmentsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_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 7a636678c62c..118c67e7a10f 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 @@ -6,46 +6,57 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._azure_ad_only_authentications_operations import build_create_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._azure_ad_only_authentications_operations import ( + build_create_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AzureADOnlyAuthenticationsOperations: - """AzureADOnlyAuthenticationsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AzureADOnlyAuthenticationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`azure_ad_only_authentications` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( @@ -54,51 +65,55 @@ async def get( workspace_name: str, azure_ad_only_authentication_name: Union[str, "_models.AzureADOnlyAuthenticationName"], **kwargs: Any - ) -> "_models.AzureADOnlyAuthentication": + ) -> _models.AzureADOnlyAuthentication: """Get Azure Active Directory only authentication property. Gets a Azure Active Directory only authentication property. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param azure_ad_only_authentication_name: name of the property. + :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 api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureADOnlyAuthentication, or the result of cls(response) + :return: AzureADOnlyAuthentication or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.AzureADOnlyAuthentication - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureADOnlyAuthentication"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureADOnlyAuthentication] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -106,73 +121,172 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/azureADOnlyAuthentications/{azureADOnlyAuthenticationName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/azureADOnlyAuthentications/{azureADOnlyAuthenticationName}"} # 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: "_models.AzureADOnlyAuthentication", + azure_ad_only_authentication_info: Union[_models.AzureADOnlyAuthentication, IO], **kwargs: Any - ) -> Optional["_models.AzureADOnlyAuthentication"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AzureADOnlyAuthentication"]] + ) -> Optional[_models.AzureADOnlyAuthentication]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(azure_ad_only_authentication_info, 'AzureADOnlyAuthentication') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.AzureADOnlyAuthentication]] - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(azure_ad_only_authentication_info, (IO, bytes)): + _content = azure_ad_only_authentication_info + else: + _json = self._serialize.body(azure_ad_only_authentication_info, "AzureADOnlyAuthentication") + + request = build_create_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, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("AzureADOnlyAuthentication", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AzureADOnlyAuthentication', pipeline_response) + deserialized = self._deserialize("AzureADOnlyAuthentication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/azureADOnlyAuthentications/{azureADOnlyAuthenticationName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/azureADOnlyAuthentications/{azureADOnlyAuthenticationName}"} # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + workspace_name: str, + azure_ad_only_authentication_name: Union[str, "_models.AzureADOnlyAuthenticationName"], + azure_ad_only_authentication_info: _models.AzureADOnlyAuthentication, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureADOnlyAuthentication]: + """Create or Update Azure Active Directory only authentication property. + Create or Update a Azure Active Directory only authentication property for the workspaces. + + :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 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. Required. + :type azure_ad_only_authentication_info: ~azure.mgmt.synapse.models.AzureADOnlyAuthentication + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.AzureADOnlyAuthentication] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + workspace_name: str, + azure_ad_only_authentication_name: Union[str, "_models.AzureADOnlyAuthenticationName"], + azure_ad_only_authentication_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureADOnlyAuthentication]: + """Create or Update Azure Active Directory only authentication property. + + Create or Update a Azure Active Directory only authentication property for the workspaces. + + :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 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. Required. + :type azure_ad_only_authentication_info: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AzureADOnlyAuthentication or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.AzureADOnlyAuthentication] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -180,25 +294,28 @@ 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: "_models.AzureADOnlyAuthentication", + azure_ad_only_authentication_info: Union[_models.AzureADOnlyAuthentication, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.AzureADOnlyAuthentication"]: + ) -> AsyncLROPoller[_models.AzureADOnlyAuthentication]: """Create or Update Azure Active Directory only authentication property. Create or Update a Azure Active Directory only authentication property for the workspaces. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param azure_ad_only_authentication_name: name of the property. + :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. + :param azure_ad_only_authentication_info: Azure Active Directory Property. Is either a model + type or a IO type. Required. :type azure_ad_only_authentication_info: ~azure.mgmt.synapse.models.AzureADOnlyAuthentication - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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 @@ -211,108 +328,110 @@ async def begin_create( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.AzureADOnlyAuthentication] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureADOnlyAuthentication"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureADOnlyAuthentication] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, azure_ad_only_authentication_name=azure_ad_only_authentication_name, azure_ad_only_authentication_info=azure_ad_only_authentication_info, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AzureADOnlyAuthentication', pipeline_response) + deserialized = self._deserialize("AzureADOnlyAuthentication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/azureADOnlyAuthentications/{azureADOnlyAuthenticationName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/azureADOnlyAuthentications/{azureADOnlyAuthenticationName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.AzureADOnlyAuthenticationListResult"]: + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.AzureADOnlyAuthentication"]: """Gets a list of Azure Active Directory only authentication property. Gets a list of Azure Active Directory only authentication property for a workspace. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AzureADOnlyAuthenticationListResult or the result - of cls(response) + :return: An iterator like instance of either AzureADOnlyAuthentication or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.AzureADOnlyAuthenticationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.AzureADOnlyAuthentication] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureADOnlyAuthenticationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureADOnlyAuthenticationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -326,10 +445,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -340,8 +457,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/azureADOnlyAuthentications"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/azureADOnlyAuthentications"} # type: ignore 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 d285cd4a3cd7..66fe6707cc3c 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 @@ -6,98 +6,117 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._big_data_pools_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_workspace_request, build_update_request -T = TypeVar('T') +from ...operations._big_data_pools_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_workspace_request, + build_update_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class BigDataPoolsOperations: - """BigDataPoolsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BigDataPoolsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`big_data_pools` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - workspace_name: str, - big_data_pool_name: str, - **kwargs: Any - ) -> "_models.BigDataPoolResourceInfo": + self, resource_group_name: str, workspace_name: str, big_data_pool_name: str, **kwargs: Any + ) -> _models.BigDataPoolResourceInfo: """Get Big Data pool. Get a Big Data 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param big_data_pool_name: Big Data pool name. + :param big_data_pool_name: Big Data pool name. Required. :type big_data_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BigDataPoolResourceInfo, or the result of cls(response) + :return: BigDataPoolResourceInfo or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.BigDataPoolResourceInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BigDataPoolResourceInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.BigDataPoolResourceInfo] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -105,15 +124,80 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}"} # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + workspace_name: str, + big_data_pool_name: str, + big_data_pool_patch_info: _models.BigDataPoolPatchInfo, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BigDataPoolResourceInfo: + """Update a Big Data pool. + Patch a Big Data 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 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: ~azure.mgmt.synapse.models.BigDataPoolPatchInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: + """ + + @overload + async def update( + self, + resource_group_name: str, + workspace_name: str, + big_data_pool_name: str, + big_data_pool_patch_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BigDataPoolResourceInfo: + """Update a Big Data pool. + + Patch a Big Data 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: + """ @distributed_trace_async async def update( @@ -121,58 +205,74 @@ async def update( resource_group_name: str, workspace_name: str, big_data_pool_name: str, - big_data_pool_patch_info: "_models.BigDataPoolPatchInfo", + big_data_pool_patch_info: Union[_models.BigDataPoolPatchInfo, IO], **kwargs: Any - ) -> "_models.BigDataPoolResourceInfo": + ) -> _models.BigDataPoolResourceInfo: """Update a Big Data pool. Patch a Big Data 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param big_data_pool_name: Big Data pool name. + :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. - :type big_data_pool_patch_info: ~azure.mgmt.synapse.models.BigDataPoolPatchInfo - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: 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 - :return: BigDataPoolResourceInfo, or the result of cls(response) + :return: BigDataPoolResourceInfo or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.BigDataPoolResourceInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BigDataPoolResourceInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(big_data_pool_patch_info, 'BigDataPoolPatchInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BigDataPoolResourceInfo] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(big_data_pool_patch_info, (IO, bytes)): + _content = big_data_pool_patch_info + else: + _json = self._serialize.body(big_data_pool_patch_info, "BigDataPoolPatchInfo") request = build_update_request( - subscription_id=self._config.subscription_id, 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, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -180,74 +280,175 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}"} # 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: "_models.BigDataPoolResourceInfo", - force: Optional[bool] = False, + big_data_pool_info: Union[_models.BigDataPoolResourceInfo, IO], + force: bool = False, **kwargs: Any - ) -> "_models.BigDataPoolResourceInfo": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BigDataPoolResourceInfo"] + ) -> _models.BigDataPoolResourceInfo: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(big_data_pool_info, 'BigDataPoolResourceInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BigDataPoolResourceInfo] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(big_data_pool_info, (IO, bytes)): + _content = big_data_pool_info + else: + _json = self._serialize.body(big_data_pool_info, "BigDataPoolResourceInfo") + + request = build_create_or_update_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, + force=force, api_version=api_version, content_type=content_type, json=_json, - force=force, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("BigDataPoolResourceInfo", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BigDataPoolResourceInfo', pipeline_response) + deserialized = self._deserialize("BigDataPoolResourceInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + big_data_pool_name: str, + big_data_pool_info: _models.BigDataPoolResourceInfo, + force: bool = False, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BigDataPoolResourceInfo]: + """Create a Big Data pool. + Create a new Big Data 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 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: ~azure.mgmt.synapse.models.BigDataPoolResourceInfo + :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 JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + big_data_pool_name: str, + big_data_pool_info: IO, + force: bool = False, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BigDataPoolResourceInfo]: + """Create a Big Data pool. + + Create a new Big Data 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 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 + :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] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -255,27 +456,29 @@ async def begin_create_or_update( resource_group_name: str, workspace_name: str, big_data_pool_name: str, - big_data_pool_info: "_models.BigDataPoolResourceInfo", - force: Optional[bool] = False, + big_data_pool_info: Union[_models.BigDataPoolResourceInfo, IO], + force: bool = False, **kwargs: Any - ) -> AsyncLROPoller["_models.BigDataPoolResourceInfo"]: + ) -> AsyncLROPoller[_models.BigDataPoolResourceInfo]: """Create a Big Data pool. Create a new Big Data 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param big_data_pool_name: Big Data pool name. + :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. - :type big_data_pool_info: ~azure.mgmt.synapse.models.BigDataPoolResourceInfo + :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 force: Whether to stop any running jobs in the Big Data pool. Default value is False. :type force: bool - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: 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 @@ -287,19 +490,19 @@ async def begin_create_or_update( :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] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BigDataPoolResourceInfo"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BigDataPoolResourceInfo] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, big_data_pool_name=big_data_pool_name, @@ -307,107 +510,109 @@ async def begin_create_or_update( force=force, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BigDataPoolResourceInfo', pipeline_response) + deserialized = self._deserialize("BigDataPoolResourceInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}"} # type: ignore async def _delete_initial( - self, - resource_group_name: str, - workspace_name: str, - big_data_pool_name: str, - **kwargs: Any - ) -> Optional[Any]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[Any]] + self, resource_group_name: str, workspace_name: str, big_data_pool_name: str, **kwargs: Any + ) -> Optional[JSON]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[JSON]] + + 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'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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('object', pipeline_response) + deserialized = self._deserialize("object", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('object', pipeline_response) + deserialized = self._deserialize("object", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}"} # type: ignore @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - workspace_name: str, - big_data_pool_name: str, - **kwargs: Any - ) -> AsyncLROPoller[Any]: + self, resource_group_name: str, workspace_name: str, big_data_pool_name: str, **kwargs: Any + ) -> AsyncLROPoller[JSON]: """Delete a Big Data pool. Delete a Big Data pool from the workspace. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param big_data_pool_name: Big Data pool name. + :param big_data_pool_name: Big Data pool name. Required. :type big_data_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -416,107 +621,110 @@ async def begin_delete( :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either any or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[any] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An instance of AsyncLROPoller that returns either JSON or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[JSON] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Any] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[JSON] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, big_data_pool_name=big_data_pool_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('object', pipeline_response) + deserialized = self._deserialize("object", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}"} # type: ignore @distributed_trace def list_by_workspace( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.BigDataPoolResourceInfoListResult"]: + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BigDataPoolResourceInfo"]: """List the Big Data pools in a workspace. List Big Data pools in a workspace. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BigDataPoolResourceInfoListResult or the result of + :return: An iterator like instance of either BigDataPoolResourceInfo or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.BigDataPoolResourceInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.BigDataPoolResourceInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.BigDataPoolResourceInfoListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BigDataPoolResourceInfoListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore else: - - request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -530,10 +738,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -544,8 +750,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_workspace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools"} # type: ignore + list_by_workspace.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools"} # type: ignore 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 1cc0bfd24fd8..2efef6b6eaff 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 @@ -6,105 +6,198 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._data_masking_policies_operations import build_create_or_update_request, build_get_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DataMaskingPoliciesOperations: - """DataMaskingPoliciesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DataMaskingPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`data_masking_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: "_models.DataMaskingPolicy", + parameters: _models.DataMaskingPolicy, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DataMaskingPolicy": + ) -> _models.DataMaskingPolicy: """Creates or updates a Sql pool data masking policy. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param parameters: Parameters for creating or updating a data masking policy. + :param parameters: Parameters for creating or updating a data masking policy. Required. :type parameters: ~azure.mgmt.synapse.models.DataMaskingPolicy - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword 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) + :return: DataMaskingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.DataMaskingPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataMaskingPolicy: + """Creates or updates a Sql pool data masking policy. + + :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: Parameters for creating or updating a data masking policy. 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 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: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + parameters: Union[_models.DataMaskingPolicy, IO], + **kwargs: Any + ) -> _models.DataMaskingPolicy: + """Creates or updates a Sql pool data masking policy. + + :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: 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 + :return: DataMaskingPolicy or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.DataMaskingPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataMaskingPolicy"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - data_masking_policy_name = kwargs.pop('data_masking_policy_name', "Default") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'DataMaskingPolicy') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + data_masking_policy_name = kwargs.pop("data_masking_policy_name", "Default") # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataMaskingPolicy] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataMaskingPolicy") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, 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, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -112,71 +205,70 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataMaskingPolicies/{dataMaskingPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataMaskingPolicies/{dataMaskingPolicyName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> "_models.DataMaskingPolicy": + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> _models.DataMaskingPolicy: """Gets a Sql pool data masking policy. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword 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) + :return: DataMaskingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.DataMaskingPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataMaskingPolicy"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - data_masking_policy_name = kwargs.pop('data_masking_policy_name', "Default") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + data_masking_policy_name = kwargs.pop("data_masking_policy_name", "Default") # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataMaskingPolicy] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -184,12 +276,11 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataMaskingPolicies/{dataMaskingPolicyName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataMaskingPolicies/{dataMaskingPolicyName}"} # 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 611e8d7adfa8..673f9ff2912b 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 @@ -6,111 +6,216 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._data_masking_rules_operations import build_create_or_update_request, build_get_request, build_list_by_sql_pool_request -T = TypeVar('T') +from ...operations._data_masking_rules_operations import ( + build_create_or_update_request, + build_get_request, + build_list_by_sql_pool_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DataMaskingRulesOperations: - """DataMaskingRulesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DataMaskingRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`data_masking_rules` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, data_masking_rule_name: str, - parameters: "_models.DataMaskingRule", + parameters: _models.DataMaskingRule, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DataMaskingRule": + ) -> _models.DataMaskingRule: """Creates or updates a Sql pool data masking rule. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param data_masking_rule_name: The name of the data masking rule. + :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. + Required. :type parameters: ~azure.mgmt.synapse.models.DataMaskingRule - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword 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: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + data_masking_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataMaskingRule: + """Creates or updates a Sql pool data masking rule. + + :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 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. + 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 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: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + data_masking_rule_name: str, + parameters: Union[_models.DataMaskingRule, IO], + **kwargs: Any + ) -> _models.DataMaskingRule: + """Creates or updates a Sql pool data masking rule. + + :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 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 - :return: DataMaskingRule, or the result of cls(response) + :return: DataMaskingRule or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.DataMaskingRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataMaskingRule"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - data_masking_policy_name = kwargs.pop('data_masking_policy_name', "Default") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + data_masking_policy_name = kwargs.pop("data_masking_policy_name", "Default") # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataMaskingRule] - _json = self._serialize.body(parameters, 'DataMaskingRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataMaskingRule") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, data_masking_rule_name=data_masking_rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, data_masking_policy_name=data_masking_policy_name, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -119,18 +224,17 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DataMaskingRule', pipeline_response) + deserialized = self._deserialize("DataMaskingRule", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DataMaskingRule', pipeline_response) + deserialized = self._deserialize("DataMaskingRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules/{dataMaskingRuleName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules/{dataMaskingRuleName}"} # type: ignore @distributed_trace_async async def get( @@ -140,57 +244,61 @@ async def get( sql_pool_name: str, data_masking_rule_name: str, **kwargs: Any - ) -> "_models.DataMaskingRule": + ) -> _models.DataMaskingRule: """Gets the specific Sql pool data masking rule. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param data_masking_rule_name: The name of the data masking rule. + :param data_masking_rule_name: The name of the data masking rule. Required. :type data_masking_rule_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword 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) + :return: DataMaskingRule or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.DataMaskingRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataMaskingRule"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - data_masking_policy_name = kwargs.pop('data_masking_policy_name', "Default") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + data_masking_policy_name = kwargs.pop("data_masking_policy_name", "Default") # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataMaskingRule] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, data_masking_rule_name=data_masking_rule_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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -198,82 +306,73 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules/{dataMaskingRuleName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules/{dataMaskingRuleName}"} # type: ignore @distributed_trace def list_by_sql_pool( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.DataMaskingRuleListResult"]: + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DataMaskingRule"]: """Gets a list of Sql pool data masking rules. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword 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 DataMaskingRuleListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.DataMaskingRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - data_masking_policy_name = kwargs.pop('data_masking_policy_name', "Default") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + data_masking_policy_name = kwargs.pop("data_masking_policy_name", "Default") # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataMaskingRuleListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataMaskingRuleListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_sql_pool_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore else: - - request = build_list_by_sql_pool_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - api_version=api_version, - data_masking_policy_name=data_masking_policy_name, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -287,10 +386,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -301,8 +398,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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"} # type: ignore + list_by_sql_pool.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules"} # type: ignore 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 db93c2222eba..f47bfe3fe132 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 @@ -6,114 +6,192 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._extended_sql_pool_blob_auditing_policies_operations import build_create_or_update_request, build_get_request, build_list_by_sql_pool_request -T = TypeVar('T') +from ...operations._extended_sql_pool_blob_auditing_policies_operations import ( + build_create_or_update_request, + build_get_request, + build_list_by_sql_pool_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ExtendedSqlPoolBlobAuditingPoliciesOperations: - """ExtendedSqlPoolBlobAuditingPoliciesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ExtendedSqlPoolBlobAuditingPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`extended_sql_pool_blob_auditing_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> "_models.ExtendedSqlPoolBlobAuditingPolicy": + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> _models.ExtendedSqlPoolBlobAuditingPolicy: """Gets an extended Sql pool's blob auditing policy. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword 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) + :return: ExtendedSqlPoolBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ExtendedSqlPoolBlobAuditingPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtendedSqlPoolBlobAuditingPolicy"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - blob_auditing_policy_name = kwargs.pop('blob_auditing_policy_name', "default") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + blob_auditing_policy_name = kwargs.pop("blob_auditing_policy_name", "default") # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ExtendedSqlPoolBlobAuditingPolicy] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/extendedAuditingSettings/{blobAuditingPolicyName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/extendedAuditingSettings/{blobAuditingPolicyName}"} # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + parameters: _models.ExtendedSqlPoolBlobAuditingPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ExtendedSqlPoolBlobAuditingPolicy: + """Creates or updates an extended Sql pool's blob auditing policy. + :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 extended Sql pool blob auditing policy. Required. + :type parameters: ~azure.mgmt.synapse.models.ExtendedSqlPoolBlobAuditingPolicy + :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: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ExtendedSqlPoolBlobAuditingPolicy: + """Creates or updates an extended Sql pool's blob auditing policy. + + :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 extended Sql pool blob auditing policy. 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 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: + """ @distributed_trace_async async def create_or_update( @@ -121,61 +199,77 @@ async def create_or_update( resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: "_models.ExtendedSqlPoolBlobAuditingPolicy", + parameters: Union[_models.ExtendedSqlPoolBlobAuditingPolicy, IO], **kwargs: Any - ) -> "_models.ExtendedSqlPoolBlobAuditingPolicy": + ) -> _models.ExtendedSqlPoolBlobAuditingPolicy: """Creates or updates an extended Sql pool's blob auditing policy. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param parameters: The extended Sql pool blob auditing policy. - :type parameters: ~azure.mgmt.synapse.models.ExtendedSqlPoolBlobAuditingPolicy - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 - :return: ExtendedSqlPoolBlobAuditingPolicy, or the result of cls(response) + :return: ExtendedSqlPoolBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ExtendedSqlPoolBlobAuditingPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtendedSqlPoolBlobAuditingPolicy"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - blob_auditing_policy_name = kwargs.pop('blob_auditing_policy_name', "default") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + blob_auditing_policy_name = kwargs.pop("blob_auditing_policy_name", "default") # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ExtendedSqlPoolBlobAuditingPolicy] - _json = self._serialize.body(parameters, 'ExtendedSqlPoolBlobAuditingPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExtendedSqlPoolBlobAuditingPolicy") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, 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, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -183,78 +277,72 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ExtendedSqlPoolBlobAuditingPolicy', pipeline_response) + deserialized = self._deserialize("ExtendedSqlPoolBlobAuditingPolicy", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ExtendedSqlPoolBlobAuditingPolicy', pipeline_response) + deserialized = self._deserialize("ExtendedSqlPoolBlobAuditingPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/extendedAuditingSettings/{blobAuditingPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/extendedAuditingSettings/{blobAuditingPolicyName}"} # type: ignore @distributed_trace def list_by_sql_pool( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ExtendedSqlPoolBlobAuditingPolicyListResult"]: + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ExtendedSqlPoolBlobAuditingPolicy"]: """Lists extended auditing settings of 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExtendedSqlPoolBlobAuditingPolicyListResult or the - result of cls(response) + :return: An iterator like instance of either ExtendedSqlPoolBlobAuditingPolicy or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.ExtendedSqlPoolBlobAuditingPolicyListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.ExtendedSqlPoolBlobAuditingPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ExtendedSqlPoolBlobAuditingPolicyListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtendedSqlPoolBlobAuditingPolicyListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_sql_pool_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore else: - - request = build_list_by_sql_pool_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -268,10 +356,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -281,8 +367,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_sql_pool.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/extendedAuditingSettings"} # type: ignore + list_by_sql_pool.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/extendedAuditingSettings"} # 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 2ee71cd9f813..9742f8673394 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 @@ -6,103 +6,194 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._integration_runtime_auth_keys_operations import build_list_request, build_regenerate_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class IntegrationRuntimeAuthKeysOperations: - """IntegrationRuntimeAuthKeysOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IntegrationRuntimeAuthKeysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`integration_runtime_auth_keys` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def regenerate( self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, - regenerate_key_parameters: "_models.IntegrationRuntimeRegenerateKeyParameters", + regenerate_key_parameters: _models.IntegrationRuntimeRegenerateKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.IntegrationRuntimeAuthKeys": + ) -> _models.IntegrationRuntimeAuthKeys: """Regenerate integration runtime authentication key. Regenerate the authentication key for an integration runtime. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :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. + authentication key. Required. :type regenerate_key_parameters: ~azure.mgmt.synapse.models.IntegrationRuntimeRegenerateKeyParameters - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IntegrationRuntimeAuthKeys, or the result of cls(response) + :return: IntegrationRuntimeAuthKeys or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeAuthKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate( + self, + resource_group_name: str, + workspace_name: str, + integration_runtime_name: str, + regenerate_key_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IntegrationRuntimeAuthKeys: + """Regenerate integration runtime authentication key. + + Regenerate the authentication key for an integration runtime. + + :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 integration_runtime_name: Integration runtime name. Required. + :type integration_runtime_name: str + :param regenerate_key_parameters: The parameters for regenerating integration runtime + authentication key. Required. + :type regenerate_key_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: IntegrationRuntimeAuthKeys or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeAuthKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate( + self, + resource_group_name: str, + workspace_name: str, + integration_runtime_name: str, + regenerate_key_parameters: Union[_models.IntegrationRuntimeRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.IntegrationRuntimeAuthKeys: + """Regenerate integration runtime authentication key. + + Regenerate the authentication key for an integration runtime. + + :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 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. + :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 + :return: IntegrationRuntimeAuthKeys or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeAuthKeys + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IntegrationRuntimeAuthKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(regenerate_key_parameters, 'IntegrationRuntimeRegenerateKeyParameters') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IntegrationRuntimeAuthKeys] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key_parameters, (IO, bytes)): + _content = regenerate_key_parameters + else: + _json = self._serialize.body(regenerate_key_parameters, "IntegrationRuntimeRegenerateKeyParameters") request = build_regenerate_request( - subscription_id=self._config.subscription_id, 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, content_type=content_type, json=_json, - template_url=self.regenerate.metadata['url'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,67 +201,66 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/regenerateAuthKey"} # type: ignore - + regenerate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/regenerateAuthKey"} # type: ignore @distributed_trace_async async def list( - self, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any - ) -> "_models.IntegrationRuntimeAuthKeys": + self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any + ) -> _models.IntegrationRuntimeAuthKeys: """List integration runtime authentication keys. List authentication keys in an integration runtime. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IntegrationRuntimeAuthKeys, or the result of cls(response) + :return: IntegrationRuntimeAuthKeys or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeAuthKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IntegrationRuntimeAuthKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IntegrationRuntimeAuthKeys] - request = build_list_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -178,12 +268,11 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/listAuthKeys"} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/listAuthKeys"} # 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 3d4b97f0236c..b23c7fc54e18 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 @@ -8,92 +8,99 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._integration_runtime_connection_infos_operations import build_get_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class IntegrationRuntimeConnectionInfosOperations: - """IntegrationRuntimeConnectionInfosOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IntegrationRuntimeConnectionInfosOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`integration_runtime_connection_infos` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any - ) -> "_models.IntegrationRuntimeConnectionInfo": + self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any + ) -> _models.IntegrationRuntimeConnectionInfo: """Get integration runtime connection info. Get connection info for an integration runtime. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IntegrationRuntimeConnectionInfo, or the result of cls(response) + :return: IntegrationRuntimeConnectionInfo or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeConnectionInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IntegrationRuntimeConnectionInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IntegrationRuntimeConnectionInfo] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,12 +108,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IntegrationRuntimeConnectionInfo', pipeline_response) + deserialized = self._deserialize("IntegrationRuntimeConnectionInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/getConnectionInfo"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/getConnectionInfo"} # 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 5354caf3071e..d6af8a827831 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 @@ -8,48 +8,51 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._integration_runtime_credentials_operations import build_sync_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class IntegrationRuntimeCredentialsOperations: - """IntegrationRuntimeCredentialsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IntegrationRuntimeCredentialsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`integration_runtime_credentials` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def sync( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any + self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any ) -> None: """Sync integration runtime credentials. @@ -59,44 +62,48 @@ async def sync( # pylint: disable=inconsistent-return-statements import it (preferred) on any self-hosted integration runtime node than using this API directly. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_sync_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -107,5 +114,4 @@ async def sync( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - sync.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/syncCredentials"} # type: ignore - + sync.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/syncCredentials"} # 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 5f9eddcb238d..dc32506fe913 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 @@ -8,92 +8,99 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._integration_runtime_monitoring_data_operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class IntegrationRuntimeMonitoringDataOperations: - """IntegrationRuntimeMonitoringDataOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IntegrationRuntimeMonitoringDataOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`integration_runtime_monitoring_data` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def list( - self, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any - ) -> "_models.IntegrationRuntimeMonitoringData": + self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any + ) -> _models.IntegrationRuntimeMonitoringData: """Get integration runtime monitoring data. Get monitoring data for an integration runtime. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IntegrationRuntimeMonitoringData, or the result of cls(response) + :return: IntegrationRuntimeMonitoringData or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeMonitoringData - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IntegrationRuntimeMonitoringData"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IntegrationRuntimeMonitoringData] - request = build_list_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,12 +108,11 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/monitoringData"} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/monitoringData"} # 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 6a55e4441251..55e01cda8690 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 @@ -8,40 +8,47 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._integration_runtime_node_ip_address_operations import build_get_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class IntegrationRuntimeNodeIpAddressOperations: - """IntegrationRuntimeNodeIpAddressOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IntegrationRuntimeNodeIpAddressOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`integration_runtime_node_ip_address` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( @@ -51,53 +58,57 @@ async def get( integration_runtime_name: str, node_name: str, **kwargs: Any - ) -> "_models.IntegrationRuntimeNodeIpAddress": + ) -> _models.IntegrationRuntimeNodeIpAddress: """Get integration runtime node IP address. Get the IP address of an integration runtime node. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :param node_name: Integration runtime node name. + :param node_name: Integration runtime node name. Required. :type node_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IntegrationRuntimeNodeIpAddress, or the result of cls(response) + :return: IntegrationRuntimeNodeIpAddress or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeNodeIpAddress - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IntegrationRuntimeNodeIpAddress"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IntegrationRuntimeNodeIpAddress] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -105,12 +116,11 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/nodes/{nodeName}/ipAddress"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/nodes/{nodeName}/ipAddress"} # 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 6f6d454819df..62a6f5cc4bc4 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 @@ -6,42 +6,53 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._integration_runtime_nodes_operations import build_delete_request, build_get_request, build_update_request -T = TypeVar('T') +from ...operations._integration_runtime_nodes_operations import ( + build_delete_request, + build_get_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class IntegrationRuntimeNodesOperations: - """IntegrationRuntimeNodesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IntegrationRuntimeNodesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`integration_runtime_nodes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( @@ -51,53 +62,57 @@ async def get( integration_runtime_name: str, node_name: str, **kwargs: Any - ) -> "_models.SelfHostedIntegrationRuntimeNode": + ) -> _models.SelfHostedIntegrationRuntimeNode: """Get integration runtime node. Get an integration runtime node. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :param node_name: Integration runtime node name. + :param node_name: Integration runtime node name. Required. :type node_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SelfHostedIntegrationRuntimeNode, or the result of cls(response) + :return: SelfHostedIntegrationRuntimeNode or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SelfHostedIntegrationRuntimeNode - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SelfHostedIntegrationRuntimeNode"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SelfHostedIntegrationRuntimeNode] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -105,15 +120,89 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/nodes/{nodeName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/nodes/{nodeName}"} # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + workspace_name: str, + integration_runtime_name: str, + node_name: str, + update_integration_runtime_node_request: _models.UpdateIntegrationRuntimeNodeRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SelfHostedIntegrationRuntimeNode: + """Create integration runtime node. + + Create an integration runtime node. + :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 integration_runtime_name: Integration runtime name. Required. + :type integration_runtime_name: str + :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. Required. + :type update_integration_runtime_node_request: + ~azure.mgmt.synapse.models.UpdateIntegrationRuntimeNodeRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: + """ + + @overload + async def update( + self, + resource_group_name: str, + workspace_name: str, + integration_runtime_name: str, + node_name: str, + update_integration_runtime_node_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SelfHostedIntegrationRuntimeNode: + """Create integration runtime node. + + Create an integration runtime node. + + :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 integration_runtime_name: Integration runtime name. Required. + :type integration_runtime_name: str + :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. Required. + :type update_integration_runtime_node_request: 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: SelfHostedIntegrationRuntimeNode or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.SelfHostedIntegrationRuntimeNode + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def update( @@ -122,63 +211,78 @@ async def update( workspace_name: str, integration_runtime_name: str, node_name: str, - update_integration_runtime_node_request: "_models.UpdateIntegrationRuntimeNodeRequest", + update_integration_runtime_node_request: Union[_models.UpdateIntegrationRuntimeNodeRequest, IO], **kwargs: Any - ) -> "_models.SelfHostedIntegrationRuntimeNode": + ) -> _models.SelfHostedIntegrationRuntimeNode: """Create integration runtime node. Create an integration runtime node. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :param node_name: Integration runtime node name. + :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. + runtime node. Is either a model type or a IO type. Required. :type update_integration_runtime_node_request: - ~azure.mgmt.synapse.models.UpdateIntegrationRuntimeNodeRequest - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + ~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 - :return: SelfHostedIntegrationRuntimeNode, or the result of cls(response) + :return: SelfHostedIntegrationRuntimeNode or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SelfHostedIntegrationRuntimeNode - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SelfHostedIntegrationRuntimeNode"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SelfHostedIntegrationRuntimeNode] - _json = self._serialize.body(update_integration_runtime_node_request, 'UpdateIntegrationRuntimeNodeRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_integration_runtime_node_request, (IO, bytes)): + _content = update_integration_runtime_node_request + else: + _json = self._serialize.body(update_integration_runtime_node_request, "UpdateIntegrationRuntimeNodeRequest") request = build_update_request( - subscription_id=self._config.subscription_id, 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, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -186,15 +290,14 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/nodes/{nodeName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/nodes/{nodeName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -210,47 +313,51 @@ async def delete( # pylint: disable=inconsistent-return-statements Delete an integration runtime node. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :param node_name: Integration runtime node name. + :param node_name: Integration runtime node name. Required. :type node_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -261,5 +368,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/nodes/{nodeName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/nodes/{nodeName}"} # 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 ea58e26e18c9..ef51f02c736a 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 @@ -6,107 +6,197 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._integration_runtime_object_metadata_operations import build_list_request, build_refresh_request_initial -T = TypeVar('T') +from ...operations._integration_runtime_object_metadata_operations import build_list_request, build_refresh_request + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class IntegrationRuntimeObjectMetadataOperations: - """IntegrationRuntimeObjectMetadataOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IntegrationRuntimeObjectMetadataOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`integration_runtime_object_metadata` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def list( self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, - get_metadata_request: Optional["_models.GetSsisObjectMetadataRequest"] = None, + get_metadata_request: Optional[_models.GetSsisObjectMetadataRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.SsisObjectMetadataListResponse": + ) -> _models.SsisObjectMetadataListResponse: """Get integration runtime object metadata. Get object metadata from an integration runtime. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :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. Default value is None. :type get_metadata_request: ~azure.mgmt.synapse.models.GetSsisObjectMetadataRequest - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SsisObjectMetadataListResponse or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.SsisObjectMetadataListResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list( + self, + resource_group_name: str, + workspace_name: str, + integration_runtime_name: str, + get_metadata_request: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SsisObjectMetadataListResponse: + """Get integration runtime object metadata. + + Get object metadata from an integration runtime. + + :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 integration_runtime_name: Integration runtime name. Required. + :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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: + """ + + @distributed_trace_async + async def list( + self, + resource_group_name: str, + workspace_name: str, + integration_runtime_name: str, + get_metadata_request: Optional[Union[_models.GetSsisObjectMetadataRequest, IO]] = None, + **kwargs: Any + ) -> _models.SsisObjectMetadataListResponse: + """Get integration runtime object metadata. + + Get object metadata from an integration runtime. + + :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 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 - :return: SsisObjectMetadataListResponse, or the result of cls(response) + :return: SsisObjectMetadataListResponse or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SsisObjectMetadataListResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SsisObjectMetadataListResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SsisObjectMetadataListResponse] - if get_metadata_request is not None: - _json = self._serialize.body(get_metadata_request, 'GetSsisObjectMetadataRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(get_metadata_request, (IO, bytes)): + _content = get_metadata_request else: - _json = None + if get_metadata_request is not None: + _json = self._serialize.body(get_metadata_request, "GetSsisObjectMetadataRequest") + else: + _json = None request = build_list_request( - subscription_id=self._config.subscription_id, 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, content_type=content_type, json=_json, - template_url=self.list.metadata['url'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,87 +204,82 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/getObjectMetadata"} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/getObjectMetadata"} # type: ignore async def _refresh_initial( - self, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any - ) -> Optional["_models.SsisObjectMetadataStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.SsisObjectMetadataStatusResponse"]] + self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any + ) -> Optional[_models.SsisObjectMetadataStatusResponse]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_refresh_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SsisObjectMetadataStatusResponse]] + + 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'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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 = self._deserialize("SsisObjectMetadataStatusResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _refresh_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/refreshObjectMetadata"} # type: ignore - + _refresh_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/refreshObjectMetadata"} # type: ignore @distributed_trace_async async def begin_refresh( - self, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any - ) -> AsyncLROPoller["_models.SsisObjectMetadataStatusResponse"]: + self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.SsisObjectMetadataStatusResponse]: """Refresh integration runtime object metadata. Refresh the object metadata in an integration runtime. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -207,45 +292,48 @@ async def begin_refresh( the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.SsisObjectMetadataStatusResponse] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SsisObjectMetadataStatusResponse"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SsisObjectMetadataStatusResponse] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._refresh_initial( + raw_result = await self._refresh_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('SsisObjectMetadataStatusResponse', pipeline_response) + deserialized = self._deserialize("SsisObjectMetadataStatusResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_refresh.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/refreshObjectMetadata"} # type: ignore + begin_refresh.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/refreshObjectMetadata"} # 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 4b39b876c1c7..72bcfed77c8c 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 @@ -8,92 +8,99 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._integration_runtime_status_operations import build_get_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class IntegrationRuntimeStatusOperations: - """IntegrationRuntimeStatusOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IntegrationRuntimeStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`integration_runtime_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any - ) -> "_models.IntegrationRuntimeStatusResponse": + self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any + ) -> _models.IntegrationRuntimeStatusResponse: """Get integration runtime status. Get the integration runtime status. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IntegrationRuntimeStatusResponse, or the result of cls(response) + :return: IntegrationRuntimeStatusResponse or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeStatusResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IntegrationRuntimeStatusResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IntegrationRuntimeStatusResponse] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,12 +108,11 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/getStatus"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/getStatus"} # 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 188e9f35b3d0..0ff47a56792e 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,106 +6,210 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._integration_runtimes_operations import build_create_request_initial, build_delete_request_initial, build_disable_interactive_query_request_initial, build_enable_interactive_query_request_initial, build_get_request, build_list_by_workspace_request, build_list_outbound_network_dependencies_endpoints_request, build_start_request_initial, build_stop_request_initial, build_update_request, build_upgrade_request -T = TypeVar('T') +from ...operations._integration_runtimes_operations import ( + build_create_request, + build_delete_request, + build_disable_interactive_query_request, + build_enable_interactive_query_request, + build_get_request, + build_list_by_workspace_request, + build_list_outbound_network_dependencies_endpoints_request, + build_start_request, + build_stop_request, + build_update_request, + build_upgrade_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class IntegrationRuntimesOperations: - """IntegrationRuntimesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IntegrationRuntimesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`integration_runtimes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def update( self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, - update_integration_runtime_request: "_models.UpdateIntegrationRuntimeRequest", + update_integration_runtime_request: _models.UpdateIntegrationRuntimeRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.IntegrationRuntimeResource": + ) -> _models.IntegrationRuntimeResource: """Update integration runtime. Update an integration runtime. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :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. + Required. :type update_integration_runtime_request: ~azure.mgmt.synapse.models.UpdateIntegrationRuntimeRequest - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IntegrationRuntimeResource or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + workspace_name: str, + integration_runtime_name: str, + update_integration_runtime_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IntegrationRuntimeResource: + """Update integration runtime. + + Update an integration runtime. + + :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 integration_runtime_name: Integration runtime name. Required. + :type integration_runtime_name: str + :param update_integration_runtime_request: The parameters for updating an integration runtime. + Required. + :type update_integration_runtime_request: 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: IntegrationRuntimeResource or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + workspace_name: str, + integration_runtime_name: str, + update_integration_runtime_request: Union[_models.UpdateIntegrationRuntimeRequest, IO], + **kwargs: Any + ) -> _models.IntegrationRuntimeResource: + """Update integration runtime. + + Update an integration runtime. + + :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 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. + :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 - :return: IntegrationRuntimeResource, or the result of cls(response) + :return: IntegrationRuntimeResource or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IntegrationRuntimeResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IntegrationRuntimeResource] - _json = self._serialize.body(update_integration_runtime_request, 'UpdateIntegrationRuntimeRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_integration_runtime_request, (IO, bytes)): + _content = update_integration_runtime_request + else: + _json = self._serialize.body(update_integration_runtime_request, "UpdateIntegrationRuntimeRequest") request = build_update_request( - subscription_id=self._config.subscription_id, 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, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -113,15 +217,14 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}"} # type: ignore @distributed_trace_async async def get( @@ -131,55 +234,59 @@ async def get( integration_runtime_name: str, if_none_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.IntegrationRuntimeResource"]: + ) -> Optional[_models.IntegrationRuntimeResource]: """Get integration runtime. Get an integration runtime. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str :param if_none_match: ETag of the integration runtime entity. Should only be specified for 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 api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IntegrationRuntimeResource, or the result of cls(response) + :return: IntegrationRuntimeResource or None or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeResource or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.IntegrationRuntimeResource"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.IntegrationRuntimeResource]] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_none_match=if_none_match, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 304]: @@ -189,72 +296,179 @@ async def get( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('IntegrationRuntimeResource', pipeline_response) + deserialized = self._deserialize("IntegrationRuntimeResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}"} # type: ignore async def _create_initial( self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, - integration_runtime: "_models.IntegrationRuntimeResource", + integration_runtime: Union[_models.IntegrationRuntimeResource, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.IntegrationRuntimeResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.IntegrationRuntimeResource"]] + ) -> Optional[_models.IntegrationRuntimeResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(integration_runtime, 'IntegrationRuntimeResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.IntegrationRuntimeResource]] - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(integration_runtime, (IO, bytes)): + _content = integration_runtime + else: + _json = self._serialize.body(integration_runtime, "IntegrationRuntimeResource") + + request = build_create_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, + subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self._create_initial.metadata['url'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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 = self._deserialize("IntegrationRuntimeResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}"} # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + workspace_name: str, + integration_runtime_name: str, + integration_runtime: _models.IntegrationRuntimeResource, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IntegrationRuntimeResource]: + """Create integration runtime. + + Create an integration runtime. + + :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 integration_runtime_name: Integration runtime name. Required. + :type integration_runtime_name: str + :param integration_runtime: Integration runtime resource definition. Required. + :type integration_runtime: ~azure.mgmt.synapse.models.IntegrationRuntimeResource + :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. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.IntegrationRuntimeResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + workspace_name: str, + integration_runtime_name: str, + integration_runtime: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IntegrationRuntimeResource]: + """Create integration runtime. + + Create an integration runtime. + :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 integration_runtime_name: Integration runtime name. Required. + :type integration_runtime_name: str + :param integration_runtime: Integration runtime resource definition. Required. + :type integration_runtime: IO + :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. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.IntegrationRuntimeResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -262,29 +476,31 @@ async def begin_create( resource_group_name: str, workspace_name: str, integration_runtime_name: str, - integration_runtime: "_models.IntegrationRuntimeResource", + integration_runtime: Union[_models.IntegrationRuntimeResource, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.IntegrationRuntimeResource"]: + ) -> AsyncLROPoller[_models.IntegrationRuntimeResource]: """Create integration runtime. Create an integration runtime. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :param integration_runtime: Integration runtime resource definition. - :type integration_runtime: ~azure.mgmt.synapse.models.IntegrationRuntimeResource + :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 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 api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: 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 @@ -297,19 +513,19 @@ async def begin_create( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.IntegrationRuntimeResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IntegrationRuntimeResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IntegrationRuntimeResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, @@ -317,98 +533,97 @@ async def begin_create( if_match=if_match, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IntegrationRuntimeResource', pipeline_response) + deserialized = self._deserialize("IntegrationRuntimeResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any + self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + 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'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete integration runtime. Delete an integration runtime. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -419,97 +634,101 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}"} # type: ignore @distributed_trace_async async def upgrade( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any + self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any ) -> None: """Upgrade integration runtime. Upgrade an integration runtime. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_upgrade_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -520,65 +739,61 @@ async def upgrade( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - upgrade.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/upgrade"} # type: ignore - + upgrade.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/upgrade"} # type: ignore @distributed_trace def list_by_workspace( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IntegrationRuntimeListResponse"]: + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IntegrationRuntimeResource"]: """List integration runtimes. List all integration runtimes. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IntegrationRuntimeListResponse or the result of + :return: An iterator like instance of either IntegrationRuntimeResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.IntegrationRuntimeListResponse] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.IntegrationRuntimeResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IntegrationRuntimeListResponse] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IntegrationRuntimeListResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore else: - - request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -592,10 +807,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -606,83 +819,77 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_workspace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes"} # type: ignore + list_by_workspace.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes"} # type: ignore async def _start_initial( - self, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any - ) -> Optional["_models.IntegrationRuntimeStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.IntegrationRuntimeStatusResponse"]] + self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any + ) -> Optional[_models.IntegrationRuntimeStatusResponse]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_start_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.IntegrationRuntimeStatusResponse]] + + 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'], + template_url=self._start_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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 = self._deserialize("IntegrationRuntimeStatusResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/start"} # type: ignore - + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/start"} # type: ignore @distributed_trace_async async def begin_start( - self, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any - ) -> AsyncLROPoller["_models.IntegrationRuntimeStatusResponse"]: + self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.IntegrationRuntimeStatusResponse]: """Start integration runtime. Start an integration runtime. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -695,114 +902,113 @@ async def begin_start( the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.IntegrationRuntimeStatusResponse] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IntegrationRuntimeStatusResponse"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IntegrationRuntimeStatusResponse] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IntegrationRuntimeStatusResponse', pipeline_response) + deserialized = self._deserialize("IntegrationRuntimeStatusResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/start"} # type: ignore + begin_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/start"} # type: ignore async def _stop_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any + self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_stop_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + 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'], + template_url=self._stop_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/stop"} # type: ignore - + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/stop"} # type: ignore @distributed_trace_async - async def begin_stop( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any + async def begin_stop( + self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Stop integration runtime. Stop an integration runtime. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -813,99 +1019,105 @@ async def begin_stop( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._stop_initial( + raw_result = await self._stop_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/stop"} # type: ignore + begin_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/stop"} # type: ignore @distributed_trace_async async def list_outbound_network_dependencies_endpoints( - self, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any - ) -> "_models.IntegrationRuntimeOutboundNetworkDependenciesEndpointsResponse": + 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. Gets the list of outbound network dependencies for a given Azure-SSIS integration runtime. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IntegrationRuntimeOutboundNetworkDependenciesEndpointsResponse, or the result of + :return: IntegrationRuntimeOutboundNetworkDependenciesEndpointsResponse or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeOutboundNetworkDependenciesEndpointsResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IntegrationRuntimeOutboundNetworkDependenciesEndpointsResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop( + "cls", None + ) # type: ClsType[_models.IntegrationRuntimeOutboundNetworkDependenciesEndpointsResponse] - request = build_list_outbound_network_dependencies_endpoints_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.list_outbound_network_dependencies_endpoints.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -913,79 +1125,76 @@ async def list_outbound_network_dependencies_endpoints( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IntegrationRuntimeOutboundNetworkDependenciesEndpointsResponse', pipeline_response) + deserialized = self._deserialize( + "IntegrationRuntimeOutboundNetworkDependenciesEndpointsResponse", pipeline_response + ) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_outbound_network_dependencies_endpoints.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/outboundNetworkDependenciesEndpoints"} # type: ignore - + list_outbound_network_dependencies_endpoints.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/outboundNetworkDependenciesEndpoints"} # type: ignore async def _enable_interactive_query_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any + self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_enable_interactive_query_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + 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'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _enable_interactive_query_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/enableInteractiveQuery"} # type: ignore - + _enable_interactive_query_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/enableInteractiveQuery"} # type: ignore @distributed_trace_async - async def begin_enable_interactive_query( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any + async def begin_enable_interactive_query( + self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Enable interactive query in integration runtime. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -996,109 +1205,109 @@ async def begin_enable_interactive_query( # pylint: disable=inconsistent-return Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._enable_interactive_query_initial( + raw_result = await self._enable_interactive_query_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_enable_interactive_query.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/enableInteractiveQuery"} # type: ignore + begin_enable_interactive_query.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/enableInteractiveQuery"} # type: ignore async def _disable_interactive_query_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any + self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_disable_interactive_query_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + 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'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _disable_interactive_query_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/disableInteractiveQuery"} # type: ignore - + _disable_interactive_query_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/disableInteractiveQuery"} # type: ignore @distributed_trace_async - async def begin_disable_interactive_query( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any + async def begin_disable_interactive_query( + self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Disable interactive query in integration runtime. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -1109,42 +1318,46 @@ async def begin_disable_interactive_query( # pylint: disable=inconsistent-retur Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._disable_interactive_query_initial( + raw_result = await self._disable_interactive_query_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_disable_interactive_query.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/disableInteractiveQuery"} # type: ignore + begin_disable_interactive_query.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/disableInteractiveQuery"} # 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 37ab03379a38..1032afc35099 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 @@ -6,101 +6,115 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._ip_firewall_rules_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_workspace_request, build_replace_all_request_initial -T = TypeVar('T') +from ...operations._ip_firewall_rules_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_workspace_request, + build_replace_all_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class IpFirewallRulesOperations: - """IpFirewallRulesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IpFirewallRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`ip_firewall_rules` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_workspace( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IpFirewallRuleInfoListResult"]: + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IpFirewallRuleInfo"]: """Returns a list of firewall rules. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IpFirewallRuleInfoListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.IpFirewallRuleInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IpFirewallRuleInfoListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IpFirewallRuleInfoListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore else: - - request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -114,10 +128,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -128,69 +140,159 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_workspace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/firewallRules"} # type: ignore + list_by_workspace.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/firewallRules"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, workspace_name: str, rule_name: str, - ip_firewall_rule_info: "_models.IpFirewallRuleInfo", + ip_firewall_rule_info: Union[_models.IpFirewallRuleInfo, IO], **kwargs: Any - ) -> Optional["_models.IpFirewallRuleInfo"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.IpFirewallRuleInfo"]] + ) -> Optional[_models.IpFirewallRuleInfo]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(ip_firewall_rule_info, 'IpFirewallRuleInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.IpFirewallRuleInfo]] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(ip_firewall_rule_info, (IO, bytes)): + _content = ip_firewall_rule_info + else: + _json = self._serialize.body(ip_firewall_rule_info, "IpFirewallRuleInfo") + + request = build_create_or_update_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, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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 = self._deserialize("IpFirewallRuleInfo", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('IpFirewallRuleInfo', pipeline_response) + deserialized = self._deserialize("IpFirewallRuleInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/firewallRules/{ruleName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/firewallRules/{ruleName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + rule_name: str, + ip_firewall_rule_info: _models.IpFirewallRuleInfo, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IpFirewallRuleInfo]: + """Creates or updates a firewall rule. + + :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 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: ~azure.mgmt.synapse.models.IpFirewallRuleInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + rule_name: str, + ip_firewall_rule_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.IpFirewallRuleInfo]: + """Creates or updates a firewall rule. + + :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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -198,22 +300,24 @@ async def begin_create_or_update( resource_group_name: str, workspace_name: str, rule_name: str, - ip_firewall_rule_info: "_models.IpFirewallRuleInfo", + ip_firewall_rule_info: Union[_models.IpFirewallRuleInfo, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.IpFirewallRuleInfo"]: + ) -> AsyncLROPoller[_models.IpFirewallRuleInfo]: """Creates or updates a firewall rule. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param rule_name: The IP firewall rule name. + :param rule_name: The IP firewall rule name. Required. :type rule_name: str - :param ip_firewall_rule_info: IP firewall rule properties. - :type ip_firewall_rule_info: ~azure.mgmt.synapse.models.IpFirewallRuleInfo - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 @@ -225,121 +329,122 @@ async def begin_create_or_update( :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] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IpFirewallRuleInfo"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IpFirewallRuleInfo] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, rule_name=rule_name, ip_firewall_rule_info=ip_firewall_rule_info, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IpFirewallRuleInfo', pipeline_response) + deserialized = self._deserialize("IpFirewallRuleInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/firewallRules/{ruleName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/firewallRules/{ruleName}"} # type: ignore async def _delete_initial( - self, - resource_group_name: str, - workspace_name: str, - rule_name: str, - **kwargs: Any - ) -> Optional[Any]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[Any]] + self, resource_group_name: str, workspace_name: str, rule_name: str, **kwargs: Any + ) -> Optional[JSON]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[JSON]] + + 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'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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('object', pipeline_response) + deserialized = self._deserialize("object", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/firewallRules/{ruleName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/firewallRules/{ruleName}"} # type: ignore @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - workspace_name: str, - rule_name: str, - **kwargs: Any - ) -> AsyncLROPoller[Any]: + self, resource_group_name: str, workspace_name: str, rule_name: str, **kwargs: Any + ) -> AsyncLROPoller[JSON]: """Deletes a firewall rule. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param rule_name: The IP firewall rule name. + :param rule_name: The IP firewall rule name. Required. :type rule_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -348,100 +453,105 @@ async def begin_delete( :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either any or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[any] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An instance of AsyncLROPoller that returns either JSON or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[JSON] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Any] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[JSON] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, rule_name=rule_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('object', pipeline_response) + deserialized = self._deserialize("object", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/firewallRules/{ruleName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/firewallRules/{ruleName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - workspace_name: str, - rule_name: str, - **kwargs: Any - ) -> "_models.IpFirewallRuleInfo": + self, resource_group_name: str, workspace_name: str, rule_name: str, **kwargs: Any + ) -> _models.IpFirewallRuleInfo: """Get a firewall rule. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param rule_name: The IP firewall rule name. + :param rule_name: The IP firewall rule name. Required. :type rule_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IpFirewallRuleInfo, or the result of cls(response) + :return: IpFirewallRuleInfo or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IpFirewallRuleInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IpFirewallRuleInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IpFirewallRuleInfo] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -449,88 +559,177 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/firewallRules/{ruleName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/firewallRules/{ruleName}"} # type: ignore async def _replace_all_initial( self, resource_group_name: str, workspace_name: str, - request: "_models.ReplaceAllIpFirewallRulesRequest", + request: Union[_models.ReplaceAllIpFirewallRulesRequest, IO], **kwargs: Any - ) -> Optional["_models.ReplaceAllFirewallRulesOperationResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ReplaceAllFirewallRulesOperationResponse"]] + ) -> Optional[_models.ReplaceAllFirewallRulesOperationResponse]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(request, 'ReplaceAllIpFirewallRulesRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ReplaceAllFirewallRulesOperationResponse]] - request = build_replace_all_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(request, (IO, bytes)): + _content = request + else: + _json = self._serialize.body(request, "ReplaceAllIpFirewallRulesRequest") + + request = build_replace_all_request( resource_group_name=resource_group_name, workspace_name=workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._replace_all_initial.metadata['url'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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 = self._deserialize("ReplaceAllFirewallRulesOperationResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _replace_all_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/replaceAllIpFirewallRules"} # type: ignore + _replace_all_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/replaceAllIpFirewallRules"} # type: ignore + @overload + async def begin_replace_all( + self, + resource_group_name: str, + workspace_name: str, + request: _models.ReplaceAllIpFirewallRulesRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ReplaceAllFirewallRulesOperationResponse]: + """Replaces firewall rules. + + :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 request: Replace all IP firewall rules request. Required. + :type request: ~azure.mgmt.synapse.models.ReplaceAllIpFirewallRulesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.ReplaceAllFirewallRulesOperationResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_replace_all( + self, + resource_group_name: str, + workspace_name: str, + request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ReplaceAllFirewallRulesOperationResponse]: + """Replaces firewall rules. + + :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 request: Replace all IP firewall rules request. Required. + :type request: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either + ReplaceAllFirewallRulesOperationResponse or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.ReplaceAllFirewallRulesOperationResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_replace_all( self, resource_group_name: str, workspace_name: str, - request: "_models.ReplaceAllIpFirewallRulesRequest", + request: Union[_models.ReplaceAllIpFirewallRulesRequest, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ReplaceAllFirewallRulesOperationResponse"]: + ) -> AsyncLROPoller[_models.ReplaceAllFirewallRulesOperationResponse]: """Replaces firewall rules. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param request: Replace all IP firewall rules request. - :type request: ~azure.mgmt.synapse.models.ReplaceAllIpFirewallRulesRequest - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 @@ -543,47 +742,52 @@ async def begin_replace_all( ReplaceAllFirewallRulesOperationResponse or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.ReplaceAllFirewallRulesOperationResponse] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReplaceAllFirewallRulesOperationResponse"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ReplaceAllFirewallRulesOperationResponse] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._replace_all_initial( + raw_result = await self._replace_all_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, request=request, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ReplaceAllFirewallRulesOperationResponse', pipeline_response) + deserialized = self._deserialize("ReplaceAllFirewallRulesOperationResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_replace_all.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/replaceAllIpFirewallRules"} # type: ignore + begin_replace_all.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/replaceAllIpFirewallRules"} # 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 d43e8924e3fc..f647579926f2 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 @@ -6,97 +6,106 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._keys_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_workspace_request -T = TypeVar('T') +from ...operations._keys_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_workspace_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class KeysOperations: - """KeysOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class KeysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`keys` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_workspace( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.KeyInfoListResult"]: + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Key"]: """Returns a list of keys in a workspace. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either KeyInfoListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.KeyInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.KeyInfoListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.KeyInfoListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore else: - - request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -110,10 +119,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -124,61 +131,57 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_workspace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/keys"} # type: ignore + list_by_workspace.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/keys"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - workspace_name: str, - key_name: str, - **kwargs: Any - ) -> "_models.Key": + async def get(self, resource_group_name: str, workspace_name: str, key_name: str, **kwargs: Any) -> _models.Key: """Gets a workspace key. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param key_name: The name of the workspace key. + :param key_name: The name of the workspace key. Required. :type key_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Key, or the result of cls(response) + :return: Key or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.Key - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Key"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Key] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -186,15 +189,76 @@ async def get( 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/keys/{keyName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/keys/{keyName}"} # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + key_name: str, + key_properties: _models.Key, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Key: + """Creates or updates a workspace key. + + :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 key_name: The name of the workspace key. Required. + :type key_name: str + :param key_properties: Key put request properties. Required. + :type key_properties: ~azure.mgmt.synapse.models.Key + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + key_name: str, + key_properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Key: + """Creates or updates a workspace key. + :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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: + """ @distributed_trace_async async def create_or_update( @@ -202,56 +266,72 @@ async def create_or_update( resource_group_name: str, workspace_name: str, key_name: str, - key_properties: "_models.Key", + key_properties: Union[_models.Key, IO], **kwargs: Any - ) -> "_models.Key": + ) -> _models.Key: """Creates or updates a workspace key. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param key_name: The name of the workspace key. + :param key_name: The name of the workspace key. Required. :type key_name: str - :param key_properties: Key put request properties. - :type key_properties: ~azure.mgmt.synapse.models.Key - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :param key_properties: Key put request properties. Is either a model type or a IO 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 - :return: Key, or the result of cls(response) + :return: Key or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.Key - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Key"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Key] - _json = self._serialize.body(key_properties, 'Key') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(key_properties, (IO, bytes)): + _content = key_properties + else: + _json = self._serialize.body(key_properties, "Key") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, key_name=key_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -259,65 +339,64 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/keys/{keyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/keys/{keyName}"} # type: ignore @distributed_trace_async async def delete( - self, - resource_group_name: str, - workspace_name: str, - key_name: str, - **kwargs: Any - ) -> Optional["_models.Key"]: + self, resource_group_name: str, workspace_name: str, key_name: str, **kwargs: Any + ) -> Optional[_models.Key]: """Deletes a workspace key. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param key_name: The name of the workspace key. + :param key_name: The name of the workspace key. Required. :type key_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Key, or the result of cls(response) + :return: Key or None or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.Key or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Key"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.Key]] - request = build_delete_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -327,12 +406,11 @@ async def delete( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Key', pipeline_response) + deserialized = self._deserialize("Key", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/keys/{keyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/keys/{keyName}"} # 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 bae3a869f0f0..09604260f20c 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 @@ -9,81 +9,87 @@ from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.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 -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class KustoOperationsOperations: - """KustoOperationsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class KustoOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`kusto_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists available operations for the Kusto sub-resources inside Microsoft.Synapse provider. - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -97,10 +103,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -111,8 +115,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Synapse/kustooperations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Synapse/kustooperations"} # type: ignore 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 e79bdaaca047..417254bb5264 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 @@ -6,106 +6,113 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._kusto_pool_attached_database_configurations_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_kusto_pool_request -T = TypeVar('T') +from ...operations._kusto_pool_attached_database_configurations_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_kusto_pool_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class KustoPoolAttachedDatabaseConfigurationsOperations: - """KustoPoolAttachedDatabaseConfigurationsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class KustoPoolAttachedDatabaseConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`kusto_pool_attached_database_configurations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_kusto_pool( - self, - workspace_name: str, - kusto_pool_name: str, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.AttachedDatabaseConfigurationListResult"]: + self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.AttachedDatabaseConfiguration"]: """Returns the list of attached database configurations of the given Kusto Pool. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AttachedDatabaseConfigurationListResult or the - result of cls(response) + :return: An iterator like instance of either AttachedDatabaseConfiguration or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.AttachedDatabaseConfigurationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.AttachedDatabaseConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AttachedDatabaseConfigurationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AttachedDatabaseConfigurationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_kusto_pool_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore else: - - request = build_list_by_kusto_pool_request( - workspace_name=workspace_name, - kusto_pool_name=kusto_pool_name, - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -119,10 +126,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -133,11 +138,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_kusto_pool.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations"} # type: ignore + list_by_kusto_pool.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations"} # type: ignore @distributed_trace_async async def get( @@ -147,51 +150,56 @@ async def get( attached_database_configuration_name: str, resource_group_name: str, **kwargs: Any - ) -> "_models.AttachedDatabaseConfiguration": + ) -> _models.AttachedDatabaseConfiguration: """Returns an attached database configuration. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str :param attached_database_configuration_name: The name of the attached database configuration. + Required. :type attached_database_configuration_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AttachedDatabaseConfiguration, or the result of cls(response) + :return: AttachedDatabaseConfiguration or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.AttachedDatabaseConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AttachedDatabaseConfiguration"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AttachedDatabaseConfiguration] - request = build_get_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, attached_database_configuration_name=attached_database_configuration_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -199,15 +207,14 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}"} # type: ignore async def _create_or_update_initial( self, @@ -215,61 +222,163 @@ async def _create_or_update_initial( kusto_pool_name: str, attached_database_configuration_name: str, resource_group_name: str, - parameters: "_models.AttachedDatabaseConfiguration", + parameters: Union[_models.AttachedDatabaseConfiguration, IO], **kwargs: Any - ) -> "_models.AttachedDatabaseConfiguration": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AttachedDatabaseConfiguration"] + ) -> _models.AttachedDatabaseConfiguration: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AttachedDatabaseConfiguration] - _json = self._serialize.body(parameters, 'AttachedDatabaseConfiguration') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AttachedDatabaseConfiguration") - request = build_create_or_update_request_initial( + request = build_create_or_update_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, attached_database_configuration_name=attached_database_configuration_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("AttachedDatabaseConfiguration", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AttachedDatabaseConfiguration', pipeline_response) + deserialized = self._deserialize("AttachedDatabaseConfiguration", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AttachedDatabaseConfiguration', pipeline_response) + deserialized = self._deserialize("AttachedDatabaseConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + workspace_name: str, + kusto_pool_name: str, + attached_database_configuration_name: str, + resource_group_name: str, + parameters: _models.AttachedDatabaseConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AttachedDatabaseConfiguration]: + """Creates or updates an attached database configuration. + + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param kusto_pool_name: The name of the Kusto pool. Required. + :type kusto_pool_name: str + :param attached_database_configuration_name: The name of the attached database configuration. + Required. + :type attached_database_configuration_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: The database parameters supplied to the CreateOrUpdate operation. Required. + :type parameters: ~azure.mgmt.synapse.models.AttachedDatabaseConfiguration + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AttachedDatabaseConfiguration or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.AttachedDatabaseConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + workspace_name: str, + kusto_pool_name: str, + attached_database_configuration_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AttachedDatabaseConfiguration]: + """Creates or updates an attached database configuration. + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param kusto_pool_name: The name of the Kusto pool. Required. + :type kusto_pool_name: str + :param attached_database_configuration_name: The name of the attached database configuration. + Required. + :type attached_database_configuration_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: The database parameters supplied to the CreateOrUpdate operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AttachedDatabaseConfiguration or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.AttachedDatabaseConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -278,24 +387,27 @@ async def begin_create_or_update( kusto_pool_name: str, attached_database_configuration_name: str, resource_group_name: str, - parameters: "_models.AttachedDatabaseConfiguration", + parameters: Union[_models.AttachedDatabaseConfiguration, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.AttachedDatabaseConfiguration"]: + ) -> AsyncLROPoller[_models.AttachedDatabaseConfiguration]: """Creates or updates an attached database configuration. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str :param attached_database_configuration_name: The name of the attached database configuration. + Required. :type attached_database_configuration_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param parameters: The database parameters supplied to the CreateOrUpdate operation. - :type parameters: ~azure.mgmt.synapse.models.AttachedDatabaseConfiguration - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: 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 @@ -308,19 +420,19 @@ async def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.AttachedDatabaseConfiguration] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AttachedDatabaseConfiguration"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AttachedDatabaseConfiguration] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, attached_database_configuration_name=attached_database_configuration_name, @@ -328,32 +440,35 @@ async def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AttachedDatabaseConfiguration', pipeline_response) + deserialized = self._deserialize("AttachedDatabaseConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -363,46 +478,52 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( + request = build_delete_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, attached_database_configuration_name=attached_database_configuration_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements + async def begin_delete( self, workspace_name: str, kusto_pool_name: str, @@ -412,17 +533,16 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements ) -> AsyncLROPoller[None]: """Deletes the attached database configuration with the given name. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str :param attached_database_configuration_name: The name of the attached database configuration. + Required. :type attached_database_configuration_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -433,43 +553,47 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, attached_database_configuration_name=attached_database_configuration_name, resource_group_name=resource_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}"} # 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 8b5a81b98766..f297f5291d4d 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 @@ -6,99 +6,184 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._kusto_pool_child_resource_operations import build_check_name_availability_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class KustoPoolChildResourceOperations: - """KustoPoolChildResourceOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class KustoPoolChildResourceOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`kusto_pool_child_resource` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def check_name_availability( self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, - resource_name: "_models.DatabaseCheckNameRequest", + resource_name: _models.DatabaseCheckNameRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CheckNameResult": + ) -> _models.CheckNameResult: """Checks that the Kusto Pool child resource name is valid and is not already in use. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str :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. + :param resource_name: The name of the Kusto Pool child resource. Required. :type resource_name: ~azure.mgmt.synapse.models.DatabaseCheckNameRequest - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, + workspace_name: str, + kusto_pool_name: str, + resource_group_name: str, + resource_name: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the Kusto Pool child resource name is valid and is not already in use. + + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param kusto_pool_name: The name of the Kusto pool. Required. + :type kusto_pool_name: str + :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. Required. + :type resource_name: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult, or the result of cls(response) + :return: CheckNameResult or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.CheckNameResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, + workspace_name: str, + kusto_pool_name: str, + resource_group_name: str, + resource_name: Union[_models.DatabaseCheckNameRequest, IO], + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the Kusto Pool child resource name is valid and is not already in use. + + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param kusto_pool_name: The name of the Kusto pool. Required. + :type kusto_pool_name: str + :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 + :return: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(resource_name, 'DatabaseCheckNameRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource_name, (IO, bytes)): + _content = resource_name + else: + _json = self._serialize.body(resource_name, "DatabaseCheckNameRequest") request = build_check_name_availability_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -106,12 +191,11 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/checkNameAvailability"} # 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 21c4ec19d01a..ddc1af75325b 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,107 +6,206 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._kusto_pool_data_connections_operations import build_check_name_availability_request, build_create_or_update_request_initial, build_data_connection_validation_request_initial, build_delete_request_initial, build_get_request, build_list_by_database_request, build_update_request_initial -T = TypeVar('T') +from ...operations._kusto_pool_data_connections_operations import ( + build_check_name_availability_request, + build_create_or_update_request, + build_data_connection_validation_request, + build_delete_request, + build_get_request, + build_list_by_database_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class KustoPoolDataConnectionsOperations: - """KustoPoolDataConnectionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class KustoPoolDataConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`kusto_pool_data_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def check_name_availability( self, resource_group_name: str, workspace_name: str, kusto_pool_name: str, database_name: str, - data_connection_name: "_models.DataConnectionCheckNameRequest", + data_connection_name: _models.DataConnectionCheckNameRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CheckNameResult": + ) -> _models.CheckNameResult: """Checks that the data connection name is valid and is not already in use. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :param database_name: The name of the database in the Kusto pool. + :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. + :param data_connection_name: The name of the data connection. Required. :type data_connection_name: ~azure.mgmt.synapse.models.DataConnectionCheckNameRequest - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult, or the result of cls(response) + :return: CheckNameResult or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.CheckNameResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, + resource_group_name: str, + workspace_name: str, + kusto_pool_name: str, + database_name: str, + data_connection_name: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the data connection name is valid and is not already in use. + + :param resource_group_name: The name of the resource group. 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 kusto_pool_name: The name of the Kusto pool. Required. + :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. Required. + :type data_connection_name: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, + resource_group_name: str, + workspace_name: str, + kusto_pool_name: str, + database_name: str, + data_connection_name: Union[_models.DataConnectionCheckNameRequest, IO], + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the data connection name is valid and is not already in use. + + :param resource_group_name: The name of the resource group. 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 kusto_pool_name: The name of the Kusto pool. Required. + :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 + :return: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameResult] - _json = self._serialize.body(data_connection_name, 'DataConnectionCheckNameRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(data_connection_name, (IO, bytes)): + _content = data_connection_name + else: + _json = self._serialize.body(data_connection_name, "DataConnectionCheckNameRequest") request = build_check_name_availability_request( - subscription_id=self._config.subscription_id, 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, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,15 +213,14 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/checkNameAvailability"} # type: ignore async def _data_connection_validation_initial( self, @@ -130,82 +228,100 @@ async def _data_connection_validation_initial( workspace_name: str, kusto_pool_name: str, database_name: str, - parameters: "_models.DataConnectionValidation", + parameters: Union[_models.DataConnectionValidation, IO], **kwargs: Any - ) -> Optional["_models.DataConnectionValidationListResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DataConnectionValidationListResult"]] + ) -> Optional[_models.DataConnectionValidationListResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'DataConnectionValidation') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DataConnectionValidationListResult]] - request = build_data_connection_validation_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataConnectionValidation") + + request = build_data_connection_validation_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, content_type=content_type, json=_json, - template_url=self._data_connection_validation_initial.metadata['url'], + content=_content, + template_url=self._data_connection_validation_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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 = self._deserialize("DataConnectionValidationListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _data_connection_validation_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnectionValidation"} # type: ignore - + _data_connection_validation_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnectionValidation"} # type: ignore - @distributed_trace_async + @overload async def begin_data_connection_validation( self, resource_group_name: str, workspace_name: str, kusto_pool_name: str, database_name: str, - parameters: "_models.DataConnectionValidation", + parameters: _models.DataConnectionValidation, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DataConnectionValidationListResult"]: + ) -> AsyncLROPoller[_models.DataConnectionValidationListResult]: """Checks that the data connection parameters are valid. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :param database_name: The name of the database in the Kusto pool. + :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. + Required. :type parameters: ~azure.mgmt.synapse.models.DataConnectionValidation - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -218,19 +334,105 @@ async def begin_data_connection_validation( or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.DataConnectionValidationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataConnectionValidationListResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_data_connection_validation( + self, + resource_group_name: str, + workspace_name: str, + kusto_pool_name: str, + database_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DataConnectionValidationListResult]: + """Checks that the data connection parameters are valid. + + :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 kusto_pool_name: The name of the Kusto pool. Required. + :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 data connection parameters supplied to the CreateOrUpdate operation. + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DataConnectionValidationListResult + or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.DataConnectionValidationListResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_data_connection_validation( + self, + resource_group_name: str, + workspace_name: str, + kusto_pool_name: str, + database_name: str, + parameters: Union[_models.DataConnectionValidation, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.DataConnectionValidationListResult]: + """Checks that the data connection parameters are valid. + + :param resource_group_name: The name of the resource group. 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 kusto_pool_name: The name of the Kusto pool. Required. + :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 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. + :return: An instance of AsyncLROPoller that returns either DataConnectionValidationListResult + or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.DataConnectionValidationListResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataConnectionValidationListResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._data_connection_validation_initial( + raw_result = await self._data_connection_validation_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, @@ -238,97 +440,93 @@ async def begin_data_connection_validation( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DataConnectionValidationListResult', pipeline_response) + deserialized = self._deserialize("DataConnectionValidationListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_data_connection_validation.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnectionValidation"} # type: ignore + begin_data_connection_validation.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnectionValidation"} # type: ignore @distributed_trace def list_by_database( - self, - resource_group_name: str, - workspace_name: str, - kusto_pool_name: str, - database_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.DataConnectionListResult"]: + self, resource_group_name: str, workspace_name: str, kusto_pool_name: str, database_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DataConnection"]: """Returns the list of data connections of the given Kusto pool database. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :param database_name: The name of the database in the Kusto pool. + :param database_name: The name of the database in the Kusto pool. Required. :type database_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataConnectionListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.DataConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataConnection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.DataConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataConnectionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataConnectionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_database_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_database_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - kusto_pool_name=kusto_pool_name, - database_name=database_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -342,10 +540,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -356,11 +552,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_database.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections"} # type: ignore + list_by_database.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections"} # type: ignore @distributed_trace_async async def get( @@ -371,54 +565,58 @@ async def get( database_name: str, data_connection_name: str, **kwargs: Any - ) -> "_models.DataConnection": + ) -> _models.DataConnection: """Returns a data connection. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :param database_name: The name of the database in the Kusto pool. + :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. + :param data_connection_name: The name of the data connection. Required. :type data_connection_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataConnection, or the result of cls(response) + :return: DataConnection or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.DataConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataConnection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataConnection] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, database_name=database_name, data_connection_name=data_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -426,15 +624,14 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore async def _create_or_update_initial( self, @@ -443,61 +640,75 @@ async def _create_or_update_initial( kusto_pool_name: str, database_name: str, data_connection_name: str, - parameters: "_models.DataConnection", + parameters: Union[_models.DataConnection, IO], **kwargs: Any - ) -> "_models.DataConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataConnection"] + ) -> _models.DataConnection: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'DataConnection') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataConnection] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataConnection") + + request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, database_name=database_name, data_connection_name=data_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("DataConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DataConnection', pipeline_response) + deserialized = self._deserialize("DataConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, @@ -505,26 +716,30 @@ async def begin_create_or_update( kusto_pool_name: str, database_name: str, data_connection_name: str, - parameters: "_models.DataConnection", + parameters: _models.DataConnection, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DataConnection"]: + ) -> AsyncLROPoller[_models.DataConnection]: """Creates or updates a data connection. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :param database_name: The name of the database in the Kusto pool. + :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. + :param data_connection_name: The name of the data connection. Required. :type data_connection_name: str :param parameters: The data connection parameters supplied to the CreateOrUpdate operation. + Required. :type parameters: ~azure.mgmt.synapse.models.DataConnection - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -536,19 +751,109 @@ async def begin_create_or_update( :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] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + kusto_pool_name: str, + database_name: str, + data_connection_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DataConnection]: + """Creates or updates a data connection. + + :param resource_group_name: The name of the resource group. 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 kusto_pool_name: The name of the Kusto pool. Required. + :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. Required. + :type data_connection_name: str + :param parameters: The data connection parameters supplied to the CreateOrUpdate operation. + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DataConnection or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.DataConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + kusto_pool_name: str, + database_name: str, + data_connection_name: str, + parameters: Union[_models.DataConnection, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.DataConnection]: + """Creates or updates a data connection. + + :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 kusto_pool_name: The name of the Kusto pool. Required. + :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. 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. + :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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, @@ -557,32 +862,35 @@ async def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DataConnection', pipeline_response) + deserialized = self._deserialize("DataConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore async def _update_initial( self, @@ -591,59 +899,163 @@ async def _update_initial( kusto_pool_name: str, database_name: str, data_connection_name: str, - parameters: "_models.DataConnection", + parameters: Union[_models.DataConnection, IO], **kwargs: Any - ) -> "_models.DataConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataConnection"] + ) -> _models.DataConnection: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'DataConnection') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataConnection] - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataConnection") + + request = build_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, database_name=database_name, data_connection_name=data_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("DataConnection", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('DataConnection', pipeline_response) + deserialized = self._deserialize("DataConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + workspace_name: str, + kusto_pool_name: str, + database_name: str, + data_connection_name: str, + parameters: _models.DataConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DataConnection]: + """Updates a data connection. + + :param resource_group_name: The name of the resource group. 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 kusto_pool_name: The name of the Kusto pool. Required. + :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. Required. + :type data_connection_name: str + :param parameters: The data connection parameters supplied to the Update operation. Required. + :type parameters: ~azure.mgmt.synapse.models.DataConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DataConnection or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.DataConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + workspace_name: str, + kusto_pool_name: str, + database_name: str, + data_connection_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DataConnection]: + """Updates a data connection. + + :param resource_group_name: The name of the resource group. 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 kusto_pool_name: The name of the Kusto pool. Required. + :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. Required. + :type data_connection_name: str + :param parameters: The data connection parameters supplied to the Update operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DataConnection or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.DataConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -653,26 +1065,28 @@ async def begin_update( kusto_pool_name: str, database_name: str, data_connection_name: str, - parameters: "_models.DataConnection", + parameters: Union[_models.DataConnection, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.DataConnection"]: + ) -> AsyncLROPoller[_models.DataConnection]: """Updates a data connection. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :param database_name: The name of the database in the Kusto pool. + :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. + :param data_connection_name: The name of the data connection. Required. :type data_connection_name: str - :param parameters: The data connection parameters supplied to the Update operation. - :type parameters: ~azure.mgmt.synapse.models.DataConnection - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: 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 @@ -684,19 +1098,19 @@ async def begin_update( :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] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, @@ -705,32 +1119,35 @@ async def begin_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DataConnection', pipeline_response) + deserialized = self._deserialize("DataConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -741,47 +1158,53 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements data_connection_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, database_name=database_name, data_connection_name=data_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements + async def begin_delete( self, resource_group_name: str, workspace_name: str, @@ -793,18 +1216,16 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements """Deletes the data connection with the given name. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :param database_name: The name of the database in the Kusto pool. + :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. + :param data_connection_name: The name of the data connection. Required. :type data_connection_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -815,44 +1236,48 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, database_name=database_name, data_connection_name=data_connection_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # 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 697abde815e3..c773ac768d27 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 @@ -6,108 +6,206 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._kusto_pool_database_principal_assignments_operations import build_check_name_availability_request, build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._kusto_pool_database_principal_assignments_operations import ( + build_check_name_availability_request, + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class KustoPoolDatabasePrincipalAssignmentsOperations: - """KustoPoolDatabasePrincipalAssignmentsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class KustoPoolDatabasePrincipalAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`kusto_pool_database_principal_assignments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def check_name_availability( self, workspace_name: str, kusto_pool_name: str, database_name: str, resource_group_name: str, - principal_assignment_name: "_models.DatabasePrincipalAssignmentCheckNameRequest", + principal_assignment_name: _models.DatabasePrincipalAssignmentCheckNameRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CheckNameResult": + ) -> _models.CheckNameResult: """Checks that the database principal assignment is valid and is not already in use. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :param database_name: The name of the database in the Kusto pool. + :param database_name: The name of the database in the Kusto pool. Required. :type database_name: str :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. + :param principal_assignment_name: The name of the resource. Required. :type principal_assignment_name: ~azure.mgmt.synapse.models.DatabasePrincipalAssignmentCheckNameRequest - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, + workspace_name: str, + kusto_pool_name: str, + database_name: str, + resource_group_name: str, + principal_assignment_name: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the database principal assignment is valid and is not already in use. + + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param kusto_pool_name: The name of the Kusto pool. Required. + :type kusto_pool_name: str + :param database_name: The name of the database in the Kusto pool. Required. + :type database_name: str + :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. Required. + :type principal_assignment_name: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult, or the result of cls(response) + :return: CheckNameResult or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.CheckNameResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, + workspace_name: str, + kusto_pool_name: str, + database_name: str, + resource_group_name: str, + principal_assignment_name: Union[_models.DatabasePrincipalAssignmentCheckNameRequest, IO], + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the database principal assignment is valid and is not already in use. + + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param kusto_pool_name: The name of the Kusto pool. Required. + :type kusto_pool_name: str + :param database_name: The name of the database in the Kusto pool. Required. + :type database_name: str + :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. + :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 + :return: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameResult] - _json = self._serialize.body(principal_assignment_name, 'DatabasePrincipalAssignmentCheckNameRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(principal_assignment_name, (IO, bytes)): + _content = principal_assignment_name + else: + _json = self._serialize.body(principal_assignment_name, "DatabasePrincipalAssignmentCheckNameRequest") request = build_check_name_availability_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, database_name=database_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,80 +213,72 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/checkPrincipalAssignmentNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/checkPrincipalAssignmentNameAvailability"} # type: ignore @distributed_trace def list( - self, - workspace_name: str, - kusto_pool_name: str, - database_name: str, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.DatabasePrincipalAssignmentListResult"]: + self, workspace_name: str, kusto_pool_name: str, database_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DatabasePrincipalAssignment"]: """Lists all Kusto pool database principalAssignments. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :param database_name: The name of the database in the Kusto pool. + :param database_name: The name of the database in the Kusto pool. Required. :type database_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabasePrincipalAssignmentListResult or the - result of cls(response) + :return: An iterator like instance of either DatabasePrincipalAssignment or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.DatabasePrincipalAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.DatabasePrincipalAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DatabasePrincipalAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabasePrincipalAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, database_name=database_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - workspace_name=workspace_name, - kusto_pool_name=kusto_pool_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -202,10 +292,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -216,11 +304,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments"} # type: ignore @distributed_trace_async async def get( @@ -231,54 +317,58 @@ async def get( principal_assignment_name: str, resource_group_name: str, **kwargs: Any - ) -> "_models.DatabasePrincipalAssignment": + ) -> _models.DatabasePrincipalAssignment: """Gets a Kusto pool database principalAssignment. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :param database_name: The name of the database in the Kusto pool. + :param database_name: The name of the database in the Kusto pool. Required. :type database_name: str - :param principal_assignment_name: The name of the Kusto principalAssignment. + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. :type principal_assignment_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DatabasePrincipalAssignment, or the result of cls(response) + :return: DatabasePrincipalAssignment or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.DatabasePrincipalAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabasePrincipalAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DatabasePrincipalAssignment] - request = build_get_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, database_name=database_name, principal_assignment_name=principal_assignment_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -286,15 +376,14 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}"} # type: ignore async def _create_or_update_initial( self, @@ -303,61 +392,75 @@ async def _create_or_update_initial( database_name: str, principal_assignment_name: str, resource_group_name: str, - parameters: "_models.DatabasePrincipalAssignment", + parameters: Union[_models.DatabasePrincipalAssignment, IO], **kwargs: Any - ) -> "_models.DatabasePrincipalAssignment": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabasePrincipalAssignment"] + ) -> _models.DatabasePrincipalAssignment: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DatabasePrincipalAssignment] - _json = self._serialize.body(parameters, 'DatabasePrincipalAssignment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DatabasePrincipalAssignment") - request = build_create_or_update_request_initial( + request = build_create_or_update_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, database_name=database_name, principal_assignment_name=principal_assignment_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("DatabasePrincipalAssignment", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DatabasePrincipalAssignment', pipeline_response) + deserialized = self._deserialize("DatabasePrincipalAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update( self, workspace_name: str, @@ -365,26 +468,30 @@ async def begin_create_or_update( database_name: str, principal_assignment_name: str, resource_group_name: str, - parameters: "_models.DatabasePrincipalAssignment", + parameters: _models.DatabasePrincipalAssignment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.DatabasePrincipalAssignment"]: + ) -> AsyncLROPoller[_models.DatabasePrincipalAssignment]: """Creates a Kusto pool database principalAssignment. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :param database_name: The name of the database in the Kusto pool. + :param database_name: The name of the database in the Kusto pool. Required. :type database_name: str - :param principal_assignment_name: The name of the Kusto principalAssignment. + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. :type principal_assignment_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param parameters: The Kusto principalAssignments parameters supplied for the operation. + Required. :type parameters: ~azure.mgmt.synapse.models.DatabasePrincipalAssignment - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -397,19 +504,111 @@ async def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.DatabasePrincipalAssignment] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabasePrincipalAssignment"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + workspace_name: str, + kusto_pool_name: str, + database_name: str, + principal_assignment_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DatabasePrincipalAssignment]: + """Creates a Kusto pool database principalAssignment. + + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param kusto_pool_name: The name of the Kusto pool. Required. + :type kusto_pool_name: str + :param database_name: The name of the database in the Kusto pool. Required. + :type database_name: str + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. + :type principal_assignment_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: The Kusto principalAssignments parameters supplied for the operation. + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DatabasePrincipalAssignment or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.DatabasePrincipalAssignment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + workspace_name: str, + kusto_pool_name: str, + database_name: str, + principal_assignment_name: str, + resource_group_name: str, + parameters: Union[_models.DatabasePrincipalAssignment, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.DatabasePrincipalAssignment]: + """Creates a Kusto pool database principalAssignment. + + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param kusto_pool_name: The name of the Kusto pool. Required. + :type kusto_pool_name: str + :param database_name: The name of the database in the Kusto pool. Required. + :type database_name: str + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. + :type principal_assignment_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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. + :return: An instance of AsyncLROPoller that returns either DatabasePrincipalAssignment or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.DatabasePrincipalAssignment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DatabasePrincipalAssignment] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, database_name=database_name, @@ -418,32 +617,35 @@ async def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DatabasePrincipalAssignment', pipeline_response) + deserialized = self._deserialize("DatabasePrincipalAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -454,47 +656,53 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( + request = build_delete_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, database_name=database_name, principal_assignment_name=principal_assignment_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements + async def begin_delete( self, workspace_name: str, kusto_pool_name: str, @@ -505,19 +713,17 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements ) -> AsyncLROPoller[None]: """Deletes a Kusto pool principalAssignment. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :param database_name: The name of the database in the Kusto pool. + :param database_name: The name of the database in the Kusto pool. Required. :type database_name: str - :param principal_assignment_name: The name of the Kusto principalAssignment. + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. :type principal_assignment_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -528,44 +734,48 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, database_name=database_name, principal_assignment_name=principal_assignment_name, resource_group_name=resource_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}"} # 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 7fab0c4f36ed..0c92e510c710 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 @@ -6,104 +6,112 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._kusto_pool_databases_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_kusto_pool_request, build_update_request_initial -T = TypeVar('T') +from ...operations._kusto_pool_databases_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_kusto_pool_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class KustoPoolDatabasesOperations: - """KustoPoolDatabasesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class KustoPoolDatabasesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`kusto_pool_databases` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_kusto_pool( - self, - resource_group_name: str, - workspace_name: str, - kusto_pool_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.DatabaseListResult"]: + self, resource_group_name: str, workspace_name: str, kusto_pool_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Database"]: """Returns the list of databases of the given Kusto 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabaseListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.DatabaseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Database or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DatabaseListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabaseListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_kusto_pool_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore else: - - request = build_list_by_kusto_pool_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - kusto_pool_name=kusto_pool_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -117,10 +125,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,65 +137,62 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_kusto_pool.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases"} # type: ignore + list_by_kusto_pool.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - workspace_name: str, - kusto_pool_name: str, - database_name: str, - **kwargs: Any - ) -> "_models.Database": + self, resource_group_name: str, workspace_name: str, kusto_pool_name: str, database_name: str, **kwargs: Any + ) -> _models.Database: """Returns a database. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :param database_name: The name of the database in the Kusto pool. + :param database_name: The name of the database in the Kusto pool. Required. :type database_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Database, or the result of cls(response) + :return: Database or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.Database - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Database] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -197,15 +200,14 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}"} # type: ignore async def _create_or_update_initial( self, @@ -213,58 +215,156 @@ async def _create_or_update_initial( workspace_name: str, kusto_pool_name: str, database_name: str, - parameters: "_models.Database", + parameters: Union[_models.Database, IO], **kwargs: Any - ) -> "_models.Database": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] + ) -> _models.Database: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Database') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Database] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Database") + + request = build_create_or_update_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, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("Database", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Database', pipeline_response) + deserialized = self._deserialize("Database", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + kusto_pool_name: str, + database_name: str, + parameters: _models.Database, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Database]: + """Creates or updates a database. + + :param resource_group_name: The name of the resource group. 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 kusto_pool_name: The name of the Kusto pool. Required. + :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 CreateOrUpdate operation. Required. + :type parameters: ~azure.mgmt.synapse.models.Database + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + kusto_pool_name: str, + database_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Database]: + """Creates or updates a database. + + :param resource_group_name: The name of the resource group. 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 kusto_pool_name: The name of the Kusto pool. Required. + :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 CreateOrUpdate operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Database or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -273,24 +373,26 @@ async def begin_create_or_update( workspace_name: str, kusto_pool_name: str, database_name: str, - parameters: "_models.Database", + parameters: Union[_models.Database, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Database"]: + ) -> AsyncLROPoller[_models.Database]: """Creates or updates a database. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :param database_name: The name of the database in the Kusto pool. + :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. - :type parameters: ~azure.mgmt.synapse.models.Database - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: 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 @@ -302,19 +404,19 @@ async def begin_create_or_update( :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] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Database] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, @@ -322,32 +424,35 @@ async def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('Database', pipeline_response) + deserialized = self._deserialize("Database", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}"} # type: ignore async def _update_initial( self, @@ -355,58 +460,156 @@ async def _update_initial( workspace_name: str, kusto_pool_name: str, database_name: str, - parameters: "_models.Database", + parameters: Union[_models.Database, IO], **kwargs: Any - ) -> "_models.Database": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] + ) -> _models.Database: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Database') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Database] - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Database") + + request = build_update_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, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("Database", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('Database', pipeline_response) + deserialized = self._deserialize("Database", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + workspace_name: str, + kusto_pool_name: str, + database_name: str, + parameters: _models.Database, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Database]: + """Updates a database. + + :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 kusto_pool_name: The name of the Kusto pool. Required. + :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. Required. + :type parameters: ~azure.mgmt.synapse.models.Database + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + workspace_name: str, + kusto_pool_name: str, + database_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Database]: + """Updates a database. + + :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 kusto_pool_name: The name of the Kusto pool. Required. + :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. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Database or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -415,24 +618,26 @@ async def begin_update( workspace_name: str, kusto_pool_name: str, database_name: str, - parameters: "_models.Database", + parameters: Union[_models.Database, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Database"]: + ) -> AsyncLROPoller[_models.Database]: """Updates a database. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :param database_name: The name of the database in the Kusto pool. + :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. - :type parameters: ~azure.mgmt.synapse.models.Database - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: 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 @@ -444,19 +649,19 @@ async def begin_update( :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] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Database] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, @@ -464,101 +669,98 @@ async def begin_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('Database', pipeline_response) + deserialized = self._deserialize("Database", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - kusto_pool_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, workspace_name: str, kusto_pool_name: str, database_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + 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'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - kusto_pool_name: str, - database_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, workspace_name: str, kusto_pool_name: str, database_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the database with the given name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :param database_name: The name of the database in the Kusto pool. + :param database_name: The name of the database in the Kusto pool. Required. :type database_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -569,43 +771,47 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, database_name=database_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}"} # 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 44701a67b6a8..823cbc9b8bcf 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 @@ -6,104 +6,196 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._kusto_pool_principal_assignments_operations import build_check_name_availability_request, build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._kusto_pool_principal_assignments_operations import ( + build_check_name_availability_request, + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class KustoPoolPrincipalAssignmentsOperations: - """KustoPoolPrincipalAssignmentsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class KustoPoolPrincipalAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`kusto_pool_principal_assignments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def check_name_availability( self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, - principal_assignment_name: "_models.ClusterPrincipalAssignmentCheckNameRequest", + principal_assignment_name: _models.ClusterPrincipalAssignmentCheckNameRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CheckNameResult": + ) -> _models.CheckNameResult: """Checks that the principal assignment name is valid and is not already in use. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str :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. + :param principal_assignment_name: The name of the principal assignment. Required. :type principal_assignment_name: ~azure.mgmt.synapse.models.ClusterPrincipalAssignmentCheckNameRequest - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult, or the result of cls(response) + :return: CheckNameResult or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.CheckNameResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, + workspace_name: str, + kusto_pool_name: str, + resource_group_name: str, + principal_assignment_name: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the principal assignment name is valid and is not already in use. + + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param kusto_pool_name: The name of the Kusto pool. Required. + :type kusto_pool_name: str + :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. Required. + :type principal_assignment_name: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, + workspace_name: str, + kusto_pool_name: str, + resource_group_name: str, + principal_assignment_name: Union[_models.ClusterPrincipalAssignmentCheckNameRequest, IO], + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the principal assignment name is valid and is not already in use. + + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param kusto_pool_name: The name of the Kusto pool. Required. + :type kusto_pool_name: str + :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. + :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 + :return: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameResult] - _json = self._serialize.body(principal_assignment_name, 'ClusterPrincipalAssignmentCheckNameRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(principal_assignment_name, (IO, bytes)): + _content = principal_assignment_name + else: + _json = self._serialize.body(principal_assignment_name, "ClusterPrincipalAssignmentCheckNameRequest") request = build_check_name_availability_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -111,75 +203,69 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/checkPrincipalAssignmentNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/checkPrincipalAssignmentNameAvailability"} # type: ignore @distributed_trace def list( - self, - workspace_name: str, - kusto_pool_name: str, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ClusterPrincipalAssignmentListResult"]: + self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ClusterPrincipalAssignment"]: """Lists all Kusto pool principalAssignments. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ClusterPrincipalAssignmentListResult or the result - of cls(response) + :return: An iterator like instance of either ClusterPrincipalAssignment or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.ClusterPrincipalAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.ClusterPrincipalAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ClusterPrincipalAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterPrincipalAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - workspace_name=workspace_name, - kusto_pool_name=kusto_pool_name, - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -193,10 +279,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -207,11 +291,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments"} # type: ignore @distributed_trace_async async def get( @@ -221,51 +303,55 @@ async def get( principal_assignment_name: str, resource_group_name: str, **kwargs: Any - ) -> "_models.ClusterPrincipalAssignment": + ) -> _models.ClusterPrincipalAssignment: """Gets a Kusto pool principalAssignment. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :param principal_assignment_name: The name of the Kusto principalAssignment. + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. :type principal_assignment_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ClusterPrincipalAssignment, or the result of cls(response) + :return: ClusterPrincipalAssignment or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ClusterPrincipalAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterPrincipalAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ClusterPrincipalAssignment] - request = build_get_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, principal_assignment_name=principal_assignment_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -273,15 +359,14 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments/{principalAssignmentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments/{principalAssignmentName}"} # type: ignore async def _create_or_update_initial( self, @@ -289,58 +374,160 @@ async def _create_or_update_initial( kusto_pool_name: str, principal_assignment_name: str, resource_group_name: str, - parameters: "_models.ClusterPrincipalAssignment", + parameters: Union[_models.ClusterPrincipalAssignment, IO], **kwargs: Any - ) -> "_models.ClusterPrincipalAssignment": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterPrincipalAssignment"] + ) -> _models.ClusterPrincipalAssignment: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ClusterPrincipalAssignment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ClusterPrincipalAssignment] - request = build_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ClusterPrincipalAssignment") + + request = build_create_or_update_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, principal_assignment_name=principal_assignment_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("ClusterPrincipalAssignment", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ClusterPrincipalAssignment', pipeline_response) + deserialized = self._deserialize("ClusterPrincipalAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments/{principalAssignmentName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments/{principalAssignmentName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + workspace_name: str, + kusto_pool_name: str, + principal_assignment_name: str, + resource_group_name: str, + parameters: _models.ClusterPrincipalAssignment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ClusterPrincipalAssignment]: + """Create a Kusto pool principalAssignment. + + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param kusto_pool_name: The name of the Kusto pool. Required. + :type kusto_pool_name: str + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. + :type principal_assignment_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: The Kusto pool principalAssignment's parameters supplied for the operation. + Required. + :type parameters: ~azure.mgmt.synapse.models.ClusterPrincipalAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ClusterPrincipalAssignment or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.ClusterPrincipalAssignment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + workspace_name: str, + kusto_pool_name: str, + principal_assignment_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ClusterPrincipalAssignment]: + """Create a Kusto pool principalAssignment. + + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param kusto_pool_name: The name of the Kusto pool. Required. + :type kusto_pool_name: str + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. + :type principal_assignment_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: The Kusto pool principalAssignment's parameters supplied for the operation. + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ClusterPrincipalAssignment or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.ClusterPrincipalAssignment] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -349,24 +536,26 @@ async def begin_create_or_update( kusto_pool_name: str, principal_assignment_name: str, resource_group_name: str, - parameters: "_models.ClusterPrincipalAssignment", + parameters: Union[_models.ClusterPrincipalAssignment, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ClusterPrincipalAssignment"]: + ) -> AsyncLROPoller[_models.ClusterPrincipalAssignment]: """Create a Kusto pool principalAssignment. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :param principal_assignment_name: The name of the Kusto principalAssignment. + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. :type principal_assignment_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param parameters: The Kusto pool principalAssignment's parameters supplied for the operation. - :type parameters: ~azure.mgmt.synapse.models.ClusterPrincipalAssignment - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + 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 @@ -379,19 +568,19 @@ async def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.ClusterPrincipalAssignment] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterPrincipalAssignment"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ClusterPrincipalAssignment] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, principal_assignment_name=principal_assignment_name, @@ -399,32 +588,35 @@ async def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ClusterPrincipalAssignment', pipeline_response) + deserialized = self._deserialize("ClusterPrincipalAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments/{principalAssignmentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments/{principalAssignmentName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -434,46 +626,52 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( + request = build_delete_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, principal_assignment_name=principal_assignment_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments/{principalAssignmentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments/{principalAssignmentName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements + async def begin_delete( self, workspace_name: str, kusto_pool_name: str, @@ -483,17 +681,15 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements ) -> AsyncLROPoller[None]: """Deletes a Kusto pool principalAssignment. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :param principal_assignment_name: The name of the Kusto principalAssignment. + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. :type principal_assignment_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -504,43 +700,47 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, principal_assignment_name=principal_assignment_name, resource_group_name=resource_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments/{principalAssignmentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments/{principalAssignmentName}"} # type: ignore 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 271d12909dc1..18b3cff1cf83 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,89 +6,110 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._kusto_pools_operations import build_add_language_extensions_request_initial, build_check_name_availability_request, build_create_or_update_request_initial, build_delete_request_initial, build_detach_follower_databases_request_initial, build_get_request, build_list_by_workspace_request, build_list_follower_databases_request, build_list_language_extensions_request, build_list_skus_by_resource_request, build_list_skus_request, build_remove_language_extensions_request_initial, build_start_request_initial, build_stop_request_initial, build_update_request_initial -T = TypeVar('T') +from ...operations._kusto_pools_operations import ( + build_add_language_extensions_request, + build_check_name_availability_request, + build_create_or_update_request, + build_delete_request, + build_detach_follower_databases_request, + build_get_request, + build_list_by_workspace_request, + build_list_follower_databases_request, + build_list_language_extensions_request, + build_list_skus_by_resource_request, + build_list_skus_request, + build_remove_language_extensions_request, + build_start_request, + build_stop_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class KustoPoolsOperations: # pylint: disable=too-many-public-methods - """KustoPoolsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class KustoPoolsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`kusto_pools` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_skus( - self, - **kwargs: Any - ) -> AsyncIterable["_models.SkuDescriptionList"]: + def list_skus(self, **kwargs: Any) -> AsyncIterable["_models.SkuDescription"]: """Lists eligible SKUs for Kusto Pool resource. - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SkuDescriptionList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.SkuDescriptionList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SkuDescription or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.SkuDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SkuDescriptionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SkuDescriptionList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_skus_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_skus.metadata['url'], + template_url=self.list_skus.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_skus_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -102,10 +123,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -116,60 +135,112 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_skus.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Synapse/skus"} # type: ignore + list_skus.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Synapse/skus"} # type: ignore - @distributed_trace_async + @overload async def check_name_availability( self, location: str, - kusto_pool_name: "_models.KustoPoolCheckNameRequest", + kusto_pool_name: _models.KustoPoolCheckNameRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CheckNameResult": + ) -> _models.CheckNameResult: """Checks that the kusto pool name is valid and is not already in use. - :param location: The name of Azure region. + :param location: The name of Azure region. Required. :type location: str - :param kusto_pool_name: The name of the cluster. + :param kusto_pool_name: The name of the cluster. Required. :type kusto_pool_name: ~azure.mgmt.synapse.models.KustoPoolCheckNameRequest - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, location: str, kusto_pool_name: IO, *, 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: + """ + + @distributed_trace_async + async def check_name_availability( + self, location: str, kusto_pool_name: Union[_models.KustoPoolCheckNameRequest, IO], **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 - :return: CheckNameResult, or the result of cls(response) + :return: CheckNameResult or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.CheckNameResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(kusto_pool_name, 'KustoPoolCheckNameRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(kusto_pool_name, (IO, bytes)): + _content = kusto_pool_name + else: + _json = self._serialize.body(kusto_pool_name, "KustoPoolCheckNameRequest") request = build_check_name_availability_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -177,63 +248,63 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Synapse/locations/{location}/kustoPoolCheckNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Synapse/locations/{location}/kustoPoolCheckNameAvailability"} # type: ignore @distributed_trace_async async def list_by_workspace( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> "_models.KustoPoolListResult": + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> _models.KustoPoolListResult: """List Kusto pools. List all Kusto pools. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: KustoPoolListResult, or the result of cls(response) + :return: KustoPoolListResult or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.KustoPoolListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.KustoPoolListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.KustoPoolListResult] - request = build_list_by_workspace_request( resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, workspace_name=workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_workspace.metadata['url'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -241,65 +312,64 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_workspace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools"} # type: ignore - + list_by_workspace.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools"} # type: ignore @distributed_trace_async async def get( - self, - workspace_name: str, - kusto_pool_name: str, - resource_group_name: str, - **kwargs: Any - ) -> "_models.KustoPool": + self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.KustoPool: """Gets a Kusto pool. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: KustoPool, or the result of cls(response) + :return: KustoPool or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.KustoPool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.KustoPool"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.KustoPool] - request = build_get_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -307,97 +377,114 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}"} # type: ignore async def _create_or_update_initial( self, workspace_name: str, resource_group_name: str, kusto_pool_name: str, - parameters: "_models.KustoPool", + parameters: Union[_models.KustoPool, IO], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> "_models.KustoPool": - cls = kwargs.pop('cls', None) # type: ClsType["_models.KustoPool"] + ) -> _models.KustoPool: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'KustoPool') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.KustoPool] - request = build_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "KustoPool") + + request = build_create_or_update_request( workspace_name=workspace_name, resource_group_name=resource_group_name, kusto_pool_name=kusto_pool_name, subscription_id=self._config.subscription_id, + if_match=if_match, + if_none_match=if_none_match, api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - if_none_match=if_none_match, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("KustoPool", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('KustoPool', pipeline_response) + deserialized = self._deserialize("KustoPool", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update( self, workspace_name: str, resource_group_name: str, kusto_pool_name: str, - parameters: "_models.KustoPool", + parameters: _models.KustoPool, if_match: Optional[str] = None, if_none_match: Optional[str] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.KustoPool"]: + ) -> AsyncLROPoller[_models.KustoPool]: """Create or update a Kusto pool. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param kusto_pool_name: The name of the Kusto pool. + :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. + Required. :type parameters: ~azure.mgmt.synapse.models.KustoPool :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 @@ -407,9 +494,9 @@ 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 api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -421,19 +508,117 @@ async def begin_create_or_update( :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] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.KustoPool"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + workspace_name: str, + resource_group_name: str, + kusto_pool_name: str, + parameters: IO, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.KustoPool]: + """Create or update a Kusto pool. + + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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. + Required. + :type parameters: IO + :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 + :param if_none_match: Set to '*' to allow a new Kusto Pool to be created, but to prevent + 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. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + workspace_name: str, + resource_group_name: str, + kusto_pool_name: str, + parameters: Union[_models.KustoPool, IO], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.KustoPool]: + """Create or update a Kusto pool. + + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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 + :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 + :param if_none_match: Set to '*' to allow a new Kusto Pool to be created, but to prevent + 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.KustoPool] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore workspace_name=workspace_name, resource_group_name=resource_group_name, kusto_pool_name=kusto_pool_name, @@ -442,91 +627,196 @@ async def begin_create_or_update( if_none_match=if_none_match, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('KustoPool', pipeline_response) + deserialized = self._deserialize("KustoPool", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}"} # type: ignore async def _update_initial( self, workspace_name: str, resource_group_name: str, kusto_pool_name: str, - parameters: "_models.KustoPoolUpdate", + parameters: Union[_models.KustoPoolUpdate, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.KustoPool": - cls = kwargs.pop('cls', None) # type: ClsType["_models.KustoPool"] + ) -> _models.KustoPool: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.KustoPool] - _json = self._serialize.body(parameters, 'KustoPoolUpdate') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "KustoPoolUpdate") - request = build_update_request_initial( + request = build_update_request( workspace_name=workspace_name, resource_group_name=resource_group_name, kusto_pool_name=kusto_pool_name, subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("KustoPool", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('KustoPool', pipeline_response) + deserialized = self._deserialize("KustoPool", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}"} # type: ignore + + @overload + async def begin_update( + self, + workspace_name: str, + resource_group_name: str, + kusto_pool_name: str, + parameters: _models.KustoPoolUpdate, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.KustoPool]: + """Update a Kusto Kusto Pool. + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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: ~azure.mgmt.synapse.models.KustoPoolUpdate + :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. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + workspace_name: str, + resource_group_name: str, + kusto_pool_name: str, + parameters: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.KustoPool]: + """Update a Kusto Kusto Pool. + + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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 + :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. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -534,27 +824,29 @@ async def begin_update( workspace_name: str, resource_group_name: str, kusto_pool_name: str, - parameters: "_models.KustoPoolUpdate", + parameters: Union[_models.KustoPoolUpdate, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.KustoPool"]: + ) -> AsyncLROPoller[_models.KustoPool]: """Update a Kusto Kusto Pool. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param kusto_pool_name: The name of the Kusto pool. + :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. - :type parameters: ~azure.mgmt.synapse.models.KustoPoolUpdate + :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 :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 api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: 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 @@ -566,19 +858,19 @@ async def begin_update( :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] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.KustoPool"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.KustoPool] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore workspace_name=workspace_name, resource_group_name=resource_group_name, kusto_pool_name=kusto_pool_name, @@ -586,96 +878,95 @@ async def begin_update( if_match=if_match, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('KustoPool', pipeline_response) + deserialized = self._deserialize("KustoPool", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - workspace_name: str, - resource_group_name: str, - kusto_pool_name: str, - **kwargs: Any + self, workspace_name: str, resource_group_name: str, kusto_pool_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( + 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'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - workspace_name: str, - resource_group_name: str, - kusto_pool_name: str, - **kwargs: Any + async def begin_delete( + self, workspace_name: str, resource_group_name: str, kusto_pool_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a Kusto pool. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -686,109 +977,109 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore workspace_name=workspace_name, resource_group_name=resource_group_name, kusto_pool_name=kusto_pool_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}"} # type: ignore async def _stop_initial( # pylint: disable=inconsistent-return-statements - self, - workspace_name: str, - kusto_pool_name: str, - resource_group_name: str, - **kwargs: Any + self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_stop_request_initial( + request = build_stop_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._stop_initial.metadata['url'], + template_url=self._stop_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/stop"} # type: ignore - + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/stop"} # type: ignore @distributed_trace_async - async def begin_stop( # pylint: disable=inconsistent-return-statements - self, - workspace_name: str, - kusto_pool_name: str, - resource_group_name: str, - **kwargs: Any + async def begin_stop( + self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Stops a Kusto pool. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -799,109 +1090,109 @@ async def begin_stop( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._stop_initial( + raw_result = await self._stop_initial( # type: ignore workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/stop"} # type: ignore + begin_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/stop"} # type: ignore async def _start_initial( # pylint: disable=inconsistent-return-statements - self, - workspace_name: str, - kusto_pool_name: str, - resource_group_name: str, - **kwargs: Any + self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_start_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_start_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata['url'], + template_url=self._start_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/start"} # type: ignore - + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/start"} # type: ignore @distributed_trace_async - async def begin_start( # pylint: disable=inconsistent-return-statements - self, - workspace_name: str, - kusto_pool_name: str, - resource_group_name: str, - **kwargs: Any + async def begin_start( + self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Starts a Kusto pool. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -912,105 +1203,102 @@ async def begin_start( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._start_initial( + raw_result = await self._start_initial( # type: ignore workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/start"} # type: ignore + begin_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/start"} # type: ignore @distributed_trace def list_skus_by_resource( - self, - workspace_name: str, - kusto_pool_name: str, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ListResourceSkusResult"]: + self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.AzureResourceSku"]: """Returns the SKUs available for the provided resource. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListResourceSkusResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.ListResourceSkusResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either AzureResourceSku or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.AzureResourceSku] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListResourceSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListResourceSkusResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_skus_by_resource_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, - subscription_id=self._config.subscription_id, 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'], + template_url=self.list_skus_by_resource.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_skus_by_resource_request( - workspace_name=workspace_name, - kusto_pool_name=kusto_pool_name, - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1024,10 +1312,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1038,71 +1324,62 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_skus_by_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/skus"} # type: ignore + list_skus_by_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/skus"} # type: ignore @distributed_trace def list_language_extensions( - self, - workspace_name: str, - kusto_pool_name: str, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.LanguageExtensionsList"]: + self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.LanguageExtension"]: """Returns a list of language extensions that can run within KQL queries. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LanguageExtensionsList or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.LanguageExtensionsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either LanguageExtension or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.LanguageExtension] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LanguageExtensionsList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LanguageExtensionsList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_language_extensions_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_language_extensions.metadata['url'], + template_url=self.list_language_extensions.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_language_extensions_request( - workspace_name=workspace_name, - kusto_pool_name=kusto_pool_name, - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1116,10 +1393,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1130,83 +1405,173 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_language_extensions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/listLanguageExtensions"} # type: ignore + list_language_extensions.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/listLanguageExtensions"} # type: ignore async def _add_language_extensions_initial( # pylint: disable=inconsistent-return-statements self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, - language_extensions_to_add: "_models.LanguageExtensionsList", + language_extensions_to_add: Union[_models.LanguageExtensionsList, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(language_extensions_to_add, 'LanguageExtensionsList') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(language_extensions_to_add, (IO, bytes)): + _content = language_extensions_to_add + else: + _json = self._serialize.body(language_extensions_to_add, "LanguageExtensionsList") - request = build_add_language_extensions_request_initial( + request = build_add_language_extensions_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._add_language_extensions_initial.metadata['url'], + content=_content, + template_url=self._add_language_extensions_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _add_language_extensions_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/addLanguageExtensions"} # type: ignore + _add_language_extensions_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/addLanguageExtensions"} # type: ignore + + @overload + async def begin_add_language_extensions( + self, + workspace_name: str, + kusto_pool_name: str, + resource_group_name: str, + language_extensions_to_add: _models.LanguageExtensionsList, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Add a list of language extensions that can run within KQL queries. + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param kusto_pool_name: The name of the Kusto pool. Required. + :type kusto_pool_name: str + :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. Required. + :type language_extensions_to_add: ~azure.mgmt.synapse.models.LanguageExtensionsList + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_add_language_extensions( + self, + workspace_name: str, + kusto_pool_name: str, + resource_group_name: str, + language_extensions_to_add: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Add a list of language extensions that can run within KQL queries. + + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param kusto_pool_name: The name of the Kusto pool. Required. + :type kusto_pool_name: str + :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. Required. + :type language_extensions_to_add: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async - async def begin_add_language_extensions( # pylint: disable=inconsistent-return-statements + async def begin_add_language_extensions( self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, - language_extensions_to_add: "_models.LanguageExtensionsList", + language_extensions_to_add: Union[_models.LanguageExtensionsList, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Add a list of language extensions that can run within KQL queries. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str :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. - :type language_extensions_to_add: ~azure.mgmt.synapse.models.LanguageExtensionsList - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: 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 @@ -1217,120 +1582,216 @@ async def begin_add_language_extensions( # pylint: disable=inconsistent-return- Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._add_language_extensions_initial( + raw_result = await self._add_language_extensions_initial( # type: ignore workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_name, language_extensions_to_add=language_extensions_to_add, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_add_language_extensions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/addLanguageExtensions"} # type: ignore + begin_add_language_extensions.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/addLanguageExtensions"} # type: ignore async def _remove_language_extensions_initial( # pylint: disable=inconsistent-return-statements self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, - language_extensions_to_remove: "_models.LanguageExtensionsList", + language_extensions_to_remove: Union[_models.LanguageExtensionsList, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(language_extensions_to_remove, 'LanguageExtensionsList') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_remove_language_extensions_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(language_extensions_to_remove, (IO, bytes)): + _content = language_extensions_to_remove + else: + _json = self._serialize.body(language_extensions_to_remove, "LanguageExtensionsList") + + request = build_remove_language_extensions_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._remove_language_extensions_initial.metadata['url'], + content=_content, + template_url=self._remove_language_extensions_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _remove_language_extensions_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/removeLanguageExtensions"} # type: ignore + _remove_language_extensions_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/removeLanguageExtensions"} # type: ignore + + @overload + async def begin_remove_language_extensions( + self, + workspace_name: str, + kusto_pool_name: str, + resource_group_name: str, + language_extensions_to_remove: _models.LanguageExtensionsList, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Remove a list of language extensions that can run within KQL queries. + + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param kusto_pool_name: The name of the Kusto pool. Required. + :type kusto_pool_name: str + :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. Required. + :type language_extensions_to_remove: ~azure.mgmt.synapse.models.LanguageExtensionsList + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_remove_language_extensions( + self, + workspace_name: str, + kusto_pool_name: str, + resource_group_name: str, + language_extensions_to_remove: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Remove a list of language extensions that can run within KQL queries. + + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param kusto_pool_name: The name of the Kusto pool. Required. + :type kusto_pool_name: str + :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. Required. + :type language_extensions_to_remove: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async - async def begin_remove_language_extensions( # pylint: disable=inconsistent-return-statements + async def begin_remove_language_extensions( self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, - language_extensions_to_remove: "_models.LanguageExtensionsList", + language_extensions_to_remove: Union[_models.LanguageExtensionsList, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Remove a list of language extensions that can run within KQL queries. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str :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. - :type language_extensions_to_remove: ~azure.mgmt.synapse.models.LanguageExtensionsList - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: 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 @@ -1341,109 +1802,108 @@ async def begin_remove_language_extensions( # pylint: disable=inconsistent-retu Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._remove_language_extensions_initial( + raw_result = await self._remove_language_extensions_initial( # type: ignore workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_name, language_extensions_to_remove=language_extensions_to_remove, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_remove_language_extensions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/removeLanguageExtensions"} # type: ignore + begin_remove_language_extensions.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/removeLanguageExtensions"} # type: ignore @distributed_trace def list_follower_databases( - self, - workspace_name: str, - kusto_pool_name: str, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.FollowerDatabaseListResult"]: + self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.FollowerDatabaseDefinition"]: """Returns a list of databases that are owned by this Kusto Pool and were followed by another Kusto Pool. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FollowerDatabaseListResult or the result of + :return: An iterator like instance of either FollowerDatabaseDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.FollowerDatabaseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.FollowerDatabaseDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.FollowerDatabaseListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.FollowerDatabaseListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_follower_databases_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_follower_databases.metadata['url'], + template_url=self.list_follower_databases.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_follower_databases_request( - workspace_name=workspace_name, - kusto_pool_name=kusto_pool_name, - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1457,10 +1917,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1471,83 +1929,173 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_follower_databases.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/listFollowerDatabases"} # type: ignore + list_follower_databases.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/listFollowerDatabases"} # type: ignore async def _detach_follower_databases_initial( # pylint: disable=inconsistent-return-statements self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, - follower_database_to_remove: "_models.FollowerDatabaseDefinition", + follower_database_to_remove: Union[_models.FollowerDatabaseDefinition, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(follower_database_to_remove, 'FollowerDatabaseDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(follower_database_to_remove, (IO, bytes)): + _content = follower_database_to_remove + else: + _json = self._serialize.body(follower_database_to_remove, "FollowerDatabaseDefinition") - request = build_detach_follower_databases_request_initial( + request = build_detach_follower_databases_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._detach_follower_databases_initial.metadata['url'], + content=_content, + template_url=self._detach_follower_databases_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _detach_follower_databases_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/detachFollowerDatabases"} # type: ignore + _detach_follower_databases_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/detachFollowerDatabases"} # type: ignore + @overload + async def begin_detach_follower_databases( + self, + workspace_name: str, + kusto_pool_name: str, + resource_group_name: str, + follower_database_to_remove: _models.FollowerDatabaseDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Detaches all followers of a database owned by this Kusto Pool. + + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param kusto_pool_name: The name of the Kusto pool. Required. + :type kusto_pool_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param follower_database_to_remove: The follower databases properties to remove. Required. + :type follower_database_to_remove: ~azure.mgmt.synapse.models.FollowerDatabaseDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_detach_follower_databases( + self, + workspace_name: str, + kusto_pool_name: str, + resource_group_name: str, + follower_database_to_remove: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Detaches all followers of a database owned by this Kusto Pool. + + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param kusto_pool_name: The name of the Kusto pool. Required. + :type kusto_pool_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param follower_database_to_remove: The follower databases properties to remove. Required. + :type follower_database_to_remove: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async - async def begin_detach_follower_databases( # pylint: disable=inconsistent-return-statements + async def begin_detach_follower_databases( self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, - follower_database_to_remove: "_models.FollowerDatabaseDefinition", + follower_database_to_remove: Union[_models.FollowerDatabaseDefinition, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Detaches all followers of a database owned by this Kusto Pool. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param follower_database_to_remove: The follower databases properties to remove. - :type follower_database_to_remove: ~azure.mgmt.synapse.models.FollowerDatabaseDefinition - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: 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 @@ -1558,45 +2106,49 @@ async def begin_detach_follower_databases( # pylint: disable=inconsistent-retur Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._detach_follower_databases_initial( + raw_result = await self._detach_follower_databases_initial( # type: ignore workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_name, follower_database_to_remove=follower_database_to_remove, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_detach_follower_databases.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/detachFollowerDatabases"} # type: ignore + begin_detach_follower_databases.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/detachFollowerDatabases"} # 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 3e83191c445a..1769043479bc 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 @@ -9,95 +9,99 @@ from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.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 -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class LibrariesOperations: - """LibrariesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class LibrariesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`libraries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_workspace( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.LibraryListResponse"]: + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.LibraryResource"]: """List the libraries in a workspace. List libraries in a workspace. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LibraryListResponse or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.LibraryListResponse] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LibraryListResponse] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LibraryListResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore else: - - request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -111,10 +115,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -125,8 +127,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_workspace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/libraries"} # type: ignore + list_by_workspace.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/libraries"} # type: ignore 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 85c863db1905..733427362666 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 @@ -8,92 +8,99 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._library_operations import build_get_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class LibraryOperations: - """LibraryOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class LibraryOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`library` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - library_name: str, - workspace_name: str, - **kwargs: Any - ) -> "_models.LibraryResource": + self, resource_group_name: str, library_name: str, workspace_name: str, **kwargs: Any + ) -> _models.LibraryResource: """Get library by name. Get library by name in a workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param library_name: Library name. + :param library_name: Library name. Required. :type library_name: str - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LibraryResource, or the result of cls(response) + :return: LibraryResource or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.LibraryResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LibraryResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LibraryResource] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,12 +108,11 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/libraries/{libraryName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/libraries/{libraryName}"} # 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 4579605b2900..d620f0968d4d 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 @@ -6,89 +6,151 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, List, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._operations import build_check_name_availability_request, build_get_azure_async_header_result_request, build_get_location_header_result_request, build_list_request -T = TypeVar('T') +from ...operations._operations import ( + build_check_name_availability_request, + build_get_azure_async_header_result_request, + build_get_location_header_result_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def check_name_availability( - self, - request: "_models.CheckNameAvailabilityRequest", - **kwargs: Any - ) -> "_models.CheckNameAvailabilityResponse": + self, request: _models.CheckNameAvailabilityRequest, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResponse: """Check name availability. Check whether a workspace name is available. - :param request: The check request. + :param request: The check request. Required. :type request: ~azure.mgmt.synapse.models.CheckNameAvailabilityRequest - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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) + :return: CheckNameAvailabilityResponse or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.CheckNameAvailabilityResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, request: IO, *, 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: + """ + + @distributed_trace_async + async def check_name_availability( + self, request: Union[_models.CheckNameAvailabilityRequest, IO], **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 + :return: CheckNameAvailabilityResponse or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.CheckNameAvailabilityResponse + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(request, 'CheckNameAvailabilityRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(request, (IO, bytes)): + _content = request + else: + _json = self._serialize.body(request, "CheckNameAvailabilityRequest") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,48 +158,51 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Synapse/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Synapse/checkNameAvailability"} # type: ignore @distributed_trace_async - async def list( - self, - **kwargs: Any - ) -> List["_models.AvailableRpOperation"]: + async def list(self, **kwargs: Any) -> List[_models.AvailableRpOperation]: """All operations. 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) + :return: list of AvailableRpOperation or the result of cls(response) :rtype: list[~azure.mgmt.synapse.models.AvailableRpOperation] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.AvailableRpOperation"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[List[_models.AvailableRpOperation]] - request = build_list_request( - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -145,67 +210,66 @@ async def list( 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/providers/Microsoft.Synapse/operations"} # type: ignore - + list.metadata = {"url": "/providers/Microsoft.Synapse/operations"} # type: ignore @distributed_trace_async async def get_location_header_result( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - operation_id: str, - **kwargs: Any + self, resource_group_name: str, workspace_name: str, operation_id: str, **kwargs: Any ) -> None: """Get operation result. Get the result of an 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param operation_id: Operation ID. + :param operation_id: Operation ID. Required. :type operation_id: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_get_location_header_result_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202, 204]: @@ -216,60 +280,59 @@ async def get_location_header_result( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - get_location_header_result.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/operationResults/{operationId}"} # type: ignore - + get_location_header_result.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/operationResults/{operationId}"} # type: ignore @distributed_trace_async async def get_azure_async_header_result( - self, - resource_group_name: str, - workspace_name: str, - operation_id: str, - **kwargs: Any - ) -> Optional["_models.OperationResource"]: + self, resource_group_name: str, workspace_name: str, operation_id: str, **kwargs: Any + ) -> Optional[_models.OperationResource]: """Get operation status. Get the status of an 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param operation_id: Operation ID. + :param operation_id: Operation ID. Required. :type operation_id: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationResource, or the result of cls(response) + :return: OperationResource or None or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.OperationResource or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationResource"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.OperationResource]] - request = build_get_azure_async_header_result_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 404]: @@ -279,12 +342,11 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_azure_async_header_result.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/operationStatuses/{operationId}"} # type: ignore - + get_azure_async_header_result.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/operationStatuses/{operationId}"} # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_patch.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 201a1f9f41ec..b71834ebadd0 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 @@ -6,96 +6,108 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._private_endpoint_connections_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._private_endpoint_connections_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PrivateEndpointConnectionsOperations: - """PrivateEndpointConnectionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - workspace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + self, resource_group_name: str, workspace_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: """Gets a private endpoint connection. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -103,72 +115,165 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore async def _create_initial( self, resource_group_name: str, workspace_name: str, private_endpoint_connection_name: str, - request: "_models.PrivateEndpointConnection", + request: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + ) -> _models.PrivateEndpointConnection: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(request, 'PrivateEndpointConnection') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(request, (IO, bytes)): + _content = request + else: + _json = self._serialize.body(request, "PrivateEndpointConnection") + + request = build_create_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, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + workspace_name: str, + private_endpoint_connection_name: str, + request: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection. + + :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 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: ~azure.mgmt.synapse.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + workspace_name: str, + private_endpoint_connection_name: str, + request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection. + :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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -176,22 +281,24 @@ async def begin_create( resource_group_name: str, workspace_name: str, private_endpoint_connection_name: str, - request: "_models.PrivateEndpointConnection", + request: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.PrivateEndpointConnection"]: + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Approve or reject a private endpoint connection. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :param request: Request body of private endpoint connection to create. - :type request: ~azure.mgmt.synapse.models.PrivateEndpointConnection - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 @@ -204,121 +311,123 @@ async def begin_create( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, private_endpoint_connection_name=private_endpoint_connection_name, request=request, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore async def _delete_initial( - self, - resource_group_name: str, - workspace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> Optional["_models.OperationResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationResource"]] + self, resource_group_name: str, workspace_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> Optional[_models.OperationResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.OperationResource]] + + 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'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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 = self._deserialize("OperationResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - workspace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> AsyncLROPoller["_models.OperationResource"]: + self, resource_group_name: str, workspace_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: """Delete a private endpoint connection. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -330,103 +439,103 @@ async def begin_delete( :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] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('OperationResource', pipeline_response) + deserialized = self._deserialize("OperationResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnectionList"]: + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: """Lists private endpoint connection in workspace. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionList or the result of + :return: An iterator like instance of either PrivateEndpointConnection or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.PrivateEndpointConnectionList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -440,10 +549,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -454,8 +561,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateEndpointConnections"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateEndpointConnections"} # type: ignore 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 d65a38e81999..52be6310e6c6 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 @@ -9,102 +9,112 @@ from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._private_endpoint_connections_private_link_hub_operations import build_get_request, build_list_request -T = TypeVar('T') +from ...operations._private_endpoint_connections_private_link_hub_operations import ( + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PrivateEndpointConnectionsPrivateLinkHubOperations: - """PrivateEndpointConnectionsPrivateLinkHubOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateEndpointConnectionsPrivateLinkHubOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`private_endpoint_connections_private_link_hub` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - private_link_hub_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnectionForPrivateLinkHubResourceCollectionResponse"]: + self, resource_group_name: str, private_link_hub_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnectionForPrivateLinkHub"]: """Get all PrivateEndpointConnections in the PrivateLinkHub. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_link_hub_name: Name of the privateLinkHub. + :param private_link_hub_name: Name of the privateLinkHub. Required. :type private_link_hub_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either - PrivateEndpointConnectionForPrivateLinkHubResourceCollectionResponse or the result of - cls(response) + :return: An iterator like instance of either PrivateEndpointConnectionForPrivateLinkHub or the + result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.PrivateEndpointConnectionForPrivateLinkHubResourceCollectionResponse] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.PrivateEndpointConnectionForPrivateLinkHub] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop( + "cls", None + ) # type: ClsType[_models.PrivateEndpointConnectionForPrivateLinkHubResourceCollectionResponse] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionForPrivateLinkHubResourceCollectionResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, private_link_hub_name=private_link_hub_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - private_link_hub_name=private_link_hub_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnectionForPrivateLinkHubResourceCollectionResponse", pipeline_response) + deserialized = self._deserialize( + "PrivateEndpointConnectionForPrivateLinkHubResourceCollectionResponse", pipeline_response + ) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -113,10 +123,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -127,61 +135,59 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}/privateEndpointConnections"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}/privateEndpointConnections"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - private_link_hub_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> "_models.PrivateEndpointConnectionForPrivateLinkHub": + self, resource_group_name: str, private_link_hub_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnectionForPrivateLinkHub: """Get all PrivateEndpointConnection in the PrivateLinkHub by name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_link_hub_name: Name of the privateLinkHub. + :param private_link_hub_name: Name of the privateLinkHub. Required. :type private_link_hub_name: str - :param private_endpoint_connection_name: Name of the privateEndpointConnection. + :param private_endpoint_connection_name: Name of the privateEndpointConnection. Required. :type private_endpoint_connection_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnectionForPrivateLinkHub, or the result of cls(response) + :return: PrivateEndpointConnectionForPrivateLinkHub or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.PrivateEndpointConnectionForPrivateLinkHub - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionForPrivateLinkHub"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionForPrivateLinkHub] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -189,12 +195,11 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}/privateEndpointConnections/{privateEndpointConnectionName}"} # 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 4c17ad0f73ae..60ece8b9f892 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 @@ -9,98 +9,100 @@ from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._private_link_hub_private_link_resources_operations import build_get_request, build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PrivateLinkHubPrivateLinkResourcesOperations: - """PrivateLinkHubPrivateLinkResourcesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateLinkHubPrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`private_link_hub_private_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - private_link_hub_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.PrivateLinkResourceListResult"]: + self, resource_group_name: str, private_link_hub_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateLinkResource"]: """Private Link Resources. Get all private link resources for a private link hub. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_link_hub_name: The name of the private link hub. + :param private_link_hub_name: The name of the private link hub. Required. :type private_link_hub_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkResourceListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.PrivateLinkResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, private_link_hub_name=private_link_hub_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - private_link_hub_name=private_link_hub_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -114,10 +116,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -128,63 +128,61 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}/privateLinkResources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}/privateLinkResources"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - private_link_hub_name: str, - private_link_resource_name: str, - **kwargs: Any - ) -> "_models.PrivateLinkResource": + self, resource_group_name: str, private_link_hub_name: str, private_link_resource_name: str, **kwargs: Any + ) -> _models.PrivateLinkResource: """Get Private Link Hub Private Link Resource. Get private link resource in private link hub. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_link_hub_name: The name of the private link hub. + :param private_link_hub_name: The name of the private link hub. Required. :type private_link_hub_name: str - :param private_link_resource_name: The name of the private link resource. + :param private_link_resource_name: The name of the private link resource. Required. :type private_link_resource_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResource, or the result of cls(response) + :return: PrivateLinkResource or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.PrivateLinkResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -192,12 +190,11 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}/privateLinkResources/{privateLinkResourceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}/privateLinkResources/{privateLinkResourceName}"} # 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 97692af19593..c325ed87fdab 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 @@ -6,96 +6,107 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._private_link_hubs_operations import build_create_or_update_request, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_request -T = TypeVar('T') +from ...operations._private_link_hubs_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PrivateLinkHubsOperations: - """PrivateLinkHubsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateLinkHubsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`private_link_hubs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.PrivateLinkHubInfoListResult"]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateLinkHub"]: """Returns a list of privateLinkHubs in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkHubInfoListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.PrivateLinkHubInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkHubInfoListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkHubInfoListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -109,10 +120,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -123,57 +132,54 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - private_link_hub_name: str, - **kwargs: Any - ) -> "_models.PrivateLinkHub": + async def get(self, resource_group_name: str, private_link_hub_name: str, **kwargs: Any) -> _models.PrivateLinkHub: """Gets a privateLinkHub. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_link_hub_name: Name of the privateLinkHub. + :param private_link_hub_name: Name of the privateLinkHub. Required. :type private_link_hub_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkHub, or the result of cls(response) + :return: PrivateLinkHub or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.PrivateLinkHub - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkHub"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkHub] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -181,68 +187,139 @@ async def get( 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}"} # type: ignore + @overload + async def update( + self, + resource_group_name: str, + private_link_hub_name: str, + private_link_hub_patch_info: _models.PrivateLinkHubPatchInfo, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateLinkHub: + """Updates a privateLinkHub. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :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. Required. + :type private_link_hub_patch_info: ~azure.mgmt.synapse.models.PrivateLinkHubPatchInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: + """ + + @overload + async def update( + self, + resource_group_name: str, + private_link_hub_name: str, + private_link_hub_patch_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateLinkHub: + """Updates a privateLinkHub. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :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. Required. + :type private_link_hub_patch_info: 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: PrivateLinkHub or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.PrivateLinkHub + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def update( self, resource_group_name: str, private_link_hub_name: str, - private_link_hub_patch_info: "_models.PrivateLinkHubPatchInfo", + private_link_hub_patch_info: Union[_models.PrivateLinkHubPatchInfo, IO], **kwargs: Any - ) -> "_models.PrivateLinkHub": + ) -> _models.PrivateLinkHub: """Updates a privateLinkHub. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_link_hub_name: Name of the privateLinkHub. + :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. - :type private_link_hub_patch_info: ~azure.mgmt.synapse.models.PrivateLinkHubPatchInfo - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 - :return: PrivateLinkHub, or the result of cls(response) + :return: PrivateLinkHub or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.PrivateLinkHub - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkHub"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkHub] - _json = self._serialize.body(private_link_hub_patch_info, 'PrivateLinkHubPatchInfo') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_link_hub_patch_info, (IO, bytes)): + _content = private_link_hub_patch_info + else: + _json = self._serialize.body(private_link_hub_patch_info, "PrivateLinkHubPatchInfo") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, private_link_hub_name=private_link_hub_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -251,71 +328,142 @@ async def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateLinkHub', pipeline_response) + deserialized = self._deserialize("PrivateLinkHub", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateLinkHub', pipeline_response) + deserialized = self._deserialize("PrivateLinkHub", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}"} # type: ignore + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}"} # type: ignore + @overload + async def create_or_update( + self, + resource_group_name: str, + private_link_hub_name: str, + private_link_hub_info: _models.PrivateLinkHub, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateLinkHub: + """Creates or updates a privateLinkHub. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :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_info: PrivateLinkHub create or update request properties. Required. + :type private_link_hub_info: ~azure.mgmt.synapse.models.PrivateLinkHub + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + private_link_hub_name: str, + private_link_hub_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateLinkHub: + """Creates or updates a privateLinkHub. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :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_info: PrivateLinkHub create or update request properties. Required. + :type private_link_hub_info: 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: PrivateLinkHub or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.PrivateLinkHub + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update( self, resource_group_name: str, private_link_hub_name: str, - private_link_hub_info: "_models.PrivateLinkHub", + private_link_hub_info: Union[_models.PrivateLinkHub, IO], **kwargs: Any - ) -> "_models.PrivateLinkHub": + ) -> _models.PrivateLinkHub: """Creates or updates a privateLinkHub. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_link_hub_name: Name of the privateLinkHub. + :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. - :type private_link_hub_info: ~azure.mgmt.synapse.models.PrivateLinkHub - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 - :return: PrivateLinkHub, or the result of cls(response) + :return: PrivateLinkHub or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.PrivateLinkHub - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkHub"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(private_link_hub_info, 'PrivateLinkHub') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkHub] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_link_hub_info, (IO, bytes)): + _content = private_link_hub_info + else: + _json = self._serialize.body(private_link_hub_info, "PrivateLinkHub") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, private_link_hub_name=private_link_hub_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -324,77 +472,74 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateLinkHub', pipeline_response) + deserialized = self._deserialize("PrivateLinkHub", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateLinkHub', pipeline_response) + deserialized = self._deserialize("PrivateLinkHub", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - private_link_hub_name: str, - **kwargs: Any + self, resource_group_name: str, private_link_hub_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + 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'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - private_link_hub_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, private_link_hub_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a privateLinkHub. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_link_hub_name: Name of the privateLinkHub. + :param private_link_hub_name: Name of the privateLinkHub. Required. :type private_link_hub_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -405,89 +550,89 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, private_link_hub_name=private_link_hub_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.PrivateLinkHubInfoListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.PrivateLinkHub"]: """Returns a list of privateLinkHubs in a subscription. - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkHubInfoListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.PrivateLinkHubInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkHubInfoListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkHubInfoListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -501,10 +646,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -515,8 +658,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Synapse/privateLinkHubs"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Synapse/privateLinkHubs"} # type: ignore 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 510b5d0858b8..812db345a4ba 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 @@ -9,98 +9,100 @@ from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_get_request, build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PrivateLinkResourcesOperations: - """PrivateLinkResourcesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`private_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.PrivateLinkResourceListResult"]: + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateLinkResource"]: """Private Link Resources. Get all private link resources for a workspaces. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkResourceListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.PrivateLinkResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -114,10 +116,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -128,63 +128,61 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateLinkResources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateLinkResources"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - workspace_name: str, - private_link_resource_name: str, - **kwargs: Any - ) -> "_models.PrivateLinkResource": + self, resource_group_name: str, workspace_name: str, private_link_resource_name: str, **kwargs: Any + ) -> _models.PrivateLinkResource: """Get Private Link Resource. Get private link resource in workspace. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param private_link_resource_name: The name of the private link resource. + :param private_link_resource_name: The name of the private link resource. Required. :type private_link_resource_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResource, or the result of cls(response) + :return: PrivateLinkResource or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.PrivateLinkResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -192,12 +190,11 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateLinkResources/{privateLinkResourceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateLinkResources/{privateLinkResourceName}"} # 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 a687a1f607aa..f5a5d35d13aa 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 @@ -9,92 +9,99 @@ from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._restorable_dropped_sql_pools_operations import build_get_request, build_list_by_workspace_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class RestorableDroppedSqlPoolsOperations: - """RestorableDroppedSqlPoolsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RestorableDroppedSqlPoolsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`restorable_dropped_sql_pools` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - workspace_name: str, - restorable_dropped_sql_pool_id: str, - **kwargs: Any - ) -> "_models.RestorableDroppedSqlPool": + self, resource_group_name: str, workspace_name: str, restorable_dropped_sql_pool_id: str, **kwargs: Any + ) -> _models.RestorableDroppedSqlPool: """Gets a deleted sql pool that can be restored. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str :param restorable_dropped_sql_pool_id: The id of the deleted Sql Pool in the form of - sqlPoolName,deletionTimeInFileTimeFormat. + sqlPoolName,deletionTimeInFileTimeFormat. Required. :type restorable_dropped_sql_pool_id: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RestorableDroppedSqlPool, or the result of cls(response) + :return: RestorableDroppedSqlPool or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.RestorableDroppedSqlPool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorableDroppedSqlPool"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RestorableDroppedSqlPool] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -102,70 +109,66 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/restorableDroppedSqlPools/{restorableDroppedSqlPoolId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/restorableDroppedSqlPools/{restorableDroppedSqlPoolId}"} # type: ignore @distributed_trace def list_by_workspace( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.RestorableDroppedSqlPoolListResult"]: + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.RestorableDroppedSqlPool"]: """Gets a list of deleted Sql pools that can be restored. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RestorableDroppedSqlPoolListResult or the result - of cls(response) + :return: An iterator like instance of either RestorableDroppedSqlPool or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.RestorableDroppedSqlPoolListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.RestorableDroppedSqlPool] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RestorableDroppedSqlPoolListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorableDroppedSqlPoolListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore else: - - request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -179,10 +182,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -193,8 +194,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_workspace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/restorableDroppedSqlPools"} # type: ignore + list_by_workspace.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/restorableDroppedSqlPools"} # type: ignore 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 684074347e7f..0465e77a2d8e 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 @@ -8,92 +8,99 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._spark_configuration_operations import build_get_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SparkConfigurationOperations: - """SparkConfigurationOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SparkConfigurationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`spark_configuration` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - spark_configuration_name: str, - workspace_name: str, - **kwargs: Any - ) -> "_models.SparkConfigurationResource": + self, resource_group_name: str, spark_configuration_name: str, workspace_name: str, **kwargs: Any + ) -> _models.SparkConfigurationResource: """Get SparkConfiguration by name. Get SparkConfiguration by name in a workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param spark_configuration_name: SparkConfiguration name. + :param spark_configuration_name: SparkConfiguration name. Required. :type spark_configuration_name: str - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SparkConfigurationResource, or the result of cls(response) + :return: SparkConfigurationResource or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SparkConfigurationResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SparkConfigurationResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SparkConfigurationResource] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,12 +108,11 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sparkconfigurations/{sparkConfigurationName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sparkconfigurations/{sparkConfigurationName}"} # 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 10b21bec8fdd..5c7c162603c8 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 @@ -9,97 +9,101 @@ from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.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 -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SparkConfigurationsOperations: - """SparkConfigurationsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SparkConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`spark_configurations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_workspace( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.SparkConfigurationListResponse"]: + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SparkConfigurationResource"]: """List the sparkConfigurations in a workspace. List sparkConfigurations in a workspace. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SparkConfigurationListResponse or the result of + :return: An iterator like instance of either SparkConfigurationResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.SparkConfigurationListResponse] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.SparkConfigurationResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SparkConfigurationListResponse] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SparkConfigurationListResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore else: - - request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -113,10 +117,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -127,8 +129,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_workspace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sparkconfigurations"} # type: ignore + list_by_workspace.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sparkconfigurations"} # type: ignore 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 b5b915036c5d..21699f66f05e 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 @@ -6,116 +6,198 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._sql_pool_blob_auditing_policies_operations import build_create_or_update_request, build_get_request, build_list_by_sql_pool_request -T = TypeVar('T') +from ...operations._sql_pool_blob_auditing_policies_operations import ( + build_create_or_update_request, + build_get_request, + build_list_by_sql_pool_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SqlPoolBlobAuditingPoliciesOperations: - """SqlPoolBlobAuditingPoliciesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SqlPoolBlobAuditingPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`sql_pool_blob_auditing_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> "_models.SqlPoolBlobAuditingPolicy": + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> _models.SqlPoolBlobAuditingPolicy: """Get a SQL pool's blob auditing policy. Get a SQL pool's blob auditing policy. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword 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) + :return: SqlPoolBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolBlobAuditingPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolBlobAuditingPolicy"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - blob_auditing_policy_name = kwargs.pop('blob_auditing_policy_name', "default") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + blob_auditing_policy_name = kwargs.pop("blob_auditing_policy_name", "default") # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolBlobAuditingPolicy] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/auditingSettings/{blobAuditingPolicyName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/auditingSettings/{blobAuditingPolicyName}"} # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + parameters: _models.SqlPoolBlobAuditingPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SqlPoolBlobAuditingPolicy: + """Creates or updates a SQL pool's blob auditing policy. + + Creates or updates a SQL pool's blob auditing policy. + :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 database blob auditing policy. Required. + :type parameters: ~azure.mgmt.synapse.models.SqlPoolBlobAuditingPolicy + :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: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SqlPoolBlobAuditingPolicy: + """Creates or updates a SQL pool's blob auditing policy. + + Creates or updates a SQL pool's blob auditing policy. + + :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 database blob auditing policy. 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 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: + """ @distributed_trace_async async def create_or_update( @@ -123,63 +205,79 @@ async def create_or_update( resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: "_models.SqlPoolBlobAuditingPolicy", + parameters: Union[_models.SqlPoolBlobAuditingPolicy, IO], **kwargs: Any - ) -> "_models.SqlPoolBlobAuditingPolicy": + ) -> _models.SqlPoolBlobAuditingPolicy: """Creates or updates a SQL pool's blob auditing policy. Creates or updates a SQL pool's blob auditing policy. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param parameters: The database blob auditing policy. - :type parameters: ~azure.mgmt.synapse.models.SqlPoolBlobAuditingPolicy - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 - :return: SqlPoolBlobAuditingPolicy, or the result of cls(response) + :return: SqlPoolBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolBlobAuditingPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolBlobAuditingPolicy"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - blob_auditing_policy_name = kwargs.pop('blob_auditing_policy_name', "default") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + blob_auditing_policy_name = kwargs.pop("blob_auditing_policy_name", "default") # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolBlobAuditingPolicy] - _json = self._serialize.body(parameters, 'SqlPoolBlobAuditingPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SqlPoolBlobAuditingPolicy") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, 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, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -187,78 +285,72 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('SqlPoolBlobAuditingPolicy', pipeline_response) + deserialized = self._deserialize("SqlPoolBlobAuditingPolicy", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SqlPoolBlobAuditingPolicy', pipeline_response) + deserialized = self._deserialize("SqlPoolBlobAuditingPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/auditingSettings/{blobAuditingPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/auditingSettings/{blobAuditingPolicyName}"} # type: ignore @distributed_trace def list_by_sql_pool( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.SqlPoolBlobAuditingPolicyListResult"]: + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SqlPoolBlobAuditingPolicy"]: """Lists auditing settings of 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SqlPoolBlobAuditingPolicyListResult or the result - of cls(response) + :return: An iterator like instance of either SqlPoolBlobAuditingPolicy or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.SqlPoolBlobAuditingPolicyListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.SqlPoolBlobAuditingPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolBlobAuditingPolicyListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolBlobAuditingPolicyListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_sql_pool_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore else: - - request = build_list_by_sql_pool_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -272,10 +364,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -285,8 +375,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_sql_pool.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/auditingSettings"} # type: ignore + list_by_sql_pool.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/auditingSettings"} # type: ignore 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 49ae18507549..9af99e9e25f1 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 @@ -8,40 +8,47 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._sql_pool_columns_operations import build_get_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SqlPoolColumnsOperations: - """SqlPoolColumnsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SqlPoolColumnsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`sql_pool_columns` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( @@ -53,69 +60,72 @@ async def get( table_name: str, column_name: str, **kwargs: Any - ) -> "_models.SqlPoolColumn": + ) -> _models.SqlPoolColumn: """Get Sql pool column. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param schema_name: The name of the schema. + :param schema_name: The name of the schema. Required. :type schema_name: str - :param table_name: The name of the table. + :param table_name: The name of the table. Required. :type table_name: str - :param column_name: The name of the column. + :param column_name: The name of the column. Required. :type column_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SqlPoolColumn, or the result of cls(response) + :return: SqlPoolColumn or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolColumn - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolColumn"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolColumn] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, schema_name=schema_name, table_name=table_name, column_name=column_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}"} # 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 248a77dfd8d0..0e6b1cd26ac6 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 @@ -8,40 +8,47 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar, Union -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._sql_pool_connection_policies_operations import build_get_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SqlPoolConnectionPoliciesOperations: - """SqlPoolConnectionPoliciesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SqlPoolConnectionPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`sql_pool_connection_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( @@ -51,53 +58,57 @@ async def get( sql_pool_name: str, connection_policy_name: Union[str, "_models.ConnectionPolicyName"], **kwargs: Any - ) -> "_models.SqlPoolConnectionPolicy": + ) -> _models.SqlPoolConnectionPolicy: """Get a Sql pool's connection policy, which is used with table auditing. Get a Sql pool's connection policy, which is used with table auditing. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param connection_policy_name: The name of the connection policy. + :param connection_policy_name: The name of the connection policy. "default" Required. :type connection_policy_name: str or ~azure.mgmt.synapse.models.ConnectionPolicyName - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SqlPoolConnectionPolicy, or the result of cls(response) + :return: SqlPoolConnectionPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolConnectionPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolConnectionPolicy"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolConnectionPolicy] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -105,12 +116,11 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/connectionPolicies/{connectionPolicyName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/connectionPolicies/{connectionPolicyName}"} # 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 0eb2ffe397ae..6544d83153e4 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 @@ -8,40 +8,47 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar, Union -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._sql_pool_data_warehouse_user_activities_operations import build_get_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SqlPoolDataWarehouseUserActivitiesOperations: - """SqlPoolDataWarehouseUserActivitiesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SqlPoolDataWarehouseUserActivitiesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`sql_pool_data_warehouse_user_activities` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( @@ -51,66 +58,70 @@ async def get( sql_pool_name: str, data_warehouse_user_activity_name: Union[str, "_models.DataWarehouseUserActivityName"], **kwargs: Any - ) -> "_models.DataWarehouseUserActivities": + ) -> _models.DataWarehouseUserActivities: """Get SQL pool user activities. Gets the user activities of a SQL pool which includes running and suspended queries. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param data_warehouse_user_activity_name: The activity name of the Sql pool. + :param data_warehouse_user_activity_name: The activity name of the Sql pool. "current" + Required. :type data_warehouse_user_activity_name: str or ~azure.mgmt.synapse.models.DataWarehouseUserActivityName - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataWarehouseUserActivities, or the result of cls(response) + :return: DataWarehouseUserActivities or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.DataWarehouseUserActivities - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataWarehouseUserActivities"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataWarehouseUserActivities] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataWarehouseUserActivities/{dataWarehouseUserActivityName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataWarehouseUserActivities/{dataWarehouseUserActivityName}"} # 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 1376674ab256..1bcf1f50bada 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 @@ -6,106 +6,110 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._sql_pool_geo_backup_policies_operations import build_create_or_update_request, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._sql_pool_geo_backup_policies_operations import ( + build_create_or_update_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SqlPoolGeoBackupPoliciesOperations: - """SqlPoolGeoBackupPoliciesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SqlPoolGeoBackupPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`sql_pool_geo_backup_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.GeoBackupPolicyListResult"]: + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> AsyncIterable["_models.GeoBackupPolicy"]: """List SQL pool geo backup policies. Get list of SQL pool geo backup policies. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GeoBackupPolicyListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.GeoBackupPolicyListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GeoBackupPolicyListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GeoBackupPolicyListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, 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'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -119,10 +123,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -133,72 +135,156 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/geoBackupPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/geoBackupPolicies"} # type: ignore - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, geo_backup_policy_name: Union[str, "_models.GeoBackupPolicyName"], - parameters: "_models.GeoBackupPolicy", + parameters: _models.GeoBackupPolicy, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.GeoBackupPolicy": + ) -> _models.GeoBackupPolicy: """Updates a SQL Pool geo backup policy. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param geo_backup_policy_name: The name of the geo backup policy. + :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. + Required. :type parameters: ~azure.mgmt.synapse.models.GeoBackupPolicy - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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) + :return: GeoBackupPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.GeoBackupPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + geo_backup_policy_name: Union[str, "_models.GeoBackupPolicyName"], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GeoBackupPolicy: + """Updates a SQL Pool geo backup policy. + + :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 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. + 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: GeoBackupPolicy or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.GeoBackupPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + geo_backup_policy_name: Union[str, "_models.GeoBackupPolicyName"], + parameters: Union[_models.GeoBackupPolicy, IO], + **kwargs: Any + ) -> _models.GeoBackupPolicy: + """Updates a SQL Pool geo backup policy. + + :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 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 + :return: GeoBackupPolicy or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.GeoBackupPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GeoBackupPolicy"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'GeoBackupPolicy') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GeoBackupPolicy] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GeoBackupPolicy") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, 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, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -207,18 +293,17 @@ async def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('GeoBackupPolicy', pipeline_response) + deserialized = self._deserialize("GeoBackupPolicy", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GeoBackupPolicy', pipeline_response) + deserialized = self._deserialize("GeoBackupPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/geoBackupPolicies/{geoBackupPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/geoBackupPolicies/{geoBackupPolicyName}"} # type: ignore @distributed_trace_async async def get( @@ -228,53 +313,57 @@ async def get( sql_pool_name: str, geo_backup_policy_name: Union[str, "_models.GeoBackupPolicyName"], **kwargs: Any - ) -> "_models.GeoBackupPolicy": + ) -> _models.GeoBackupPolicy: """Get a SQL pool geo backup policy. Get the specified SQL pool geo backup policy. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param geo_backup_policy_name: The name of the geo backup policy. + :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 api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GeoBackupPolicy, or the result of cls(response) + :return: GeoBackupPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.GeoBackupPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GeoBackupPolicy"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GeoBackupPolicy] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -282,12 +371,11 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/geoBackupPolicies/{geoBackupPolicyName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/geoBackupPolicies/{geoBackupPolicyName}"} # 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 eb012e235beb..8f8f8fa4c100 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 @@ -8,40 +8,47 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._sql_pool_maintenance_window_options_operations import build_get_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SqlPoolMaintenanceWindowOptionsOperations: - """SqlPoolMaintenanceWindowOptionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SqlPoolMaintenanceWindowOptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`sql_pool_maintenance_window_options` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( @@ -51,65 +58,68 @@ async def get( sql_pool_name: str, maintenance_window_options_name: str, **kwargs: Any - ) -> "_models.MaintenanceWindowOptions": + ) -> _models.MaintenanceWindowOptions: """SQL pool's available maintenance windows. Get list of SQL pool's available maintenance windows. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param maintenance_window_options_name: Maintenance window options name. + :param maintenance_window_options_name: Maintenance window options name. Required. :type maintenance_window_options_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MaintenanceWindowOptions, or the result of cls(response) + :return: MaintenanceWindowOptions or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.MaintenanceWindowOptions - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MaintenanceWindowOptions"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MaintenanceWindowOptions] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, - api_version=api_version, + subscription_id=self._config.subscription_id, maintenance_window_options_name=maintenance_window_options_name, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/maintenanceWindowOptions/current"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/maintenanceWindowOptions/current"} # 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 7b236fc9bfa6..9f316a9e7f1f 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 @@ -6,42 +6,49 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._sql_pool_maintenance_windows_operations import build_create_or_update_request, build_get_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SqlPoolMaintenanceWindowsOperations: - """SqlPoolMaintenanceWindowsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SqlPoolMaintenanceWindowsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`sql_pool_maintenance_windows` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( @@ -51,53 +58,57 @@ async def get( sql_pool_name: str, maintenance_window_name: str, **kwargs: Any - ) -> "_models.MaintenanceWindows": + ) -> _models.MaintenanceWindows: """Get a SQL pool's Maintenance Windows. Get a SQL pool's Maintenance Windows. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param maintenance_window_name: Maintenance window name. + :param maintenance_window_name: Maintenance window name. Required. :type maintenance_window_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MaintenanceWindows, or the result of cls(response) + :return: MaintenanceWindows or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.MaintenanceWindows - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MaintenanceWindows"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MaintenanceWindows] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, - api_version=api_version, + subscription_id=self._config.subscription_id, maintenance_window_name=maintenance_window_name, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -105,15 +116,88 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/maintenancewindows/current"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/maintenancewindows/current"} # type: ignore + + @overload + async def create_or_update( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + maintenance_window_name: str, + parameters: _models.MaintenanceWindows, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Creates or updates a Sql pool's maintenance windows settings. + + Creates or updates a Sql pool's maintenance windows settings. + + :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 maintenance_window_name: Maintenance window name. Required. + :type maintenance_window_name: str + :param parameters: The required parameters for creating or updating Maintenance Windows + settings. Required. + :type parameters: ~azure.mgmt.synapse.models.MaintenanceWindows + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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 + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + maintenance_window_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Creates or updates a Sql pool's maintenance windows settings. + Creates or updates a Sql pool's maintenance windows settings. + + :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 maintenance_window_name: Maintenance window name. Required. + :type maintenance_window_name: str + :param parameters: The required parameters for creating or updating Maintenance Windows + settings. 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 create_or_update( # pylint: disable=inconsistent-return-statements @@ -122,7 +206,7 @@ async def create_or_update( # pylint: disable=inconsistent-return-statements workspace_name: str, sql_pool_name: str, maintenance_window_name: str, - parameters: "_models.MaintenanceWindows", + parameters: Union[_models.MaintenanceWindows, IO], **kwargs: Any ) -> None: """Creates or updates a Sql pool's maintenance windows settings. @@ -130,54 +214,69 @@ async def create_or_update( # pylint: disable=inconsistent-return-statements Creates or updates a Sql pool's maintenance windows settings. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param maintenance_window_name: Maintenance window name. + :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. - :type parameters: ~azure.mgmt.synapse.models.MaintenanceWindows - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + 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 - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'MaintenanceWindows') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MaintenanceWindows") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, 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, content_type=content_type, - maintenance_window_name=maintenance_window_name, json=_json, - template_url=self.create_or_update.metadata['url'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -187,5 +286,4 @@ async def create_or_update( # pylint: disable=inconsistent-return-statements 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"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/maintenancewindows/current"} # 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 957ef6efd6b4..0c87d6edb9e6 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 @@ -6,112 +6,182 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._sql_pool_metadata_sync_configs_operations import build_create_request, build_get_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SqlPoolMetadataSyncConfigsOperations: - """SqlPoolMetadataSyncConfigsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SqlPoolMetadataSyncConfigsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`sql_pool_metadata_sync_configs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> Optional["_models.MetadataSyncConfig"]: + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> _models.MetadataSyncConfig: """Get SQL pool metadata sync config. Get the metadata sync configuration for 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword 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 or None - :raises: ~azure.core.exceptions.HttpResponseError + :return: MetadataSyncConfig or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.MetadataSyncConfig + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.MetadataSyncConfig"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetadataSyncConfig] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response - if response.status_code not in [200, 404]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('MetadataSyncConfig', pipeline_response) + deserialized = self._deserialize("MetadataSyncConfig", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/metadataSync/config"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/metadataSync/config"} # type: ignore + + @overload + async def create( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + metadata_sync_configuration: _models.MetadataSyncConfig, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MetadataSyncConfig: + """Set SQL pool metadata sync config. + + Set the metadata sync configuration for 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 metadata_sync_configuration: Metadata sync configuration. Required. + :type metadata_sync_configuration: ~azure.mgmt.synapse.models.MetadataSyncConfig + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: + """ + + @overload + async def create( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + metadata_sync_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MetadataSyncConfig: + """Set SQL pool metadata sync config. + Set the metadata sync configuration for 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 metadata_sync_configuration: Metadata sync configuration. Required. + :type metadata_sync_configuration: 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: MetadataSyncConfig or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.MetadataSyncConfig + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create( @@ -119,73 +189,86 @@ async def create( resource_group_name: str, workspace_name: str, sql_pool_name: str, - metadata_sync_configuration: "_models.MetadataSyncConfig", + metadata_sync_configuration: Union[_models.MetadataSyncConfig, IO], **kwargs: Any - ) -> Optional["_models.MetadataSyncConfig"]: + ) -> _models.MetadataSyncConfig: """Set SQL pool metadata sync config. Set the metadata sync configuration for 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param metadata_sync_configuration: Metadata sync configuration. - :type metadata_sync_configuration: ~azure.mgmt.synapse.models.MetadataSyncConfig - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 - :return: MetadataSyncConfig, or the result of cls(response) - :rtype: ~azure.mgmt.synapse.models.MetadataSyncConfig or None - :raises: ~azure.core.exceptions.HttpResponseError + :return: MetadataSyncConfig or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.MetadataSyncConfig + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.MetadataSyncConfig"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetadataSyncConfig] - _json = self._serialize.body(metadata_sync_configuration, 'MetadataSyncConfig') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(metadata_sync_configuration, (IO, bytes)): + _content = metadata_sync_configuration + else: + _json = self._serialize.body(metadata_sync_configuration, "MetadataSyncConfig") request = build_create_request( - subscription_id=self._config.subscription_id, 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, - template_url=self.create.metadata['url'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response - if response.status_code not in [200, 404]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('MetadataSyncConfig', pipeline_response) + deserialized = self._deserialize("MetadataSyncConfig", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/metadataSync/config"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/metadataSync/config"} # 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 b9c3653f1d93..be494b45e2c3 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 @@ -6,98 +6,110 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._sql_pool_operation_results_operations import build_get_location_header_result_request -T = TypeVar('T') + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SqlPoolOperationResultsOperations: - """SqlPoolOperationResultsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SqlPoolOperationResultsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`sql_pool_operation_results` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get_location_header_result( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - operation_id: str, - **kwargs: Any - ) -> Any: + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, operation_id: str, **kwargs: Any + ) -> JSON: """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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param operation_id: Operation ID. + :param operation_id: Operation ID. Required. :type operation_id: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: any, or the result of cls(response) - :rtype: any - :raises: ~azure.core.exceptions.HttpResponseError + :return: JSON or the result of cls(response) + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Any] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[JSON] - request = build_get_location_header_result_request( - subscription_id=self._config.subscription_id, 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.metadata['url'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -106,15 +118,14 @@ async def get_location_header_result( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('object', pipeline_response) + deserialized = self._deserialize("object", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('object', pipeline_response) + deserialized = self._deserialize("object", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_location_header_result.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/operationResults/{operationId}"} # type: ignore - + get_location_header_result.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/operationResults/{operationId}"} # type: ignore 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 79bc9b7953b7..426f84a54f2a 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 @@ -9,102 +9,102 @@ from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.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 -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SqlPoolOperationsOperations: - """SqlPoolOperationsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SqlPoolOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`sql_pool_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.SqlPoolBlobAuditingPolicySqlPoolOperationListResult"]: + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SqlPoolOperation"]: """Gets a list of operations performed on the SQL pool. Gets a list of operations performed on the 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either - SqlPoolBlobAuditingPolicySqlPoolOperationListResult or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.SqlPoolBlobAuditingPolicySqlPoolOperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolBlobAuditingPolicySqlPoolOperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolBlobAuditingPolicySqlPoolOperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, 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'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -118,10 +118,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,8 +129,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/operations"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/operations"} # type: ignore 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 f3a623214384..5c183fd99768 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 @@ -6,99 +6,183 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._sql_pool_recommended_sensitivity_labels_operations import build_update_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SqlPoolRecommendedSensitivityLabelsOperations: - """SqlPoolRecommendedSensitivityLabelsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SqlPoolRecommendedSensitivityLabelsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`sql_pool_recommended_sensitivity_labels` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def update( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: "_models.RecommendedSensitivityLabelUpdateList", + parameters: _models.RecommendedSensitivityLabelUpdateList, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Update recommended sensitivity labels states of a given SQL Pool using an operations batch. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param parameters: + :param parameters: Required. :type parameters: ~azure.mgmt.synapse.models.RecommendedSensitivityLabelUpdateList - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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 + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update recommended sensitivity labels states of a given SQL Pool using an operations batch. + + :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: 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + parameters: Union[_models.RecommendedSensitivityLabelUpdateList, IO], + **kwargs: Any + ) -> None: + """Update recommended sensitivity labels states of a given SQL Pool using an operations batch. + + :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: 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 + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'RecommendedSensitivityLabelUpdateList') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RecommendedSensitivityLabelUpdateList") request = build_update_request( - subscription_id=self._config.subscription_id, 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, - template_url=self.update.metadata['url'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -108,5 +192,4 @@ async def update( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/recommendedSensitivityLabels"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/recommendedSensitivityLabels"} # 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 151e177088d4..9d5ebba37839 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 @@ -9,103 +9,103 @@ from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._sql_pool_replication_links_operations import build_get_by_name_request, build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SqlPoolReplicationLinksOperations: - """SqlPoolReplicationLinksOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SqlPoolReplicationLinksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`sql_pool_replication_links` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ReplicationLinkListResult"]: + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ReplicationLink"]: """Get SQL pool replication links. Lists a Sql pool's replication links. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReplicationLinkListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.ReplicationLinkListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ReplicationLinkListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReplicationLinkListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, 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'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -119,10 +119,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -133,67 +131,64 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/replicationLinks"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/replicationLinks"} # type: ignore @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 - ) -> "_models.ReplicationLink": + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, link_id: str, **kwargs: Any + ) -> _models.ReplicationLink: """Get SQL pool replication link by name. Get SQL pool replication link by name. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param link_id: The ID of the replication link. + :param link_id: The ID of the replication link. Required. :type link_id: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ReplicationLink, or the result of cls(response) + :return: ReplicationLink or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ReplicationLink - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReplicationLink"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ReplicationLink] - request = build_get_by_name_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -201,12 +196,11 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_name.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/replicationLinks/{linkId}"} # type: ignore - + get_by_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/replicationLinks/{linkId}"} # 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 65dd140e5806..00313939ff34 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 @@ -6,108 +6,113 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._sql_pool_restore_points_operations import build_create_request_initial, build_delete_request, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._sql_pool_restore_points_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SqlPoolRestorePointsOperations: - """SqlPoolRestorePointsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SqlPoolRestorePointsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`sql_pool_restore_points` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.RestorePointListResult"]: + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> AsyncIterable["_models.RestorePoint"]: """Get SQL pool backup. Get SQL pool backup information. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RestorePointListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.RestorePointListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RestorePointListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, 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'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -121,10 +126,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -135,49 +138,61 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints"} # type: ignore async def _create_initial( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: "_models.CreateSqlPoolRestorePointDefinition", + parameters: Union[_models.CreateSqlPoolRestorePointDefinition, IO], **kwargs: Any - ) -> Optional["_models.RestorePoint"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RestorePoint"]] + ) -> Optional[_models.RestorePoint]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'CreateSqlPoolRestorePointDefinition') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.RestorePoint]] - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CreateSqlPoolRestorePointDefinition") + + request = build_create_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, - template_url=self._create_initial.metadata['url'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -186,18 +201,95 @@ async def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('RestorePoint', pipeline_response) + deserialized = self._deserialize("RestorePoint", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('RestorePoint', pipeline_response) + deserialized = self._deserialize("RestorePoint", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints"} # type: ignore + @overload + async def begin_create( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + parameters: _models.CreateSqlPoolRestorePointDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.RestorePoint]: + """Creates a restore point for a data warehouse. + + :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 definition for creating the restore point of this Sql pool. Required. + :type parameters: ~azure.mgmt.synapse.models.CreateSqlPoolRestorePointDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.RestorePoint]: + """Creates a restore point for a data warehouse. + + :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 definition for creating the restore point of 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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -205,22 +297,24 @@ async def begin_create( resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: "_models.CreateSqlPoolRestorePointDefinition", + parameters: Union[_models.CreateSqlPoolRestorePointDefinition, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.RestorePoint"]: + ) -> AsyncLROPoller[_models.RestorePoint]: """Creates a restore point for a data warehouse. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :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. - :type parameters: ~azure.mgmt.synapse.models.CreateSqlPoolRestorePointDefinition - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 @@ -232,174 +326,176 @@ async def begin_create( :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] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePoint"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.RestorePoint] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('RestorePoint', pipeline_response) + deserialized = self._deserialize("RestorePoint", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - restore_point_name: str, - **kwargs: Any - ) -> "_models.RestorePoint": + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, restore_point_name: str, **kwargs: Any + ) -> _models.RestorePoint: """Gets a restore point. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param restore_point_name: The name of the restore point. + :param restore_point_name: The name of the restore point. Required. :type restore_point_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RestorePoint, or the result of cls(response) + :return: RestorePoint or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.RestorePoint - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePoint"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RestorePoint] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints/{restorePointName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints/{restorePointName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - restore_point_name: str, - **kwargs: Any + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, restore_point_name: str, **kwargs: Any ) -> None: """Deletes a restore point. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param restore_point_name: The name of the restore point. + :param restore_point_name: The name of the restore point. Required. :type restore_point_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -409,5 +505,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints/{restorePointName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints/{restorePointName}"} # 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 b06151dcaa28..058c2c392446 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 @@ -9,41 +9,48 @@ from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._sql_pool_schemas_operations import build_get_request, build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SqlPoolSchemasOperations: - """SqlPoolSchemasOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SqlPoolSchemasOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`sql_pool_schemas` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( @@ -53,65 +60,61 @@ def list( sql_pool_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.SqlPoolSchemaListResult"]: + ) -> AsyncIterable["_models.SqlPoolSchema"]: """Gets schemas of a given SQL pool. Gets schemas of a given 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str :param filter: An OData filter expression that filters elements in the collection. Default value is None. :type filter: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SqlPoolSchemaListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.SqlPoolSchemaListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolSchemaListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolSchemaListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - api_version=api_version, - filter=filter, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -125,10 +128,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -138,77 +139,73 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - schema_name: str, - **kwargs: Any - ) -> "_models.SqlPoolSchema": + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, schema_name: str, **kwargs: Any + ) -> _models.SqlPoolSchema: """Get Sql Pool schema. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param schema_name: The name of the schema. + :param schema_name: The name of the schema. Required. :type schema_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SqlPoolSchema, or the result of cls(response) + :return: SqlPoolSchema or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolSchema - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolSchema"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolSchema] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}"} # 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 f1f3490a6a00..b55e374aff44 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 @@ -6,106 +6,112 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._sql_pool_security_alert_policies_operations import build_create_or_update_request, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._sql_pool_security_alert_policies_operations import ( + build_create_or_update_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SqlPoolSecurityAlertPoliciesOperations: - """SqlPoolSecurityAlertPoliciesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SqlPoolSecurityAlertPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`sql_pool_security_alert_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ListSqlPoolSecurityAlertPolicies"]: + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SqlPoolSecurityAlertPolicy"]: """List Sql pool's security alert policies. Get a list of Sql pool's security alert policies. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListSqlPoolSecurityAlertPolicies or the result of + :return: An iterator like instance of either SqlPoolSecurityAlertPolicy or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.ListSqlPoolSecurityAlertPolicies] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.SqlPoolSecurityAlertPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListSqlPoolSecurityAlertPolicies] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListSqlPoolSecurityAlertPolicies"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, 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'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -119,10 +125,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -132,11 +136,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/securityAlertPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/securityAlertPolicies"} # type: ignore @distributed_trace_async async def get( @@ -146,68 +148,143 @@ async def get( sql_pool_name: str, security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyName"], **kwargs: Any - ) -> "_models.SqlPoolSecurityAlertPolicy": + ) -> _models.SqlPoolSecurityAlertPolicy: """Get a Sql pool's security alert policy. Get a Sql pool's security alert policy. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param security_alert_policy_name: The name of the security alert policy. + :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 api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SqlPoolSecurityAlertPolicy, or the result of cls(response) + :return: SqlPoolSecurityAlertPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolSecurityAlertPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolSecurityAlertPolicy"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolSecurityAlertPolicy] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/securityAlertPolicies/{securityAlertPolicyName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/securityAlertPolicies/{securityAlertPolicyName}"} # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyName"], + parameters: _models.SqlPoolSecurityAlertPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SqlPoolSecurityAlertPolicy: + """Create or update a Sql pool's security alert policy. + + Create or update a Sql pool's security alert policy. + + :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 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: ~azure.mgmt.synapse.models.SqlPoolSecurityAlertPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyName"], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SqlPoolSecurityAlertPolicy: + """Create or update a Sql pool's security alert policy. + Create or update a Sql pool's security alert policy. + + :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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: + """ @distributed_trace_async async def create_or_update( @@ -216,61 +293,77 @@ async def create_or_update( workspace_name: str, sql_pool_name: str, security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyName"], - parameters: "_models.SqlPoolSecurityAlertPolicy", + parameters: Union[_models.SqlPoolSecurityAlertPolicy, IO], **kwargs: Any - ) -> "_models.SqlPoolSecurityAlertPolicy": + ) -> _models.SqlPoolSecurityAlertPolicy: """Create or update a Sql pool's security alert policy. Create or update a Sql pool's security alert policy. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param security_alert_policy_name: The name of the security alert policy. + :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. - :type parameters: ~azure.mgmt.synapse.models.SqlPoolSecurityAlertPolicy - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 - :return: SqlPoolSecurityAlertPolicy, or the result of cls(response) + :return: SqlPoolSecurityAlertPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolSecurityAlertPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolSecurityAlertPolicy"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolSecurityAlertPolicy] - _json = self._serialize.body(parameters, 'SqlPoolSecurityAlertPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SqlPoolSecurityAlertPolicy") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, 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, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -278,15 +371,14 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('SqlPoolSecurityAlertPolicy', pipeline_response) + deserialized = self._deserialize("SqlPoolSecurityAlertPolicy", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SqlPoolSecurityAlertPolicy', pipeline_response) + deserialized = self._deserialize("SqlPoolSecurityAlertPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/securityAlertPolicies/{securityAlertPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/securityAlertPolicies/{securityAlertPolicyName}"} # type: ignore 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 59e046b005e3..c30367a6954e 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 @@ -6,44 +6,60 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._sql_pool_sensitivity_labels_operations import build_create_or_update_request, build_delete_request, build_disable_recommendation_request, build_enable_recommendation_request, build_get_request, build_list_current_request, build_list_recommended_request, build_update_request -T = TypeVar('T') +from ...operations._sql_pool_sensitivity_labels_operations import ( + build_create_or_update_request, + build_delete_request, + build_disable_recommendation_request, + build_enable_recommendation_request, + build_get_request, + build_list_current_request, + build_list_recommended_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SqlPoolSensitivityLabelsOperations: - """SqlPoolSensitivityLabelsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SqlPoolSensitivityLabelsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`sql_pool_sensitivity_labels` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_current( @@ -53,65 +69,61 @@ def list_current( sql_pool_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.SensitivityLabelListResult"]: + ) -> AsyncIterable["_models.SensitivityLabel"]: """Gets SQL pool sensitivity labels. Gets SQL pool sensitivity labels. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str :param filter: An OData filter expression that filters elements in the collection. Default value is None. :type filter: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SensitivityLabelListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.SensitivityLabelListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SensitivityLabelListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SensitivityLabelListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_current_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_current.metadata['url'], + 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) # type: ignore else: - - request = build_list_current_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - api_version=api_version, - filter=filter, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -125,10 +137,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -139,68 +149,143 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_current.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/currentSensitivityLabels"} # type: ignore + list_current.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/currentSensitivityLabels"} # type: ignore - @distributed_trace_async + @overload async def update( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: "_models.SensitivityLabelUpdateList", + parameters: _models.SensitivityLabelUpdateList, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Update sensitivity labels of a given SQL Pool using an operations batch. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param parameters: + :param parameters: Required. :type parameters: ~azure.mgmt.synapse.models.SensitivityLabelUpdateList - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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 + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update sensitivity labels of a given SQL Pool using an operations batch. + + :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: 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 update( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + parameters: Union[_models.SensitivityLabelUpdateList, IO], + **kwargs: Any + ) -> None: + """Update sensitivity labels of a given SQL Pool using an operations batch. + + :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: 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 - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'SensitivityLabelUpdateList') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SensitivityLabelUpdateList") request = build_update_request( - subscription_id=self._config.subscription_id, 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, - template_url=self.update.metadata['url'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -210,8 +295,7 @@ async def update( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/currentSensitivityLabels"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/currentSensitivityLabels"} # type: ignore @distributed_trace def list_recommended( @@ -223,16 +307,17 @@ def list_recommended( skip_token: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.SensitivityLabelListResult"]: + ) -> AsyncIterable["_models.SensitivityLabel"]: """Gets sensitivity labels of a given SQL pool. Gets sensitivity labels of a given 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str :param include_disabled_recommendations: Specifies whether to include disabled recommendations or not. Default value is None. @@ -243,55 +328,48 @@ def list_recommended( :param filter: An OData filter expression that filters elements in the collection. Default value is None. :type filter: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SensitivityLabelListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.SensitivityLabelListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SensitivityLabelListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SensitivityLabelListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_recommended_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, - api_version=api_version, + subscription_id=self._config.subscription_id, include_disabled_recommendations=include_disabled_recommendations, skip_token=skip_token, filter=filter, - template_url=self.list_recommended.metadata['url'], + 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) # type: ignore else: - - request = build_list_recommended_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - api_version=api_version, - include_disabled_recommendations=include_disabled_recommendations, - skip_token=skip_token, - filter=filter, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -305,10 +383,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -318,13 +394,11 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_recommended.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/recommendedSensitivityLabels"} # type: ignore + list_recommended.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/recommendedSensitivityLabels"} # type: ignore - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, @@ -333,70 +407,172 @@ async def create_or_update( schema_name: str, table_name: str, column_name: str, - parameters: "_models.SensitivityLabel", + parameters: _models.SensitivityLabel, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.SensitivityLabel": + ) -> _models.SensitivityLabel: """Creates or updates the sensitivity label of a given column in 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param schema_name: The name of the schema. + :param schema_name: The name of the schema. Required. :type schema_name: str - :param table_name: The name of the table. + :param table_name: The name of the table. Required. :type table_name: str - :param column_name: The name of the column. + :param column_name: The name of the column. Required. :type column_name: str - :param parameters: The column sensitivity label resource. + :param parameters: The column sensitivity label resource. Required. :type parameters: ~azure.mgmt.synapse.models.SensitivityLabel - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword 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) + :return: SensitivityLabel or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SensitivityLabel - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + schema_name: str, + table_name: str, + column_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SensitivityLabel: + """Creates or updates the sensitivity label of a given column in 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 schema_name: The name of the schema. Required. + :type schema_name: str + :param table_name: The name of the table. Required. + :type table_name: str + :param column_name: The name of the column. Required. + :type column_name: str + :param parameters: The column sensitivity label resource. 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 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: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + schema_name: str, + table_name: str, + column_name: str, + parameters: Union[_models.SensitivityLabel, IO], + **kwargs: Any + ) -> _models.SensitivityLabel: + """Creates or updates the sensitivity label of a given column in 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 schema_name: The name of the schema. Required. + :type schema_name: str + :param table_name: The name of the table. Required. + :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 + :return: SensitivityLabel or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.SensitivityLabel + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SensitivityLabel"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - sensitivity_label_source = kwargs.pop('sensitivity_label_source', "current") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'SensitivityLabel') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + sensitivity_label_source = kwargs.pop("sensitivity_label_source", "current") # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SensitivityLabel] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SensitivityLabel") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, schema_name=schema_name, table_name=table_name, column_name=column_name, + subscription_id=self._config.subscription_id, api_version=api_version, sensitivity_label_source=sensitivity_label_source, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -404,18 +580,17 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('SensitivityLabel', pipeline_response) + deserialized = self._deserialize("SensitivityLabel", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SensitivityLabel', pipeline_response) + deserialized = self._deserialize("SensitivityLabel", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}"} # 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}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -431,58 +606,62 @@ async def delete( # pylint: disable=inconsistent-return-statements """Deletes the sensitivity label of a given column in 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param schema_name: The name of the schema. + :param schema_name: The name of the schema. Required. :type schema_name: str - :param table_name: The name of the table. + :param table_name: The name of the table. Required. :type table_name: str - :param column_name: The name of the column. + :param column_name: The name of the column. Required. :type column_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - sensitivity_label_source = kwargs.pop('sensitivity_label_source', "current") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + sensitivity_label_source = kwargs.pop("sensitivity_label_source", "current") # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, schema_name=schema_name, table_name=table_name, column_name=column_name, + subscription_id=self._config.subscription_id, api_version=api_version, sensitivity_label_source=sensitivity_label_source, - template_url=self.delete.metadata['url'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -492,8 +671,7 @@ async def delete( # pylint: disable=inconsistent-return-statements 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}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}"} # type: ignore @distributed_trace_async async def get( @@ -506,42 +684,45 @@ async def get( column_name: str, sensitivity_label_source: Union[str, "_models.SensitivityLabelSource"], **kwargs: Any - ) -> "_models.SensitivityLabel": + ) -> _models.SensitivityLabel: """Gets the sensitivity label of a given column. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param schema_name: The name of the schema. + :param schema_name: The name of the schema. Required. :type schema_name: str - :param table_name: The name of the table. + :param table_name: The name of the table. Required. :type table_name: str - :param column_name: The name of the column. + :param column_name: The name of the column. Required. :type column_name: str - :param sensitivity_label_source: The source of the sensitivity label. + :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 api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SensitivityLabel, or the result of cls(response) + :return: SensitivityLabel or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SensitivityLabel - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SensitivityLabel"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SensitivityLabel] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -549,32 +730,33 @@ async def get( table_name=table_name, column_name=column_name, sensitivity_label_source=sensitivity_label_source, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}"} # type: ignore @distributed_trace_async async def enable_recommendation( # pylint: disable=inconsistent-return-statements @@ -591,58 +773,62 @@ async def enable_recommendation( # pylint: disable=inconsistent-return-statemen on all columns). :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param schema_name: The name of the schema. + :param schema_name: The name of the schema. Required. :type schema_name: str - :param table_name: The name of the table. + :param table_name: The name of the table. Required. :type table_name: str - :param column_name: The name of the column. + :param column_name: The name of the column. Required. :type column_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - sensitivity_label_source = kwargs.pop('sensitivity_label_source', "recommended") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + sensitivity_label_source = kwargs.pop("sensitivity_label_source", "recommended") # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_enable_recommendation_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, schema_name=schema_name, table_name=table_name, column_name=column_name, + subscription_id=self._config.subscription_id, api_version=api_version, sensitivity_label_source=sensitivity_label_source, - template_url=self.enable_recommendation.metadata['url'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -652,8 +838,7 @@ async def enable_recommendation( # pylint: disable=inconsistent-return-statemen 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"} # type: ignore - + enable_recommendation.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/enable"} # type: ignore @distributed_trace_async async def disable_recommendation( # pylint: disable=inconsistent-return-statements @@ -669,58 +854,62 @@ async def disable_recommendation( # pylint: disable=inconsistent-return-stateme """Disables sensitivity recommendations on a given column. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param schema_name: The name of the schema. + :param schema_name: The name of the schema. Required. :type schema_name: str - :param table_name: The name of the table. + :param table_name: The name of the table. Required. :type table_name: str - :param column_name: The name of the column. + :param column_name: The name of the column. Required. :type column_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - sensitivity_label_source = kwargs.pop('sensitivity_label_source', "recommended") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + sensitivity_label_source = kwargs.pop("sensitivity_label_source", "recommended") # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_disable_recommendation_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, schema_name=schema_name, table_name=table_name, column_name=column_name, + subscription_id=self._config.subscription_id, api_version=api_version, sensitivity_label_source=sensitivity_label_source, - template_url=self.disable_recommendation.metadata['url'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -730,5 +919,4 @@ async def disable_recommendation( # pylint: disable=inconsistent-return-stateme 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"} # type: ignore - + disable_recommendation.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/disable"} # 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 e759085b5093..57a810bfa150 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 @@ -9,40 +9,47 @@ from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.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 -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SqlPoolTableColumnsOperations: - """SqlPoolTableColumnsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SqlPoolTableColumnsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`sql_pool_table_columns` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_table_name( @@ -54,73 +61,67 @@ def list_by_table_name( table_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.SqlPoolColumnListResult"]: + ) -> AsyncIterable["_models.SqlPoolColumn"]: """Gets columns in a given table in a SQL pool. Gets columns in a given table in 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param schema_name: The name of the schema. + :param schema_name: The name of the schema. Required. :type schema_name: str - :param table_name: The name of the table. + :param table_name: The name of the table. Required. :type table_name: str :param filter: An OData filter expression that filters elements in the collection. Default value is None. :type filter: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SqlPoolColumnListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.SqlPoolColumnListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolColumnListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolColumnListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_table_name_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, schema_name=schema_name, table_name=table_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_by_table_name.metadata['url'], + 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) # type: ignore else: - - request = build_list_by_table_name_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - schema_name=schema_name, - table_name=table_name, - api_version=api_version, - filter=filter, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -134,10 +135,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -147,8 +146,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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"} # type: ignore + list_by_table_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns"} # type: ignore 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 13723e5c04f1..b31f17248f97 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 @@ -9,41 +9,48 @@ from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._sql_pool_tables_operations import build_get_request, build_list_by_schema_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SqlPoolTablesOperations: - """SqlPoolTablesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SqlPoolTablesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`sql_pool_tables` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_schema( @@ -54,69 +61,64 @@ def list_by_schema( schema_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.SqlPoolTableListResult"]: + ) -> AsyncIterable["_models.SqlPoolTable"]: """Gets tables of a given schema in a SQL pool. Gets tables of a given schema in 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param schema_name: The name of the schema. + :param schema_name: The name of the schema. Required. :type schema_name: str :param filter: An OData filter expression that filters elements in the collection. Default value is None. :type filter: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SqlPoolTableListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.SqlPoolTableListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolTableListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolTableListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_schema_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, schema_name=schema_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_by_schema.metadata['url'], + 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) # type: ignore else: - - request = build_list_by_schema_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - schema_name=schema_name, - api_version=api_version, - filter=filter, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -130,10 +132,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -143,11 +143,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - 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"} # type: ignore + list_by_schema.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables"} # type: ignore @distributed_trace_async async def get( @@ -158,66 +156,69 @@ async def get( schema_name: str, table_name: str, **kwargs: Any - ) -> "_models.SqlPoolTable": + ) -> _models.SqlPoolTable: """Get Sql pool table. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param schema_name: The name of the schema. + :param schema_name: The name of the schema. Required. :type schema_name: str - :param table_name: The name of the table. + :param table_name: The name of the table. Required. :type table_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SqlPoolTable, or the result of cls(response) + :return: SqlPoolTable or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolTable - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolTable"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolTable] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, schema_name=schema_name, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}"} # 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 4c14ccdbac67..a9dcc74a1fa8 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 @@ -6,44 +6,55 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._sql_pool_transparent_data_encryptions_operations import build_create_or_update_request, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._sql_pool_transparent_data_encryptions_operations import ( + build_create_or_update_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SqlPoolTransparentDataEncryptionsOperations: - """SqlPoolTransparentDataEncryptionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SqlPoolTransparentDataEncryptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`sql_pool_transparent_data_encryptions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( @@ -53,55 +64,59 @@ async def get( sql_pool_name: str, transparent_data_encryption_name: Union[str, "_models.TransparentDataEncryptionName"], **kwargs: Any - ) -> "_models.TransparentDataEncryption": + ) -> _models.TransparentDataEncryption: """Get a SQL pool's transparent data encryption configuration. Get a SQL pool's transparent data encryption configuration. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str :param transparent_data_encryption_name: The name of the transparent data encryption - configuration. + configuration. "current" Required. :type transparent_data_encryption_name: str or ~azure.mgmt.synapse.models.TransparentDataEncryptionName - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TransparentDataEncryption, or the result of cls(response) + :return: TransparentDataEncryption or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.TransparentDataEncryption - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TransparentDataEncryption"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TransparentDataEncryption] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -109,15 +124,92 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TransparentDataEncryption', pipeline_response) + deserialized = self._deserialize("TransparentDataEncryption", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/transparentDataEncryption/{transparentDataEncryptionName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/transparentDataEncryption/{transparentDataEncryptionName}"} # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + transparent_data_encryption_name: Union[str, "_models.TransparentDataEncryptionName"], + parameters: _models.TransparentDataEncryption, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TransparentDataEncryption: + """Creates or updates a Sql pool's transparent data encryption configuration. + + Creates or updates a Sql pool's transparent data encryption configuration. + + :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 transparent_data_encryption_name: The name of the transparent data encryption + configuration. "current" Required. + :type transparent_data_encryption_name: str or + ~azure.mgmt.synapse.models.TransparentDataEncryptionName + :param parameters: The required parameters for creating or updating transparent data + encryption. Required. + :type parameters: ~azure.mgmt.synapse.models.TransparentDataEncryption + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: + """ + @overload + async def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + transparent_data_encryption_name: Union[str, "_models.TransparentDataEncryptionName"], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TransparentDataEncryption: + """Creates or updates a Sql pool's transparent data encryption configuration. + + Creates or updates a Sql pool's transparent data encryption configuration. + + :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 transparent_data_encryption_name: The name of the transparent data encryption + configuration. "current" Required. + :type transparent_data_encryption_name: str or + ~azure.mgmt.synapse.models.TransparentDataEncryptionName + :param parameters: The required parameters for creating or updating transparent data + encryption. 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: TransparentDataEncryption or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.TransparentDataEncryption + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update( @@ -126,146 +218,155 @@ async def create_or_update( workspace_name: str, sql_pool_name: str, transparent_data_encryption_name: Union[str, "_models.TransparentDataEncryptionName"], - parameters: "_models.TransparentDataEncryption", + parameters: Union[_models.TransparentDataEncryption, IO], **kwargs: Any - ) -> "_models.TransparentDataEncryption": + ) -> _models.TransparentDataEncryption: """Creates or updates a Sql pool's transparent data encryption configuration. Creates or updates a Sql pool's transparent data encryption configuration. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str :param transparent_data_encryption_name: The name of the transparent data encryption - configuration. + configuration. "current" Required. :type transparent_data_encryption_name: str or ~azure.mgmt.synapse.models.TransparentDataEncryptionName :param parameters: The required parameters for creating or updating transparent data - encryption. - :type parameters: ~azure.mgmt.synapse.models.TransparentDataEncryption - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + 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 - :return: TransparentDataEncryption, or the result of cls(response) + :return: TransparentDataEncryption or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.TransparentDataEncryption - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TransparentDataEncryption"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'TransparentDataEncryption') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TransparentDataEncryption] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TransparentDataEncryption") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, 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, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TransparentDataEncryption', pipeline_response) + deserialized = self._deserialize("TransparentDataEncryption", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TransparentDataEncryption', pipeline_response) + deserialized = self._deserialize("TransparentDataEncryption", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/transparentDataEncryption/{transparentDataEncryptionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/transparentDataEncryption/{transparentDataEncryptionName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.TransparentDataEncryptionListResult"]: + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> AsyncIterable["_models.TransparentDataEncryption"]: """SQL pool's transparent data encryption configurations. Get list of SQL pool's transparent data encryption configurations. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TransparentDataEncryptionListResult or the result - of cls(response) + :return: An iterator like instance of either TransparentDataEncryption or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.TransparentDataEncryptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.TransparentDataEncryption] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TransparentDataEncryptionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TransparentDataEncryptionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, 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'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -279,10 +380,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -292,8 +391,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/transparentDataEncryption"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/transparentDataEncryption"} # type: ignore 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 daafa39a9da0..42b4bd7711ba 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 @@ -9,102 +9,102 @@ from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.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 -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SqlPoolUsagesOperations: - """SqlPoolUsagesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SqlPoolUsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`sql_pool_usages` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.SqlPoolUsageListResult"]: + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SqlPoolUsage"]: """Gets SQL pool usages. Gets SQL pool usages. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SqlPoolUsageListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.SqlPoolUsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolUsageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolUsageListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, 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'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -118,10 +118,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -132,8 +130,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/usages"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/usages"} # type: ignore 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 85feeb8759c9..bec09fef6bf0 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 @@ -6,44 +6,55 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._sql_pool_vulnerability_assessment_rule_baselines_operations import build_create_or_update_request, build_delete_request, build_get_request -T = TypeVar('T') +from ...operations._sql_pool_vulnerability_assessment_rule_baselines_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SqlPoolVulnerabilityAssessmentRuleBaselinesOperations: - """SqlPoolVulnerabilityAssessmentRuleBaselinesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SqlPoolVulnerabilityAssessmentRuleBaselinesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`sql_pool_vulnerability_assessment_rule_baselines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, @@ -52,83 +63,190 @@ async def create_or_update( vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], rule_id: str, baseline_name: Union[str, "_models.VulnerabilityAssessmentPolicyBaselineName"], - parameters: "_models.SqlPoolVulnerabilityAssessmentRuleBaseline", + parameters: _models.SqlPoolVulnerabilityAssessmentRuleBaseline, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.SqlPoolVulnerabilityAssessmentRuleBaseline": + ) -> _models.SqlPoolVulnerabilityAssessmentRuleBaseline: """Creates or updates a Sql pool's vulnerability assessment rule baseline. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param vulnerability_assessment_name: The name of the vulnerability assessment. + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :param rule_id: The vulnerability assessment rule ID. + :param rule_id: The vulnerability assessment rule ID. Required. :type rule_id: str :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a - baseline on a Sql pool level rule and master for workspace level rule). + baseline on a Sql pool level rule and master for workspace level rule). Known values are: + "master" and "default". Required. :type baseline_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentPolicyBaselineName - :param parameters: The requested rule baseline resource. + :param parameters: The requested rule baseline resource. Required. :type parameters: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessmentRuleBaseline - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + rule_id: str, + baseline_name: Union[str, "_models.VulnerabilityAssessmentPolicyBaselineName"], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SqlPoolVulnerabilityAssessmentRuleBaseline: + """Creates or updates a Sql pool's vulnerability assessment rule baseline. + + :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 vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. + :type vulnerability_assessment_name: str or + ~azure.mgmt.synapse.models.VulnerabilityAssessmentName + :param rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a + baseline on a Sql pool level rule and master for workspace level rule). Known values are: + "master" and "default". Required. + :type baseline_name: str or + ~azure.mgmt.synapse.models.VulnerabilityAssessmentPolicyBaselineName + :param parameters: The requested rule baseline resource. 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: SqlPoolVulnerabilityAssessmentRuleBaseline or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + rule_id: str, + baseline_name: Union[str, "_models.VulnerabilityAssessmentPolicyBaselineName"], + parameters: Union[_models.SqlPoolVulnerabilityAssessmentRuleBaseline, IO], + **kwargs: Any + ) -> _models.SqlPoolVulnerabilityAssessmentRuleBaseline: + """Creates or updates a Sql pool's vulnerability assessment rule baseline. + + :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 vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. + :type vulnerability_assessment_name: str or + ~azure.mgmt.synapse.models.VulnerabilityAssessmentName + :param rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a + baseline on a Sql pool level rule and master for workspace level rule). Known values are: + "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 - :return: SqlPoolVulnerabilityAssessmentRuleBaseline, or the result of cls(response) + :return: SqlPoolVulnerabilityAssessmentRuleBaseline or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessmentRuleBaseline - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolVulnerabilityAssessmentRuleBaseline"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'SqlPoolVulnerabilityAssessmentRuleBaseline') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolVulnerabilityAssessmentRuleBaseline] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SqlPoolVulnerabilityAssessmentRuleBaseline") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, vulnerability_assessment_name=vulnerability_assessment_name, rule_id=rule_id, baseline_name=baseline_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -144,56 +262,62 @@ async def delete( # pylint: disable=inconsistent-return-statements """Removes the database's vulnerability assessment rule baseline. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param vulnerability_assessment_name: The name of the vulnerability assessment. + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :param rule_id: The vulnerability assessment rule ID. + :param rule_id: The vulnerability assessment rule ID. Required. :type rule_id: str :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a - baseline on a Sql pool level rule and master for workspace level rule). + baseline on a Sql pool level rule and master for workspace level rule). Known values are: + "master" and "default". Required. :type baseline_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentPolicyBaselineName - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, vulnerability_assessment_name=vulnerability_assessment_name, rule_id=rule_id, baseline_name=baseline_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -203,8 +327,7 @@ async def delete( # pylint: disable=inconsistent-return-statements 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}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}"} # type: ignore @distributed_trace_async async def get( @@ -216,72 +339,77 @@ async def get( rule_id: str, baseline_name: Union[str, "_models.VulnerabilityAssessmentPolicyBaselineName"], **kwargs: Any - ) -> "_models.SqlPoolVulnerabilityAssessmentRuleBaseline": + ) -> _models.SqlPoolVulnerabilityAssessmentRuleBaseline: """Gets a SqlPool's vulnerability assessment rule baseline. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param vulnerability_assessment_name: The name of the vulnerability assessment. + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :param rule_id: The vulnerability assessment rule ID. + :param rule_id: The vulnerability assessment rule ID. Required. :type rule_id: str :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a - baseline on a Sql pool level rule and master for server level rule). + baseline on a Sql pool level rule and master for server level rule). Known values are: "master" + and "default". Required. :type baseline_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentPolicyBaselineName - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SqlPoolVulnerabilityAssessmentRuleBaseline, or the result of cls(response) + :return: SqlPoolVulnerabilityAssessmentRuleBaseline or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessmentRuleBaseline - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolVulnerabilityAssessmentRuleBaseline"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolVulnerabilityAssessmentRuleBaseline] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, vulnerability_assessment_name=vulnerability_assessment_name, rule_id=rule_id, baseline_name=baseline_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}"} # 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 5f53695bc56a..6c6036f164b5 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 @@ -6,46 +6,58 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._sql_pool_vulnerability_assessment_scans_operations import build_export_request, build_get_request, build_initiate_scan_request_initial, build_list_request -T = TypeVar('T') +from ...operations._sql_pool_vulnerability_assessment_scans_operations import ( + build_export_request, + build_get_request, + build_initiate_scan_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SqlPoolVulnerabilityAssessmentScansOperations: - """SqlPoolVulnerabilityAssessmentScansOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SqlPoolVulnerabilityAssessmentScansOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`sql_pool_vulnerability_assessment_scans` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( @@ -55,65 +67,64 @@ def list( sql_pool_name: str, vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], **kwargs: Any - ) -> AsyncIterable["_models.VulnerabilityAssessmentScanRecordListResult"]: + ) -> AsyncIterable["_models.VulnerabilityAssessmentScanRecord"]: """Lists the vulnerability assessment scans of a SQL pool. Lists the vulnerability assessment scans of 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param vulnerability_assessment_name: The name of the vulnerability assessment. + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VulnerabilityAssessmentScanRecordListResult or the - result of cls(response) + :return: An iterator like instance of either VulnerabilityAssessmentScanRecord or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.VulnerabilityAssessmentScanRecordListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.VulnerabilityAssessmentScanRecord] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VulnerabilityAssessmentScanRecordListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VulnerabilityAssessmentScanRecordListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, 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'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - vulnerability_assessment_name=vulnerability_assessment_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -127,10 +138,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -140,11 +149,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans"} # type: ignore async def _initiate_scan_initial( # pylint: disable=inconsistent-return-statements self, @@ -155,33 +162,39 @@ async def _initiate_scan_initial( # pylint: disable=inconsistent-return-stateme scan_id: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_initiate_scan_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_initiate_scan_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, vulnerability_assessment_name=vulnerability_assessment_name, scan_id=scan_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._initiate_scan_initial.metadata['url'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -191,11 +204,10 @@ async def _initiate_scan_initial( # pylint: disable=inconsistent-return-stateme if cls: return cls(pipeline_response, None, {}) - _initiate_scan_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan"} # type: ignore - + _initiate_scan_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan"} # type: ignore @distributed_trace_async - async def begin_initiate_scan( # pylint: disable=inconsistent-return-statements + async def begin_initiate_scan( self, resource_group_name: str, workspace_name: str, @@ -207,19 +219,18 @@ async def begin_initiate_scan( # pylint: disable=inconsistent-return-statements """Executes a Vulnerability Assessment database scan. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param vulnerability_assessment_name: The name of the vulnerability assessment. + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :param scan_id: The vulnerability assessment scan Id of the scan to retrieve. + :param scan_id: The vulnerability assessment scan Id of the scan to retrieve. Required. :type scan_id: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -230,47 +241,51 @@ async def begin_initiate_scan( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._initiate_scan_initial( + raw_result = await self._initiate_scan_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, vulnerability_assessment_name=vulnerability_assessment_name, scan_id=scan_id, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_initiate_scan.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan"} # type: ignore + begin_initiate_scan.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan"} # type: ignore @distributed_trace_async async def export( @@ -281,55 +296,60 @@ async def export( vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], scan_id: str, **kwargs: Any - ) -> "_models.SqlPoolVulnerabilityAssessmentScansExport": + ) -> _models.SqlPoolVulnerabilityAssessmentScansExport: """Convert an existing scan result to a human readable format. If already exists nothing happens. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param vulnerability_assessment_name: The name of the vulnerability assessment. + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :param scan_id: The vulnerability assessment scan Id of the scan to retrieve. + :param scan_id: The vulnerability assessment scan Id of the scan to retrieve. Required. :type scan_id: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SqlPoolVulnerabilityAssessmentScansExport, or the result of cls(response) + :return: SqlPoolVulnerabilityAssessmentScansExport or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessmentScansExport - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolVulnerabilityAssessmentScansExport"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolVulnerabilityAssessmentScansExport] - request = build_export_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, vulnerability_assessment_name=vulnerability_assessment_name, scan_id=scan_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export.metadata['url'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -337,18 +357,17 @@ async def export( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('SqlPoolVulnerabilityAssessmentScansExport', pipeline_response) + deserialized = self._deserialize("SqlPoolVulnerabilityAssessmentScansExport", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SqlPoolVulnerabilityAssessmentScansExport', pipeline_response) + deserialized = self._deserialize("SqlPoolVulnerabilityAssessmentScansExport", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/export"} # type: ignore - + export.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/export"} # type: ignore @distributed_trace_async async def get( @@ -359,67 +378,71 @@ async def get( vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], scan_id: str, **kwargs: Any - ) -> "_models.VulnerabilityAssessmentScanRecord": + ) -> _models.VulnerabilityAssessmentScanRecord: """Gets a vulnerability assessment scan record of 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param vulnerability_assessment_name: The name of the vulnerability assessment. + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :param scan_id: The vulnerability assessment scan Id of the scan to retrieve. + :param scan_id: The vulnerability assessment scan Id of the scan to retrieve. Required. :type scan_id: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: VulnerabilityAssessmentScanRecord, or the result of cls(response) + :return: VulnerabilityAssessmentScanRecord or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.VulnerabilityAssessmentScanRecord - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VulnerabilityAssessmentScanRecord"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VulnerabilityAssessmentScanRecord] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, vulnerability_assessment_name=vulnerability_assessment_name, scan_id=scan_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}"} # 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 d329abf17a33..9e32e728ec06 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 @@ -6,106 +6,113 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._sql_pool_vulnerability_assessments_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._sql_pool_vulnerability_assessments_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SqlPoolVulnerabilityAssessmentsOperations: - """SqlPoolVulnerabilityAssessmentsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SqlPoolVulnerabilityAssessmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`sql_pool_vulnerability_assessments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.SqlPoolVulnerabilityAssessmentListResult"]: + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SqlPoolVulnerabilityAssessment"]: """Lists the vulnerability assessment policies associated with a SQL pool. Lists the vulnerability assessment policies associated with 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SqlPoolVulnerabilityAssessmentListResult or the - result of cls(response) + :return: An iterator like instance of either SqlPoolVulnerabilityAssessment or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolVulnerabilityAssessmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolVulnerabilityAssessmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, 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'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -119,10 +126,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -132,11 +137,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments"} # type: ignore @distributed_trace_async async def get( @@ -146,69 +149,149 @@ async def get( sql_pool_name: str, vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], **kwargs: Any - ) -> "_models.SqlPoolVulnerabilityAssessment": + ) -> _models.SqlPoolVulnerabilityAssessment: """Gets the Sql pool's vulnerability assessment. Gets the Sql pool's vulnerability assessment. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param vulnerability_assessment_name: The name of the vulnerability assessment. + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SqlPoolVulnerabilityAssessment, or the result of cls(response) + :return: SqlPoolVulnerabilityAssessment or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolVulnerabilityAssessment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolVulnerabilityAssessment] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}"} # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + parameters: _models.SqlPoolVulnerabilityAssessment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SqlPoolVulnerabilityAssessment: + """Creates or updates the Sql pool vulnerability assessment. + + Creates or updates the Sql pool vulnerability assessment. + + :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 vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. + :type vulnerability_assessment_name: str or + ~azure.mgmt.synapse.models.VulnerabilityAssessmentName + :param parameters: The requested resource. Required. + :type parameters: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SqlPoolVulnerabilityAssessment: + """Creates or updates the Sql pool vulnerability assessment. + Creates or updates the Sql pool vulnerability assessment. + + :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 vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. + :type vulnerability_assessment_name: str or + ~azure.mgmt.synapse.models.VulnerabilityAssessmentName + :param parameters: The requested resource. 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: SqlPoolVulnerabilityAssessment or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update( @@ -217,62 +300,78 @@ async def create_or_update( workspace_name: str, sql_pool_name: str, vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], - parameters: "_models.SqlPoolVulnerabilityAssessment", + parameters: Union[_models.SqlPoolVulnerabilityAssessment, IO], **kwargs: Any - ) -> "_models.SqlPoolVulnerabilityAssessment": + ) -> _models.SqlPoolVulnerabilityAssessment: """Creates or updates the Sql pool vulnerability assessment. Creates or updates the Sql pool vulnerability assessment. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param vulnerability_assessment_name: The name of the vulnerability assessment. + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :param parameters: The requested resource. - :type parameters: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessment - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 - :return: SqlPoolVulnerabilityAssessment, or the result of cls(response) + :return: SqlPoolVulnerabilityAssessment or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolVulnerabilityAssessment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolVulnerabilityAssessment] - _json = self._serialize.body(parameters, 'SqlPoolVulnerabilityAssessment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SqlPoolVulnerabilityAssessment") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, 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, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -280,18 +379,17 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('SqlPoolVulnerabilityAssessment', pipeline_response) + deserialized = self._deserialize("SqlPoolVulnerabilityAssessment", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SqlPoolVulnerabilityAssessment', pipeline_response) + deserialized = self._deserialize("SqlPoolVulnerabilityAssessment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -307,48 +405,53 @@ async def delete( # pylint: disable=inconsistent-return-statements Removes the database's vulnerability assessment. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param vulnerability_assessment_name: The name of the vulnerability assessment. + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -358,5 +461,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}"} # 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 fc1d0e687cd3..d96b1f0fe22c 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 @@ -6,46 +6,58 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._sql_pool_workload_classifier_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._sql_pool_workload_classifier_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SqlPoolWorkloadClassifierOperations: - """SqlPoolWorkloadClassifierOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SqlPoolWorkloadClassifierOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`sql_pool_workload_classifier` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( @@ -56,71 +68,74 @@ async def get( workload_group_name: str, workload_classifier_name: str, **kwargs: Any - ) -> "_models.WorkloadClassifier": + ) -> _models.WorkloadClassifier: """Get workload classifier. Get a workload classifier of Sql pool's workload group. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param workload_group_name: The name of the workload group. + :param workload_group_name: The name of the workload group. Required. :type workload_group_name: str - :param workload_classifier_name: The name of the workload classifier. + :param workload_classifier_name: The name of the workload classifier. Required. :type workload_classifier_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: WorkloadClassifier, or the result of cls(response) + :return: WorkloadClassifier or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.WorkloadClassifier - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadClassifier"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkloadClassifier] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, workload_group_name=workload_group_name, workload_classifier_name=workload_classifier_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}"} # type: ignore async def _create_or_update_initial( self, @@ -129,40 +144,54 @@ async def _create_or_update_initial( sql_pool_name: str, workload_group_name: str, workload_classifier_name: str, - parameters: "_models.WorkloadClassifier", + parameters: Union[_models.WorkloadClassifier, IO], **kwargs: Any - ) -> Optional["_models.WorkloadClassifier"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WorkloadClassifier"]] + ) -> Optional[_models.WorkloadClassifier]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'WorkloadClassifier') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WorkloadClassifier]] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "WorkloadClassifier") + + request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, workload_group_name=workload_group_name, workload_classifier_name=workload_classifier_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -171,18 +200,111 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('WorkloadClassifier', pipeline_response) + deserialized = self._deserialize("WorkloadClassifier", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('WorkloadClassifier', pipeline_response) + deserialized = self._deserialize("WorkloadClassifier", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + workload_group_name: str, + workload_classifier_name: str, + parameters: _models.WorkloadClassifier, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkloadClassifier]: + """Create Or Update workload classifier. + + Create Or Update workload classifier for a Sql pool's workload group. + + :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 workload_group_name: The name of the workload group. Required. + :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. Required. + :type parameters: ~azure.mgmt.synapse.models.WorkloadClassifier + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + workload_group_name: str, + workload_classifier_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkloadClassifier]: + """Create Or Update workload classifier. + + Create Or Update workload classifier for a Sql pool's workload group. + :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 workload_group_name: The name of the workload group. Required. + :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. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WorkloadClassifier or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.WorkloadClassifier] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -192,28 +314,30 @@ async def begin_create_or_update( sql_pool_name: str, workload_group_name: str, workload_classifier_name: str, - parameters: "_models.WorkloadClassifier", + parameters: Union[_models.WorkloadClassifier, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.WorkloadClassifier"]: + ) -> AsyncLROPoller[_models.WorkloadClassifier]: """Create Or Update workload classifier. Create Or Update workload classifier for a Sql pool's workload group. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param workload_group_name: The name of the workload group. + :param workload_group_name: The name of the workload group. Required. :type workload_group_name: str - :param workload_classifier_name: The name of the workload classifier. + :param workload_classifier_name: The name of the workload classifier. Required. :type workload_classifier_name: str - :param parameters: The properties of the workload classifier. - :type parameters: ~azure.mgmt.synapse.models.WorkloadClassifier - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 @@ -225,19 +349,19 @@ async def begin_create_or_update( :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] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadClassifier"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkloadClassifier] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -246,32 +370,35 @@ async def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WorkloadClassifier', pipeline_response) + deserialized = self._deserialize("WorkloadClassifier", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -282,33 +409,39 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements workload_classifier_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + 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, workload_classifier_name=workload_classifier_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -318,11 +451,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements + async def begin_delete( self, resource_group_name: str, workspace_name: str, @@ -336,18 +468,16 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Remove workload classifier of a Sql pool's workload group. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param workload_group_name: The name of the workload group. + :param workload_group_name: The name of the workload group. Required. :type workload_group_name: str - :param workload_classifier_name: The name of the workload classifier. + :param workload_classifier_name: The name of the workload classifier. Required. :type workload_classifier_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -358,114 +488,109 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, workload_group_name=workload_group_name, workload_classifier_name=workload_classifier_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - workload_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.WorkloadClassifierListResult"]: + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, workload_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.WorkloadClassifier"]: """Sql pool's workload classifier. Get list of Sql pool's workload classifier for workload groups. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param workload_group_name: The name of the workload group. + :param workload_group_name: The name of the workload group. Required. :type workload_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkloadClassifierListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.WorkloadClassifierListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkloadClassifierListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadClassifierListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, 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'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - workload_group_name=workload_group_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -479,10 +604,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -492,8 +615,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers"} # type: ignore 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 8e7e86cdb2ac..fac7336563c3 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 @@ -6,117 +6,127 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._sql_pool_workload_group_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._sql_pool_workload_group_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SqlPoolWorkloadGroupOperations: - """SqlPoolWorkloadGroupOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SqlPoolWorkloadGroupOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`sql_pool_workload_group` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - workload_group_name: str, - **kwargs: Any - ) -> "_models.WorkloadGroup": + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, workload_group_name: str, **kwargs: Any + ) -> _models.WorkloadGroup: """Sql pool's workload group. Get a Sql pool's workload group. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param workload_group_name: The name of the workload group. + :param workload_group_name: The name of the workload group. Required. :type workload_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: WorkloadGroup, or the result of cls(response) + :return: WorkloadGroup or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.WorkloadGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkloadGroup] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}"} # type: ignore async def _create_or_update_initial( self, @@ -124,39 +134,53 @@ async def _create_or_update_initial( workspace_name: str, sql_pool_name: str, workload_group_name: str, - parameters: "_models.WorkloadGroup", + parameters: Union[_models.WorkloadGroup, IO], **kwargs: Any - ) -> Optional["_models.WorkloadGroup"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WorkloadGroup"]] + ) -> Optional[_models.WorkloadGroup]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'WorkloadGroup') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WorkloadGroup]] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "WorkloadGroup") + + request = build_create_or_update_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, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -165,18 +189,105 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('WorkloadGroup', pipeline_response) + deserialized = self._deserialize("WorkloadGroup", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('WorkloadGroup', pipeline_response) + deserialized = self._deserialize("WorkloadGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + workload_group_name: str, + parameters: _models.WorkloadGroup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkloadGroup]: + """Create Or Update workload group. + + Create Or Update a Sql pool's workload group. + + :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 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: ~azure.mgmt.synapse.models.WorkloadGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + workload_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkloadGroup]: + """Create Or Update workload group. + + Create Or Update a Sql pool's workload group. + + :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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -185,26 +296,28 @@ async def begin_create_or_update( workspace_name: str, sql_pool_name: str, workload_group_name: str, - parameters: "_models.WorkloadGroup", + parameters: Union[_models.WorkloadGroup, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.WorkloadGroup"]: + ) -> AsyncLROPoller[_models.WorkloadGroup]: """Create Or Update workload group. Create Or Update a Sql pool's workload group. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param workload_group_name: The name of the workload group. + :param workload_group_name: The name of the workload group. Required. :type workload_group_name: str - :param parameters: The requested workload group state. - :type parameters: ~azure.mgmt.synapse.models.WorkloadGroup - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 @@ -216,19 +329,19 @@ async def begin_create_or_update( :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] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadGroup"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkloadGroup] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -236,67 +349,71 @@ async def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WorkloadGroup', pipeline_response) + deserialized = self._deserialize("WorkloadGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - workload_group_name: str, - **kwargs: Any + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, workload_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + 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'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -306,33 +423,25 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - workload_group_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, workload_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Remove workload group. Remove Sql pool's workload group. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param workload_group_name: The name of the workload group. + :param workload_group_name: The name of the workload group. Required. :type workload_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -343,108 +452,105 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, workload_group_name=workload_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.WorkloadGroupListResult"]: + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> AsyncIterable["_models.WorkloadGroup"]: """Sql pool's workload groups. Get list of Sql pool's workload groups. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkloadGroupListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.WorkloadGroupListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkloadGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadGroupListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, 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'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -458,10 +564,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -471,8 +575,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups"} # type: ignore 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 f86399bb13d0..294701403e6a 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 @@ -6,98 +6,120 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._sql_pools_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_workspace_request, build_pause_request_initial, build_rename_request, build_resume_request_initial, build_update_request -T = TypeVar('T') +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, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SqlPoolsOperations: - """SqlPoolsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SqlPoolsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`sql_pools` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> "_models.SqlPool": + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> _models.SqlPool: """Get SQL pool. Get SQL pool properties. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SqlPool, or the result of cls(response) + :return: SqlPool or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPool"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPool] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -105,15 +127,80 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}"} # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + sql_pool_info: _models.SqlPoolPatchInfo, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.SqlPool]: + """Update SQL pool. + + Apply a partial update to 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 sql_pool_info: The updated SQL pool properties. Required. + :type sql_pool_info: ~azure.mgmt.synapse.models.SqlPoolPatchInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: SqlPool or None or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.SqlPool or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + sql_pool_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.SqlPool]: + """Update SQL pool. + Apply a partial update to 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 sql_pool_info: The updated SQL pool properties. Required. + :type sql_pool_info: 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: SqlPool or None or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.SqlPool or None + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def update( @@ -121,58 +208,74 @@ async def update( resource_group_name: str, workspace_name: str, sql_pool_name: str, - sql_pool_info: "_models.SqlPoolPatchInfo", + sql_pool_info: Union[_models.SqlPoolPatchInfo, IO], **kwargs: Any - ) -> Optional["_models.SqlPool"]: + ) -> Optional[_models.SqlPool]: """Update SQL pool. Apply a partial update to 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param sql_pool_info: The updated SQL pool properties. - :type sql_pool_info: ~azure.mgmt.synapse.models.SqlPoolPatchInfo - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 - :return: SqlPool, or the result of cls(response) + :return: SqlPool or None or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPool or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.SqlPool"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(sql_pool_info, 'SqlPoolPatchInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SqlPool]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(sql_pool_info, (IO, bytes)): + _content = sql_pool_info + else: + _json = self._serialize.body(sql_pool_info, "SqlPoolPatchInfo") request = build_update_request( - subscription_id=self._config.subscription_id, 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, - template_url=self.update.metadata['url'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -182,70 +285,165 @@ async def update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SqlPool', pipeline_response) + deserialized = self._deserialize("SqlPool", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}"} # type: ignore async def _create_initial( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, - sql_pool_info: "_models.SqlPool", + sql_pool_info: Union[_models.SqlPool, IO], **kwargs: Any - ) -> Optional["_models.SqlPool"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.SqlPool"]] + ) -> Optional[_models.SqlPool]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(sql_pool_info, 'SqlPool') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SqlPool]] - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(sql_pool_info, (IO, bytes)): + _content = sql_pool_info + else: + _json = self._serialize.body(sql_pool_info, "SqlPool") + + request = build_create_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, - template_url=self._create_initial.metadata['url'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response - if response.status_code not in [200, 202, 404]: + if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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 = self._deserialize("SqlPool", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}"} # type: ignore + @overload + async def begin_create( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + sql_pool_info: _models.SqlPool, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SqlPool]: + """Create SQL pool. + + Create 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 sql_pool_info: The SQL pool to create. Required. + :type sql_pool_info: ~azure.mgmt.synapse.models.SqlPool + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + sql_pool_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SqlPool]: + """Create SQL pool. + + Create 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 sql_pool_info: The SQL pool to create. Required. + :type sql_pool_info: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SqlPool or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.SqlPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( @@ -253,24 +451,25 @@ async def begin_create( resource_group_name: str, workspace_name: str, sql_pool_name: str, - sql_pool_info: "_models.SqlPool", + sql_pool_info: Union[_models.SqlPool, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.SqlPool"]: + ) -> AsyncLROPoller[_models.SqlPool]: """Create SQL pool. Create 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param sql_pool_info: The SQL pool to create. - :type sql_pool_info: ~azure.mgmt.synapse.models.SqlPool - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 @@ -282,126 +481,127 @@ async def begin_create( :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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPool"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPool] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, sql_pool_info=sql_pool_info, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('SqlPool', pipeline_response) + deserialized = self._deserialize("SqlPool", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}"} # type: ignore async def _delete_initial( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> Optional[Any]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[Any]] + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> Optional[JSON]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[JSON]] + + 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'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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('object', pipeline_response) + deserialized = self._deserialize("object", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('object', pipeline_response) + deserialized = self._deserialize("object", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}"} # type: ignore @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> AsyncLROPoller[Any]: + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> AsyncLROPoller[JSON]: """Delete SQL pool. Delete 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -410,107 +610,107 @@ async def begin_delete( :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either any or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[any] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An instance of AsyncLROPoller that returns either JSON or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[JSON] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Any] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[JSON] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('object', pipeline_response) + deserialized = self._deserialize("object", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}"} # type: ignore @distributed_trace def list_by_workspace( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.SqlPoolInfoListResult"]: + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SqlPool"]: """List SQL pools. List all SQL pools. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SqlPoolInfoListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.SqlPoolInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolInfoListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolInfoListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore else: - - request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -524,10 +724,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -538,83 +736,77 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_workspace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools"} # type: ignore + list_by_workspace.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools"} # type: ignore async def _pause_initial( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> Optional[Any]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[Any]] + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> Optional[JSON]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_pause_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[JSON]] + + 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'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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('object', pipeline_response) + deserialized = self._deserialize("object", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _pause_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/pause"} # type: ignore - + _pause_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/pause"} # type: ignore @distributed_trace_async async def begin_pause( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> AsyncLROPoller[Any]: + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> AsyncLROPoller[JSON]: """Pause SQL pool. Pause 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -623,122 +815,123 @@ async def begin_pause( :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either any or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[any] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An instance of AsyncLROPoller that returns either JSON or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[JSON] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Any] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[JSON] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._pause_initial( + raw_result = await self._pause_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('object', pipeline_response) + deserialized = self._deserialize("object", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_pause.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/pause"} # type: ignore + begin_pause.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/pause"} # type: ignore async def _resume_initial( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> Optional[Any]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[Any]] + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> Optional[JSON]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_resume_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[JSON]] + + 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'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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('object', pipeline_response) + deserialized = self._deserialize("object", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _resume_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/resume"} # type: ignore - + _resume_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/resume"} # type: ignore @distributed_trace_async async def begin_resume( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> AsyncLROPoller[Any]: + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> AsyncLROPoller[JSON]: """Resume SQL pool. Resume 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -747,58 +940,65 @@ async def begin_resume( :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either any or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[any] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An instance of AsyncLROPoller that returns either JSON or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[JSON] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Any] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[JSON] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._resume_initial( + raw_result = await self._resume_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('object', pipeline_response) + deserialized = self._deserialize("object", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_resume.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/resume"} # type: ignore + begin_resume.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/resume"} # type: ignore - @distributed_trace_async + @overload async def rename( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: "_models.ResourceMoveDefinition", + parameters: _models.ResourceMoveDefinition, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Rename a SQL pool. @@ -806,50 +1006,130 @@ async def rename( # pylint: disable=inconsistent-return-statements 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param parameters: The resource move definition for renaming this Sql pool. + :param parameters: The resource move definition for renaming this Sql pool. Required. :type parameters: ~azure.mgmt.synapse.models.ResourceMoveDefinition - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ResourceMoveDefinition') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ResourceMoveDefinition") request = build_rename_request( - subscription_id=self._config.subscription_id, 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, - template_url=self.rename.metadata['url'], + content=_content, + template_url=self.rename.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -859,5 +1139,4 @@ async def rename( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - rename.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/move"} # type: ignore - + rename.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/move"} # type: ignore 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 0b0b4b32cdd7..6359b412232c 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 @@ -6,90 +6,100 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._workspace_aad_admins_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request -T = TypeVar('T') +from ...operations._workspace_aad_admins_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class WorkspaceAadAdminsOperations: - """WorkspaceAadAdminsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class WorkspaceAadAdminsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`workspace_aad_admins` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> "_models.WorkspaceAadAdminInfo": + async def get(self, resource_group_name: str, workspace_name: str, **kwargs: Any) -> _models.WorkspaceAadAdminInfo: """Gets a workspace active directory admin. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: WorkspaceAadAdminInfo, or the result of cls(response) + :return: WorkspaceAadAdminInfo or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.WorkspaceAadAdminInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceAadAdminInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkspaceAadAdminInfo] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -97,90 +107,177 @@ async def get( 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/administrators/activeDirectory"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/administrators/activeDirectory"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, workspace_name: str, - aad_admin_info: "_models.WorkspaceAadAdminInfo", + aad_admin_info: Union[_models.WorkspaceAadAdminInfo, IO], **kwargs: Any - ) -> "_models.WorkspaceAadAdminInfo": - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceAadAdminInfo"] + ) -> _models.WorkspaceAadAdminInfo: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(aad_admin_info, 'WorkspaceAadAdminInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkspaceAadAdminInfo] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(aad_admin_info, (IO, bytes)): + _content = aad_admin_info + else: + _json = self._serialize.body(aad_admin_info, "WorkspaceAadAdminInfo") + + request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("WorkspaceAadAdminInfo", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('WorkspaceAadAdminInfo', pipeline_response) + deserialized = self._deserialize("WorkspaceAadAdminInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/administrators/activeDirectory"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/administrators/activeDirectory"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + aad_admin_info: _models.WorkspaceAadAdminInfo, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkspaceAadAdminInfo]: + """Creates or updates a workspace active directory admin. + :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 aad_admin_info: Workspace active directory administrator properties. Required. + :type aad_admin_info: ~azure.mgmt.synapse.models.WorkspaceAadAdminInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + aad_admin_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkspaceAadAdminInfo]: + """Creates or updates a workspace active directory admin. + + :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 aad_admin_info: Workspace active directory administrator properties. Required. + :type aad_admin_info: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WorkspaceAadAdminInfo or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.WorkspaceAadAdminInfo] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, workspace_name: str, - aad_admin_info: "_models.WorkspaceAadAdminInfo", + aad_admin_info: Union[_models.WorkspaceAadAdminInfo, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.WorkspaceAadAdminInfo"]: + ) -> AsyncLROPoller[_models.WorkspaceAadAdminInfo]: """Creates or updates a workspace active directory admin. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param aad_admin_info: Workspace active directory administrator properties. - :type aad_admin_info: ~azure.mgmt.synapse.models.WorkspaceAadAdminInfo - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 @@ -192,109 +289,110 @@ async def begin_create_or_update( :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] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceAadAdminInfo"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkspaceAadAdminInfo] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, aad_admin_info=aad_admin_info, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WorkspaceAadAdminInfo', pipeline_response) + deserialized = self._deserialize("WorkspaceAadAdminInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/administrators/activeDirectory"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/administrators/activeDirectory"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any + self, resource_group_name: str, workspace_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + 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'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/administrators/activeDirectory"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/administrators/activeDirectory"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, workspace_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a workspace active directory admin. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -305,41 +403,47 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/administrators/activeDirectory"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/administrators/activeDirectory"} # 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 67203affd03e..2d3139149ff3 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 @@ -6,92 +6,103 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._workspace_managed_identity_sql_control_settings_operations import build_create_or_update_request_initial, build_get_request -T = TypeVar('T') +from ...operations._workspace_managed_identity_sql_control_settings_operations import ( + build_create_or_update_request, + build_get_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class WorkspaceManagedIdentitySqlControlSettingsOperations: - """WorkspaceManagedIdentitySqlControlSettingsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class WorkspaceManagedIdentitySqlControlSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`workspace_managed_identity_sql_control_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> "_models.ManagedIdentitySqlControlSettingsModel": + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> _models.ManagedIdentitySqlControlSettingsModel: """Get Managed Identity Sql Control Settings. Get Managed Identity Sql Control Settings. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagedIdentitySqlControlSettingsModel, or the result of cls(response) + :return: ManagedIdentitySqlControlSettingsModel or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ManagedIdentitySqlControlSettingsModel - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedIdentitySqlControlSettingsModel"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagedIdentitySqlControlSettingsModel] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -99,91 +110,187 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/managedIdentitySqlControlSettings/default"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/managedIdentitySqlControlSettings/default"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, workspace_name: str, - managed_identity_sql_control_settings: "_models.ManagedIdentitySqlControlSettingsModel", + managed_identity_sql_control_settings: Union[_models.ManagedIdentitySqlControlSettingsModel, IO], **kwargs: Any - ) -> Optional["_models.ManagedIdentitySqlControlSettingsModel"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ManagedIdentitySqlControlSettingsModel"]] + ) -> Optional[_models.ManagedIdentitySqlControlSettingsModel]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(managed_identity_sql_control_settings, 'ManagedIdentitySqlControlSettingsModel') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ManagedIdentitySqlControlSettingsModel]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(managed_identity_sql_control_settings, (IO, bytes)): + _content = managed_identity_sql_control_settings + else: + _json = self._serialize.body( + managed_identity_sql_control_settings, "ManagedIdentitySqlControlSettingsModel" + ) - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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('ManagedIdentitySqlControlSettingsModel', pipeline_response) + deserialized = self._deserialize("ManagedIdentitySqlControlSettingsModel", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/managedIdentitySqlControlSettings/default"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/managedIdentitySqlControlSettings/default"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + managed_identity_sql_control_settings: _models.ManagedIdentitySqlControlSettingsModel, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedIdentitySqlControlSettingsModel]: + """Create or update Managed Identity Sql Control Settings. + + Create or update Managed Identity Sql Control Settings. + + :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 managed_identity_sql_control_settings: Managed Identity Sql Control Settings. Required. + :type managed_identity_sql_control_settings: + ~azure.mgmt.synapse.models.ManagedIdentitySqlControlSettingsModel + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.ManagedIdentitySqlControlSettingsModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + managed_identity_sql_control_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedIdentitySqlControlSettingsModel]: + """Create or update Managed Identity Sql Control Settings. + Create or update Managed Identity Sql Control Settings. + + :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 managed_identity_sql_control_settings: Managed Identity Sql Control Settings. Required. + :type managed_identity_sql_control_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either + ManagedIdentitySqlControlSettingsModel or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.ManagedIdentitySqlControlSettingsModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, workspace_name: str, - managed_identity_sql_control_settings: "_models.ManagedIdentitySqlControlSettingsModel", + managed_identity_sql_control_settings: Union[_models.ManagedIdentitySqlControlSettingsModel, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ManagedIdentitySqlControlSettingsModel"]: + ) -> AsyncLROPoller[_models.ManagedIdentitySqlControlSettingsModel]: """Create or update Managed Identity Sql Control Settings. Create or update Managed Identity Sql Control Settings. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param managed_identity_sql_control_settings: Managed Identity Sql Control Settings. + :param managed_identity_sql_control_settings: Managed Identity Sql Control Settings. Is either + a model type or a IO type. Required. :type managed_identity_sql_control_settings: - ~azure.mgmt.synapse.models.ManagedIdentitySqlControlSettingsModel - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + ~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 @@ -196,47 +303,53 @@ async def begin_create_or_update( ManagedIdentitySqlControlSettingsModel or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.ManagedIdentitySqlControlSettingsModel] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedIdentitySqlControlSettingsModel"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagedIdentitySqlControlSettingsModel] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, managed_identity_sql_control_settings=managed_identity_sql_control_settings, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ManagedIdentitySqlControlSettingsModel', pipeline_response) + deserialized = self._deserialize("ManagedIdentitySqlControlSettingsModel", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/managedIdentitySqlControlSettings/default"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/managedIdentitySqlControlSettings/default"} # 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 c8368e79cf2d..f811f3b54006 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 @@ -6,46 +6,57 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._workspace_managed_sql_server_blob_auditing_policies_operations import build_create_or_update_request_initial, build_get_request, build_list_by_workspace_request -T = TypeVar('T') +from ...operations._workspace_managed_sql_server_blob_auditing_policies_operations import ( + build_create_or_update_request, + build_get_request, + build_list_by_workspace_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class WorkspaceManagedSqlServerBlobAuditingPoliciesOperations: - """WorkspaceManagedSqlServerBlobAuditingPoliciesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class WorkspaceManagedSqlServerBlobAuditingPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`workspace_managed_sql_server_blob_auditing_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( @@ -54,103 +65,120 @@ async def get( workspace_name: str, blob_auditing_policy_name: Union[str, "_models.BlobAuditingPolicyName"], **kwargs: Any - ) -> "_models.ServerBlobAuditingPolicy": + ) -> _models.ServerBlobAuditingPolicy: """Get server's blob auditing policy. Get a workspace managed sql server's blob auditing policy. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param blob_auditing_policy_name: The name of the blob auditing policy. + :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 api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServerBlobAuditingPolicy, or the result of cls(response) + :return: ServerBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ServerBlobAuditingPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerBlobAuditingPolicy"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServerBlobAuditingPolicy] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/auditingSettings/{blobAuditingPolicyName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/auditingSettings/{blobAuditingPolicyName}"} # 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: "_models.ServerBlobAuditingPolicy", + parameters: Union[_models.ServerBlobAuditingPolicy, IO], **kwargs: Any - ) -> Optional["_models.ServerBlobAuditingPolicy"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ServerBlobAuditingPolicy"]] + ) -> Optional[_models.ServerBlobAuditingPolicy]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ServerBlobAuditingPolicy') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ServerBlobAuditingPolicy]] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServerBlobAuditingPolicy") + + request = build_create_or_update_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, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -159,15 +187,96 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ServerBlobAuditingPolicy', pipeline_response) + deserialized = self._deserialize("ServerBlobAuditingPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/auditingSettings/{blobAuditingPolicyName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/auditingSettings/{blobAuditingPolicyName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + blob_auditing_policy_name: Union[str, "_models.BlobAuditingPolicyName"], + parameters: _models.ServerBlobAuditingPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerBlobAuditingPolicy]: + """Create or Update server's blob auditing policy. + + Create or Update a workspace managed sql server's blob auditing policy. + + :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 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: ~azure.mgmt.synapse.models.ServerBlobAuditingPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + blob_auditing_policy_name: Union[str, "_models.BlobAuditingPolicyName"], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerBlobAuditingPolicy]: + """Create or Update server's blob auditing policy. + + Create or Update a workspace managed sql server's blob auditing policy. + :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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -175,24 +284,26 @@ async def begin_create_or_update( resource_group_name: str, workspace_name: str, blob_auditing_policy_name: Union[str, "_models.BlobAuditingPolicyName"], - parameters: "_models.ServerBlobAuditingPolicy", + parameters: Union[_models.ServerBlobAuditingPolicy, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ServerBlobAuditingPolicy"]: + ) -> AsyncLROPoller[_models.ServerBlobAuditingPolicy]: """Create or Update server's blob auditing policy. Create or Update a workspace managed sql server's blob auditing policy. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param blob_auditing_policy_name: The name of the blob auditing policy. + :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. - :type parameters: ~azure.mgmt.synapse.models.ServerBlobAuditingPolicy - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 @@ -204,108 +315,108 @@ async def begin_create_or_update( :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] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerBlobAuditingPolicy"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServerBlobAuditingPolicy] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, blob_auditing_policy_name=blob_auditing_policy_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServerBlobAuditingPolicy', pipeline_response) + deserialized = self._deserialize("ServerBlobAuditingPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/auditingSettings/{blobAuditingPolicyName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/auditingSettings/{blobAuditingPolicyName}"} # type: ignore @distributed_trace def list_by_workspace( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ServerBlobAuditingPolicyListResult"]: + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ServerBlobAuditingPolicy"]: """List workspace server's blob auditing policies. List workspace managed sql server's blob auditing policies. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServerBlobAuditingPolicyListResult or the result - of cls(response) + :return: An iterator like instance of either ServerBlobAuditingPolicy or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.ServerBlobAuditingPolicyListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.ServerBlobAuditingPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServerBlobAuditingPolicyListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerBlobAuditingPolicyListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore else: - - request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -319,10 +430,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -332,8 +441,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_workspace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/auditingSettings"} # type: ignore + list_by_workspace.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/auditingSettings"} # type: ignore 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 0e71b5051b47..b9b34b8dd716 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 @@ -6,101 +6,214 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._workspace_managed_sql_server_dedicated_sql_minimal_tls_settings_operations import build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._workspace_managed_sql_server_dedicated_sql_minimal_tls_settings_operations import ( + build_get_request, + build_list_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class WorkspaceManagedSqlServerDedicatedSQLMinimalTlsSettingsOperations: - """WorkspaceManagedSqlServerDedicatedSQLMinimalTlsSettingsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class WorkspaceManagedSqlServerDedicatedSQLMinimalTlsSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`workspace_managed_sql_server_dedicated_sql_minimal_tls_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _update_initial( self, resource_group_name: str, workspace_name: str, dedicated_sq_lminimal_tls_settings_name: Union[str, "_models.DedicatedSQLMinimalTlsSettingsName"], - parameters: "_models.DedicatedSQLminimalTlsSettings", + parameters: Union[_models.DedicatedSQLminimalTlsSettings, IO], **kwargs: Any - ) -> Optional["_models.DedicatedSQLminimalTlsSettings"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DedicatedSQLminimalTlsSettings"]] + ) -> Optional[_models.DedicatedSQLminimalTlsSettings]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'DedicatedSQLminimalTlsSettings') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DedicatedSQLminimalTlsSettings]] - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DedicatedSQLminimalTlsSettings") + + 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, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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 = self._deserialize("DedicatedSQLminimalTlsSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/dedicatedSQLminimalTlsSettings/{dedicatedSQLminimalTlsSettingsName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/dedicatedSQLminimalTlsSettings/{dedicatedSQLminimalTlsSettingsName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + workspace_name: str, + dedicated_sq_lminimal_tls_settings_name: Union[str, "_models.DedicatedSQLMinimalTlsSettingsName"], + parameters: _models.DedicatedSQLminimalTlsSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DedicatedSQLminimalTlsSettings]: + """Update server's tls settings. + + Update workspace managed sql server's minimal tls settings. + + :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 dedicated_sq_lminimal_tls_settings_name: The name of the dedicated sql minimal tls + settings. "default" Required. + :type dedicated_sq_lminimal_tls_settings_name: str or + ~azure.mgmt.synapse.models.DedicatedSQLMinimalTlsSettingsName + :param parameters: minimal tls settings. Required. + :type parameters: ~azure.mgmt.synapse.models.DedicatedSQLminimalTlsSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.DedicatedSQLminimalTlsSettings] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + workspace_name: str, + dedicated_sq_lminimal_tls_settings_name: Union[str, "_models.DedicatedSQLMinimalTlsSettingsName"], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DedicatedSQLminimalTlsSettings]: + """Update server's tls settings. + + Update workspace managed sql server's minimal tls settings. + :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 dedicated_sq_lminimal_tls_settings_name: The name of the dedicated sql minimal tls + settings. "default" Required. + :type dedicated_sq_lminimal_tls_settings_name: str or + ~azure.mgmt.synapse.models.DedicatedSQLMinimalTlsSettingsName + :param parameters: minimal tls settings. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DedicatedSQLminimalTlsSettings or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.DedicatedSQLminimalTlsSettings] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -108,26 +221,27 @@ async def begin_update( resource_group_name: str, workspace_name: str, dedicated_sq_lminimal_tls_settings_name: Union[str, "_models.DedicatedSQLMinimalTlsSettingsName"], - parameters: "_models.DedicatedSQLminimalTlsSettings", + parameters: Union[_models.DedicatedSQLminimalTlsSettings, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.DedicatedSQLminimalTlsSettings"]: + ) -> AsyncLROPoller[_models.DedicatedSQLminimalTlsSettings]: """Update server's tls settings. Update workspace managed sql server's minimal tls settings. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str :param dedicated_sq_lminimal_tls_settings_name: The name of the dedicated sql minimal tls - settings. + settings. "default" Required. :type dedicated_sq_lminimal_tls_settings_name: str or ~azure.mgmt.synapse.models.DedicatedSQLMinimalTlsSettingsName - :param parameters: minimal tls settings. - :type parameters: ~azure.mgmt.synapse.models.DedicatedSQLminimalTlsSettings - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 @@ -140,104 +254,107 @@ async def begin_update( the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.DedicatedSQLminimalTlsSettings] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedSQLminimalTlsSettings"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DedicatedSQLminimalTlsSettings] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, dedicated_sq_lminimal_tls_settings_name=dedicated_sq_lminimal_tls_settings_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DedicatedSQLminimalTlsSettings', pipeline_response) + deserialized = self._deserialize("DedicatedSQLminimalTlsSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/dedicatedSQLminimalTlsSettings/{dedicatedSQLminimalTlsSettingsName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/dedicatedSQLminimalTlsSettings/{dedicatedSQLminimalTlsSettingsName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - workspace_name: str, - dedicated_sq_lminimal_tls_settings_name: str, - **kwargs: Any - ) -> "_models.DedicatedSQLminimalTlsSettings": + self, resource_group_name: str, workspace_name: str, dedicated_sq_lminimal_tls_settings_name: str, **kwargs: Any + ) -> _models.DedicatedSQLminimalTlsSettings: """Get server's minimal tls settings. Get workspace managed sql server's minimal tls settings. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str :param dedicated_sq_lminimal_tls_settings_name: The name of the dedicated sql minimal tls - settings. + settings. Required. :type dedicated_sq_lminimal_tls_settings_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DedicatedSQLminimalTlsSettings, or the result of cls(response) + :return: DedicatedSQLminimalTlsSettings or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.DedicatedSQLminimalTlsSettings - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedSQLminimalTlsSettings"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DedicatedSQLminimalTlsSettings] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -245,72 +362,68 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/dedicatedSQLminimalTlsSettings/{dedicatedSQLminimalTlsSettingsName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/dedicatedSQLminimalTlsSettings/{dedicatedSQLminimalTlsSettingsName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.DedicatedSQLminimalTlsSettingsListResult"]: + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DedicatedSQLminimalTlsSettings"]: """List workspace server's minimal tls settings. List workspace managed sql server's minimal tls settings. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DedicatedSQLminimalTlsSettingsListResult or the - result of cls(response) + :return: An iterator like instance of either DedicatedSQLminimalTlsSettings or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.DedicatedSQLminimalTlsSettingsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.DedicatedSQLminimalTlsSettings] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DedicatedSQLminimalTlsSettingsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedSQLminimalTlsSettingsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -324,10 +437,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -338,8 +449,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/dedicatedSQLminimalTlsSettings"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/dedicatedSQLminimalTlsSettings"} # type: ignore 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 1720d125e6b1..e689734d0b9d 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 @@ -6,46 +6,58 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._workspace_managed_sql_server_encryption_protector_operations import build_create_or_update_request_initial, build_get_request, build_list_request, build_revalidate_request_initial -T = TypeVar('T') +from ...operations._workspace_managed_sql_server_encryption_protector_operations import ( + build_create_or_update_request, + build_get_request, + build_list_request, + build_revalidate_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class WorkspaceManagedSqlServerEncryptionProtectorOperations: - """WorkspaceManagedSqlServerEncryptionProtectorOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class WorkspaceManagedSqlServerEncryptionProtectorOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`workspace_managed_sql_server_encryption_protector` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( @@ -54,50 +66,54 @@ async def get( workspace_name: str, encryption_protector_name: Union[str, "_models.EncryptionProtectorName"], **kwargs: Any - ) -> "_models.EncryptionProtector": + ) -> _models.EncryptionProtector: """Get workspace server's encryption protector. Get workspace managed sql server's encryption protector. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param encryption_protector_name: The name of the encryption protector. + :param encryption_protector_name: The name of the encryption protector. "current" Required. :type encryption_protector_name: str or ~azure.mgmt.synapse.models.EncryptionProtectorName - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EncryptionProtector, or the result of cls(response) + :return: EncryptionProtector or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.EncryptionProtector - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionProtector"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionProtector] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -105,70 +121,165 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector/{encryptionProtectorName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector/{encryptionProtectorName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, workspace_name: str, encryption_protector_name: Union[str, "_models.EncryptionProtectorName"], - parameters: "_models.EncryptionProtector", + parameters: Union[_models.EncryptionProtector, IO], **kwargs: Any - ) -> Optional["_models.EncryptionProtector"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.EncryptionProtector"]] + ) -> Optional[_models.EncryptionProtector]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'EncryptionProtector') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.EncryptionProtector]] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "EncryptionProtector") + + request = build_create_or_update_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, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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 = self._deserialize("EncryptionProtector", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector/{encryptionProtectorName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector/{encryptionProtectorName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + encryption_protector_name: Union[str, "_models.EncryptionProtectorName"], + parameters: _models.EncryptionProtector, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.EncryptionProtector]: + """Updates workspace server's encryption protector. + + Updates workspace managed sql server's encryption protector. + + :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 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: ~azure.mgmt.synapse.models.EncryptionProtector + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + encryption_protector_name: Union[str, "_models.EncryptionProtectorName"], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.EncryptionProtector]: + """Updates workspace server's encryption protector. + + Updates workspace managed sql server's encryption protector. + + :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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -176,24 +287,26 @@ async def begin_create_or_update( resource_group_name: str, workspace_name: str, encryption_protector_name: Union[str, "_models.EncryptionProtectorName"], - parameters: "_models.EncryptionProtector", + parameters: Union[_models.EncryptionProtector, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.EncryptionProtector"]: + ) -> AsyncLROPoller[_models.EncryptionProtector]: """Updates workspace server's encryption protector. Updates workspace managed sql server's encryption protector. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param encryption_protector_name: The name of the encryption protector. + :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. - :type parameters: ~azure.mgmt.synapse.models.EncryptionProtector - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 @@ -205,108 +318,106 @@ async def begin_create_or_update( :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] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionProtector"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionProtector] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, encryption_protector_name=encryption_protector_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('EncryptionProtector', pipeline_response) + deserialized = self._deserialize("EncryptionProtector", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector/{encryptionProtectorName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector/{encryptionProtectorName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.EncryptionProtectorListResult"]: + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.EncryptionProtector"]: """Get list of encryption protectors for the server. Get list of encryption protectors for workspace managed sql server. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EncryptionProtectorListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.EncryptionProtectorListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionProtectorListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionProtectorListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -320,10 +431,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -333,11 +442,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector"} # type: ignore async def _revalidate_initial( # pylint: disable=inconsistent-return-statements self, @@ -346,31 +453,37 @@ async def _revalidate_initial( # pylint: disable=inconsistent-return-statements encryption_protector_name: Union[str, "_models.EncryptionProtectorName"], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_revalidate_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + 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'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -380,11 +493,10 @@ async def _revalidate_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _revalidate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector/{encryptionProtectorName}/revalidate"} # type: ignore - + _revalidate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector/{encryptionProtectorName}/revalidate"} # type: ignore @distributed_trace_async - async def begin_revalidate( # pylint: disable=inconsistent-return-statements + async def begin_revalidate( self, resource_group_name: str, workspace_name: str, @@ -396,14 +508,12 @@ async def begin_revalidate( # pylint: disable=inconsistent-return-statements Revalidates workspace managed sql server's existing encryption protector. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param encryption_protector_name: The name of the encryption protector. + :param encryption_protector_name: The name of the encryption protector. "current" Required. :type encryption_protector_name: str or ~azure.mgmt.synapse.models.EncryptionProtectorName - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -414,42 +524,46 @@ async def begin_revalidate( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._revalidate_initial( + raw_result = await self._revalidate_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, encryption_protector_name=encryption_protector_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_revalidate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector/{encryptionProtectorName}/revalidate"} # type: ignore + begin_revalidate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector/{encryptionProtectorName}/revalidate"} # 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 17c20860e49f..68bd5180a564 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 @@ -6,46 +6,57 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._workspace_managed_sql_server_extended_blob_auditing_policies_operations import build_create_or_update_request_initial, build_get_request, build_list_by_workspace_request -T = TypeVar('T') +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, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class WorkspaceManagedSqlServerExtendedBlobAuditingPoliciesOperations: - """WorkspaceManagedSqlServerExtendedBlobAuditingPoliciesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class WorkspaceManagedSqlServerExtendedBlobAuditingPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`workspace_managed_sql_server_extended_blob_auditing_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( @@ -54,103 +65,120 @@ async def get( workspace_name: str, blob_auditing_policy_name: Union[str, "_models.BlobAuditingPolicyName"], **kwargs: Any - ) -> "_models.ExtendedServerBlobAuditingPolicy": + ) -> _models.ExtendedServerBlobAuditingPolicy: """Get server's extended blob auditing policy. Get a workspace SQL server's extended blob auditing policy. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param blob_auditing_policy_name: The name of the blob auditing policy. + :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 api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ExtendedServerBlobAuditingPolicy, or the result of cls(response) + :return: ExtendedServerBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ExtendedServerBlobAuditingPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtendedServerBlobAuditingPolicy"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ExtendedServerBlobAuditingPolicy] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/extendedAuditingSettings/{blobAuditingPolicyName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/extendedAuditingSettings/{blobAuditingPolicyName}"} # 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: "_models.ExtendedServerBlobAuditingPolicy", + parameters: Union[_models.ExtendedServerBlobAuditingPolicy, IO], **kwargs: Any - ) -> Optional["_models.ExtendedServerBlobAuditingPolicy"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ExtendedServerBlobAuditingPolicy"]] + ) -> Optional[_models.ExtendedServerBlobAuditingPolicy]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ExtendedServerBlobAuditingPolicy') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ExtendedServerBlobAuditingPolicy]] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExtendedServerBlobAuditingPolicy") + + request = build_create_or_update_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, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -159,15 +187,98 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ExtendedServerBlobAuditingPolicy', pipeline_response) + deserialized = self._deserialize("ExtendedServerBlobAuditingPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/extendedAuditingSettings/{blobAuditingPolicyName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/extendedAuditingSettings/{blobAuditingPolicyName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + blob_auditing_policy_name: Union[str, "_models.BlobAuditingPolicyName"], + parameters: _models.ExtendedServerBlobAuditingPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ExtendedServerBlobAuditingPolicy]: + """Create or Update server's extended blob auditing policy. + + Create or Update a workspace managed sql server's extended blob auditing policy. + + :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 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: ~azure.mgmt.synapse.models.ExtendedServerBlobAuditingPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.ExtendedServerBlobAuditingPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + blob_auditing_policy_name: Union[str, "_models.BlobAuditingPolicyName"], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ExtendedServerBlobAuditingPolicy]: + """Create or Update server's extended blob auditing policy. + + Create or Update a workspace managed sql server's extended blob auditing policy. + :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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.ExtendedServerBlobAuditingPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -175,24 +286,26 @@ async def begin_create_or_update( resource_group_name: str, workspace_name: str, blob_auditing_policy_name: Union[str, "_models.BlobAuditingPolicyName"], - parameters: "_models.ExtendedServerBlobAuditingPolicy", + parameters: Union[_models.ExtendedServerBlobAuditingPolicy, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ExtendedServerBlobAuditingPolicy"]: + ) -> AsyncLROPoller[_models.ExtendedServerBlobAuditingPolicy]: """Create or Update server's extended blob auditing policy. Create or Update a workspace managed sql server's extended blob auditing policy. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param blob_auditing_policy_name: The name of the blob auditing policy. + :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. - :type parameters: ~azure.mgmt.synapse.models.ExtendedServerBlobAuditingPolicy - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 @@ -205,108 +318,108 @@ async def begin_create_or_update( the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.ExtendedServerBlobAuditingPolicy] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtendedServerBlobAuditingPolicy"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ExtendedServerBlobAuditingPolicy] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, blob_auditing_policy_name=blob_auditing_policy_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ExtendedServerBlobAuditingPolicy', pipeline_response) + deserialized = self._deserialize("ExtendedServerBlobAuditingPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/extendedAuditingSettings/{blobAuditingPolicyName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/extendedAuditingSettings/{blobAuditingPolicyName}"} # type: ignore @distributed_trace def list_by_workspace( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ExtendedServerBlobAuditingPolicyListResult"]: + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ExtendedServerBlobAuditingPolicy"]: """List server's extended blob auditing policies. List workspace managed sql server's extended blob auditing policies. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExtendedServerBlobAuditingPolicyListResult or the - result of cls(response) + :return: An iterator like instance of either ExtendedServerBlobAuditingPolicy or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.ExtendedServerBlobAuditingPolicyListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.ExtendedServerBlobAuditingPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ExtendedServerBlobAuditingPolicyListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtendedServerBlobAuditingPolicyListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore else: - - request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -320,10 +433,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -333,8 +444,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_workspace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/extendedAuditingSettings"} # type: ignore + list_by_workspace.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/extendedAuditingSettings"} # type: ignore 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 fa82bfff920e..4386f0e04ee8 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 @@ -9,98 +9,103 @@ from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._workspace_managed_sql_server_recoverable_sql_pools_operations import build_get_request, build_list_request -T = TypeVar('T') +from ...operations._workspace_managed_sql_server_recoverable_sql_pools_operations import ( + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class WorkspaceManagedSqlServerRecoverableSqlPoolsOperations: - """WorkspaceManagedSqlServerRecoverableSqlPoolsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class WorkspaceManagedSqlServerRecoverableSqlPoolsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`workspace_managed_sql_server_recoverable_sql_pools` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.RecoverableSqlPoolListResult"]: + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.RecoverableSqlPool"]: """Get list of recoverable sql pools for the server. Get list of recoverable sql pools for workspace managed sql server. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RecoverableSqlPoolListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.RecoverableSqlPoolListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RecoverableSqlPoolListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecoverableSqlPoolListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -114,10 +119,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -127,75 +130,72 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/recoverableSqlPools"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/recoverableSqlPools"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> "_models.RecoverableSqlPool": + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> _models.RecoverableSqlPool: """Get recoverable sql pools for the server. Get recoverable sql pools for workspace managed sql server. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: The name of the sql pool. + :param sql_pool_name: The name of the sql pool. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RecoverableSqlPool, or the result of cls(response) + :return: RecoverableSqlPool or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.RecoverableSqlPool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecoverableSqlPool"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RecoverableSqlPool] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/recoverableSqlPools/{sqlPoolName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/recoverableSqlPools/{sqlPoolName}"} # 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 1e07c1135d97..c28cdc6bcf48 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 @@ -6,46 +6,57 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._workspace_managed_sql_server_security_alert_policy_operations import build_create_or_update_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._workspace_managed_sql_server_security_alert_policy_operations import ( + build_create_or_update_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class WorkspaceManagedSqlServerSecurityAlertPolicyOperations: - """WorkspaceManagedSqlServerSecurityAlertPolicyOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class WorkspaceManagedSqlServerSecurityAlertPolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`workspace_managed_sql_server_security_alert_policy` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( @@ -54,104 +65,121 @@ async def get( workspace_name: str, security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyNameAutoGenerated"], **kwargs: Any - ) -> "_models.ServerSecurityAlertPolicy": + ) -> _models.ServerSecurityAlertPolicy: """Get server's security alert policy. Get a workspace managed sql server's security alert policy. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param security_alert_policy_name: The name of the security alert policy. + :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 api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServerSecurityAlertPolicy, or the result of cls(response) + :return: ServerSecurityAlertPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ServerSecurityAlertPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerSecurityAlertPolicy"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServerSecurityAlertPolicy] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/securityAlertPolicies/{securityAlertPolicyName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/securityAlertPolicies/{securityAlertPolicyName}"} # 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: "_models.ServerSecurityAlertPolicy", + parameters: Union[_models.ServerSecurityAlertPolicy, IO], **kwargs: Any - ) -> Optional["_models.ServerSecurityAlertPolicy"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ServerSecurityAlertPolicy"]] + ) -> Optional[_models.ServerSecurityAlertPolicy]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ServerSecurityAlertPolicy') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ServerSecurityAlertPolicy]] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServerSecurityAlertPolicy") + + request = build_create_or_update_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, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -160,15 +188,100 @@ async def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ServerSecurityAlertPolicy', pipeline_response) + deserialized = self._deserialize("ServerSecurityAlertPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/securityAlertPolicies/{securityAlertPolicyName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/securityAlertPolicies/{securityAlertPolicyName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyNameAutoGenerated"], + parameters: _models.ServerSecurityAlertPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerSecurityAlertPolicy]: + """Create or Update server's threat detection policy. + + Create or Update a workspace managed sql server's threat detection policy. + + :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 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. Required. + :type parameters: ~azure.mgmt.synapse.models.ServerSecurityAlertPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.ServerSecurityAlertPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyNameAutoGenerated"], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ServerSecurityAlertPolicy]: + """Create or Update server's threat detection policy. + + Create or Update a workspace managed sql server's threat detection policy. + :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 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. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServerSecurityAlertPolicy or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.ServerSecurityAlertPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -176,25 +289,27 @@ async def begin_create_or_update( resource_group_name: str, workspace_name: str, security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyNameAutoGenerated"], - parameters: "_models.ServerSecurityAlertPolicy", + parameters: Union[_models.ServerSecurityAlertPolicy, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ServerSecurityAlertPolicy"]: + ) -> AsyncLROPoller[_models.ServerSecurityAlertPolicy]: """Create or Update server's threat detection policy. Create or Update a workspace managed sql server's threat detection policy. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param security_alert_policy_name: The name of the security alert policy. + :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. - :type parameters: ~azure.mgmt.synapse.models.ServerSecurityAlertPolicy - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 @@ -207,108 +322,108 @@ async def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.ServerSecurityAlertPolicy] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerSecurityAlertPolicy"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServerSecurityAlertPolicy] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, security_alert_policy_name=security_alert_policy_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServerSecurityAlertPolicy', pipeline_response) + deserialized = self._deserialize("ServerSecurityAlertPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/securityAlertPolicies/{securityAlertPolicyName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/securityAlertPolicies/{securityAlertPolicyName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ServerSecurityAlertPolicyListResult"]: + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ServerSecurityAlertPolicy"]: """Get server's threat detection policies. Get workspace managed sql server's threat detection policies. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServerSecurityAlertPolicyListResult or the result - of cls(response) + :return: An iterator like instance of either ServerSecurityAlertPolicy or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.ServerSecurityAlertPolicyListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.ServerSecurityAlertPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServerSecurityAlertPolicyListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerSecurityAlertPolicyListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -322,10 +437,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -335,8 +448,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/securityAlertPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/securityAlertPolicies"} # type: ignore 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 fd1df6453b8e..3de48b183043 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 @@ -9,97 +9,99 @@ from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.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 -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class WorkspaceManagedSqlServerUsagesOperations: - """WorkspaceManagedSqlServerUsagesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class WorkspaceManagedSqlServerUsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`workspace_managed_sql_server_usages` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ServerUsageListResult"]: + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ServerUsage"]: """Get list of usages metric for the server. Get list of server usages metric for workspace managed sql server. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServerUsageListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.ServerUsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServerUsageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerUsageListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -113,10 +115,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -126,8 +126,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlUsages"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlUsages"} # type: ignore 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 e2f63f203b7f..8b7ea238070b 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 @@ -6,44 +6,56 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._workspace_managed_sql_server_vulnerability_assessments_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._workspace_managed_sql_server_vulnerability_assessments_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class WorkspaceManagedSqlServerVulnerabilityAssessmentsOperations: - """WorkspaceManagedSqlServerVulnerabilityAssessmentsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class WorkspaceManagedSqlServerVulnerabilityAssessmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`workspace_managed_sql_server_vulnerability_assessments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( @@ -52,66 +64,140 @@ async def get( workspace_name: str, vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], **kwargs: Any - ) -> "_models.ServerVulnerabilityAssessment": + ) -> _models.ServerVulnerabilityAssessment: """Get server's vulnerability assessment. Get workspace managed sql server's vulnerability assessment. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param vulnerability_assessment_name: The name of the vulnerability assessment. + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServerVulnerabilityAssessment, or the result of cls(response) + :return: ServerVulnerabilityAssessment or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ServerVulnerabilityAssessment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerVulnerabilityAssessment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServerVulnerabilityAssessment] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}"} # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + parameters: _models.ServerVulnerabilityAssessment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ServerVulnerabilityAssessment: + """Create or Update server's vulnerability assessment. + + Create or Update workspace managed sql server's vulnerability assessment. + + :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 vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. + :type vulnerability_assessment_name: str or + ~azure.mgmt.synapse.models.VulnerabilityAssessmentName + :param parameters: Properties for vulnerability assessment. Required. + :type parameters: ~azure.mgmt.synapse.models.ServerVulnerabilityAssessment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ServerVulnerabilityAssessment: + """Create or Update server's vulnerability assessment. + + Create or Update workspace managed sql server's vulnerability assessment. + :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 vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. + :type vulnerability_assessment_name: str or + ~azure.mgmt.synapse.models.VulnerabilityAssessmentName + :param parameters: Properties for vulnerability assessment. 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: ServerVulnerabilityAssessment or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.ServerVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update( @@ -119,59 +205,76 @@ async def create_or_update( resource_group_name: str, workspace_name: str, vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], - parameters: "_models.ServerVulnerabilityAssessment", + parameters: Union[_models.ServerVulnerabilityAssessment, IO], **kwargs: Any - ) -> "_models.ServerVulnerabilityAssessment": + ) -> _models.ServerVulnerabilityAssessment: """Create or Update server's vulnerability assessment. Create or Update workspace managed sql server's vulnerability assessment. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param vulnerability_assessment_name: The name of the vulnerability assessment. + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :param parameters: Properties for vulnerability assessment. - :type parameters: ~azure.mgmt.synapse.models.ServerVulnerabilityAssessment - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 - :return: ServerVulnerabilityAssessment, or the result of cls(response) + :return: ServerVulnerabilityAssessment or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ServerVulnerabilityAssessment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerVulnerabilityAssessment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServerVulnerabilityAssessment] - _json = self._serialize.body(parameters, 'ServerVulnerabilityAssessment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServerVulnerabilityAssessment") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, 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, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -179,18 +282,17 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServerVulnerabilityAssessment', pipeline_response) + deserialized = self._deserialize("ServerVulnerabilityAssessment", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ServerVulnerabilityAssessment', pipeline_response) + deserialized = self._deserialize("ServerVulnerabilityAssessment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -205,45 +307,50 @@ async def delete( # pylint: disable=inconsistent-return-statements Remove workspace managed sql server's vulnerability assessment. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param vulnerability_assessment_name: The name of the vulnerability assessment. + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -253,65 +360,61 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ServerVulnerabilityAssessmentListResult"]: + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ServerVulnerabilityAssessment"]: """Lists the vulnerability assessment policies associated with a server. Lists the vulnerability assessment policies associated with a workspace managed sql server. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServerVulnerabilityAssessmentListResult or the - result of cls(response) + :return: An iterator like instance of either ServerVulnerabilityAssessment or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.ServerVulnerabilityAssessmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.ServerVulnerabilityAssessment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServerVulnerabilityAssessmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerVulnerabilityAssessmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -325,10 +428,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -338,8 +439,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/vulnerabilityAssessments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/vulnerabilityAssessments"} # type: ignore 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 e3fdf8cdfde7..74c4323a7fbf 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 @@ -6,90 +6,100 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._workspace_sql_aad_admins_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request -T = TypeVar('T') +from ...operations._workspace_sql_aad_admins_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class WorkspaceSqlAadAdminsOperations: - """WorkspaceSqlAadAdminsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class WorkspaceSqlAadAdminsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`workspace_sql_aad_admins` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> "_models.WorkspaceAadAdminInfo": + async def get(self, resource_group_name: str, workspace_name: str, **kwargs: Any) -> _models.WorkspaceAadAdminInfo: """Gets a workspace SQL active directory admin. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: WorkspaceAadAdminInfo, or the result of cls(response) + :return: WorkspaceAadAdminInfo or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.WorkspaceAadAdminInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceAadAdminInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkspaceAadAdminInfo] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -97,90 +107,177 @@ async def get( 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlAdministrators/activeDirectory"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlAdministrators/activeDirectory"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, workspace_name: str, - aad_admin_info: "_models.WorkspaceAadAdminInfo", + aad_admin_info: Union[_models.WorkspaceAadAdminInfo, IO], **kwargs: Any - ) -> "_models.WorkspaceAadAdminInfo": - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceAadAdminInfo"] + ) -> _models.WorkspaceAadAdminInfo: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(aad_admin_info, 'WorkspaceAadAdminInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkspaceAadAdminInfo] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(aad_admin_info, (IO, bytes)): + _content = aad_admin_info + else: + _json = self._serialize.body(aad_admin_info, "WorkspaceAadAdminInfo") + + request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("WorkspaceAadAdminInfo", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('WorkspaceAadAdminInfo', pipeline_response) + deserialized = self._deserialize("WorkspaceAadAdminInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlAdministrators/activeDirectory"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlAdministrators/activeDirectory"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + aad_admin_info: _models.WorkspaceAadAdminInfo, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkspaceAadAdminInfo]: + """Creates or updates a workspace SQL active directory admin. + :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 aad_admin_info: Workspace active directory administrator properties. Required. + :type aad_admin_info: ~azure.mgmt.synapse.models.WorkspaceAadAdminInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + aad_admin_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkspaceAadAdminInfo]: + """Creates or updates a workspace SQL active directory admin. + + :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 aad_admin_info: Workspace active directory administrator properties. Required. + :type aad_admin_info: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either WorkspaceAadAdminInfo or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.WorkspaceAadAdminInfo] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, workspace_name: str, - aad_admin_info: "_models.WorkspaceAadAdminInfo", + aad_admin_info: Union[_models.WorkspaceAadAdminInfo, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.WorkspaceAadAdminInfo"]: + ) -> AsyncLROPoller[_models.WorkspaceAadAdminInfo]: """Creates or updates a workspace SQL active directory admin. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param aad_admin_info: Workspace active directory administrator properties. - :type aad_admin_info: ~azure.mgmt.synapse.models.WorkspaceAadAdminInfo - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 @@ -192,109 +289,110 @@ async def begin_create_or_update( :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] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceAadAdminInfo"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkspaceAadAdminInfo] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, aad_admin_info=aad_admin_info, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WorkspaceAadAdminInfo', pipeline_response) + deserialized = self._deserialize("WorkspaceAadAdminInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlAdministrators/activeDirectory"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlAdministrators/activeDirectory"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any + self, resource_group_name: str, workspace_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + 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'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlAdministrators/activeDirectory"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlAdministrators/activeDirectory"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, workspace_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes a workspace SQL active directory admin. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -305,41 +403,47 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlAdministrators/activeDirectory"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlAdministrators/activeDirectory"} # 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 7f68b2ff07d1..027330f96ae0 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 @@ -6,96 +6,105 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._workspaces_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._workspaces_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class WorkspacesOperations: - """WorkspacesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class WorkspacesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.aio.SynapseManagementClient`'s + :attr:`workspaces` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.WorkspaceInfoListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Workspace"]: """Returns a list of workspaces in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkspaceInfoListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.WorkspaceInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkspaceInfoListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceInfoListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -109,10 +118,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -123,57 +130,54 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> "_models.Workspace": + async def get(self, resource_group_name: str, workspace_name: str, **kwargs: Any) -> _models.Workspace: """Gets a workspace. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Workspace, or the result of cls(response) + :return: Workspace or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.Workspace - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Workspace"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Workspace] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -181,90 +185,177 @@ async def get( 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}"} # type: ignore async def _update_initial( self, resource_group_name: str, workspace_name: str, - workspace_patch_info: "_models.WorkspacePatchInfo", + workspace_patch_info: Union[_models.WorkspacePatchInfo, IO], **kwargs: Any - ) -> "_models.Workspace": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Workspace"] + ) -> _models.Workspace: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(workspace_patch_info, 'WorkspacePatchInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Workspace] - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workspace_patch_info, (IO, bytes)): + _content = workspace_patch_info + else: + _json = self._serialize.body(workspace_patch_info, "WorkspacePatchInfo") + + request = build_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("Workspace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Workspace', pipeline_response) + deserialized = self._deserialize("Workspace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + workspace_name: str, + workspace_patch_info: _models.WorkspacePatchInfo, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Workspace]: + """Updates a workspace. + + :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 workspace_patch_info: Workspace patch request properties. Required. + :type workspace_patch_info: ~azure.mgmt.synapse.models.WorkspacePatchInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + workspace_name: str, + workspace_patch_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Workspace]: + """Updates a workspace. + :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 workspace_patch_info: Workspace patch request properties. Required. + :type workspace_patch_info: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Workspace or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.Workspace] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( self, resource_group_name: str, workspace_name: str, - workspace_patch_info: "_models.WorkspacePatchInfo", + workspace_patch_info: Union[_models.WorkspacePatchInfo, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Workspace"]: + ) -> AsyncLROPoller[_models.Workspace]: """Updates a workspace. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param workspace_patch_info: Workspace patch request properties. - :type workspace_patch_info: ~azure.mgmt.synapse.models.WorkspacePatchInfo - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 @@ -276,125 +367,143 @@ async def begin_update( :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] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Workspace"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Workspace] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, workspace_patch_info=workspace_patch_info, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('Workspace', pipeline_response) + deserialized = self._deserialize("Workspace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}"} # type: ignore async def _create_or_update_initial( - self, - resource_group_name: str, - workspace_name: str, - workspace_info: "_models.Workspace", - **kwargs: Any - ) -> "_models.Workspace": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Workspace"] + self, resource_group_name: str, workspace_name: str, workspace_info: Union[_models.Workspace, IO], **kwargs: Any + ) -> _models.Workspace: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(workspace_info, 'Workspace') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Workspace] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workspace_info, (IO, bytes)): + _content = workspace_info + else: + _json = self._serialize.body(workspace_info, "Workspace") + + request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("Workspace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Workspace', pipeline_response) + deserialized = self._deserialize("Workspace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, workspace_name: str, - workspace_info: "_models.Workspace", + workspace_info: _models.Workspace, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.Workspace"]: + ) -> AsyncLROPoller[_models.Workspace]: """Creates or updates a workspace. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param workspace_info: Workspace create or update request properties. + :param workspace_info: Workspace create or update request properties. Required. :type workspace_info: ~azure.mgmt.synapse.models.Workspace - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -406,118 +515,188 @@ async def begin_create_or_update( :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] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Workspace"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + workspace_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Workspace]: + """Creates or updates a workspace. + + :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 workspace_info: Workspace create or update request properties. Required. + :type workspace_info: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Workspace or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.synapse.models.Workspace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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 + ) -> AsyncLROPoller[_models.Workspace]: + """Creates or updates a workspace. + + :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 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. + :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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Workspace] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, workspace_info=workspace_info, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('Workspace', pipeline_response) + deserialized = self._deserialize("Workspace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}"} # type: ignore async def _delete_initial( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> Optional[Any]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[Any]] + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> Optional[_models.Workspace]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.Workspace]] + + 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'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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('object', pipeline_response) + deserialized = self._deserialize("Workspace", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('object', pipeline_response) + deserialized = self._deserialize("Workspace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}"} # type: ignore @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> AsyncLROPoller[Any]: + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.Workspace]: """Deletes a workspace. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -526,94 +705,96 @@ async def begin_delete( :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either any or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[any] - :raises: ~azure.core.exceptions.HttpResponseError + :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] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Any] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Workspace] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('object', pipeline_response) + deserialized = self._deserialize("Workspace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.WorkspaceInfoListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Workspace"]: """Returns a list of workspaces in a subscription. - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkspaceInfoListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.synapse.models.WorkspaceInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkspaceInfoListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceInfoListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -627,10 +808,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -641,8 +820,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Synapse/workspaces"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Synapse/workspaces"} # type: ignore 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 855a3f8aa0e1..a43b4f035992 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 @@ -63,6 +63,7 @@ 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 @@ -260,428 +261,431 @@ from ._models_py3 import WorkspacePatchInfo from ._models_py3 import WorkspaceRepositoryConfiguration - -from ._synapse_management_client_enums import ( - AzureADOnlyAuthenticationName, - AzureScaleType, - BlobAuditingPolicyName, - BlobAuditingPolicyState, - BlobStorageEventType, - ClusterPrincipalRole, - ColumnDataType, - Compression, - ConfigurationType, - ConnectionPolicyName, - CreateMode, - CreatedByType, - DataConnectionKind, - DataFlowComputeType, - DataMaskingFunction, - DataMaskingRuleState, - DataMaskingState, - DataWarehouseUserActivityName, - DatabasePrincipalRole, - DayOfWeek, - DedicatedSQLMinimalTlsSettingsName, - DefaultPrincipalsModificationKind, - EncryptionProtectorName, - EventGridDataFormat, - EventHubDataFormat, - GeoBackupPolicyName, - GeoBackupPolicyState, - IntegrationRuntimeAuthKeyName, - IntegrationRuntimeAutoUpdate, - IntegrationRuntimeEdition, - IntegrationRuntimeEntityReferenceType, - IntegrationRuntimeInternalChannelEncryptionMode, - IntegrationRuntimeLicenseType, - IntegrationRuntimeSsisCatalogPricingTier, - IntegrationRuntimeState, - IntegrationRuntimeType, - IntegrationRuntimeUpdateResult, - IotHubDataFormat, - Kind, - LanguageExtensionName, - ManagedIdentitySqlControlSettingsModelPropertiesGrantSqlControlToManagedIdentityActualState, - ManagedIdentitySqlControlSettingsModelPropertiesGrantSqlControlToManagedIdentityDesiredState, - ManagedIntegrationRuntimeNodeStatus, - ManagementOperationState, - NodeSize, - NodeSizeFamily, - OperationStatus, - PrincipalType, - PrincipalsModificationKind, - ProvisioningState, - QueryAggregationFunction, - QueryExecutionType, - QueryMetricUnit, - QueryObservedMetricType, - Reason, - RecommendedSensitivityLabelUpdateKind, - ReplicationRole, - ReplicationState, - ResourceIdentityType, - ResourceProvisioningState, - RestorePointType, - SecurityAlertPolicyName, - SecurityAlertPolicyNameAutoGenerated, - SecurityAlertPolicyState, - SelfHostedIntegrationRuntimeNodeStatus, - SensitivityLabelRank, - SensitivityLabelSource, - SensitivityLabelUpdateKind, - ServerKeyType, - SkuName, - SkuSize, - SsisObjectMetadataType, - State, - StateValue, - StorageAccountType, - TransparentDataEncryptionName, - TransparentDataEncryptionStatus, - Type, - VulnerabilityAssessmentName, - VulnerabilityAssessmentPolicyBaselineName, - VulnerabilityAssessmentScanState, - VulnerabilityAssessmentScanTriggerType, - WorkspacePublicNetworkAccess, -) +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 ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'AttachedDatabaseConfiguration', - 'AttachedDatabaseConfigurationListResult', - 'AutoPauseProperties', - 'AutoScaleProperties', - 'AvailableRpOperation', - 'AvailableRpOperationDisplayInfo', - 'AzureADOnlyAuthentication', - 'AzureADOnlyAuthenticationListResult', - 'AzureCapacity', - 'AzureEntityResource', - 'AzureResourceSku', - 'AzureSku', - 'BigDataPoolPatchInfo', - 'BigDataPoolResourceInfo', - 'BigDataPoolResourceInfoListResult', - 'CheckNameAvailabilityRequest', - 'CheckNameAvailabilityResponse', - 'CheckNameResult', - 'ClusterPrincipalAssignment', - 'ClusterPrincipalAssignmentCheckNameRequest', - 'ClusterPrincipalAssignmentListResult', - 'CmdkeySetup', - 'ComponentSetup', - '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', - 'EventGridDataConnection', - 'EventHubDataConnection', - 'ExtendedServerBlobAuditingPolicy', - 'ExtendedServerBlobAuditingPolicyListResult', - 'ExtendedSqlPoolBlobAuditingPolicy', - 'ExtendedSqlPoolBlobAuditingPolicyListResult', - 'FollowerDatabaseDefinition', - 'FollowerDatabaseListResult', - 'GeoBackupPolicy', - 'GeoBackupPolicyListResult', - 'GetSsisObjectMetadataRequest', - 'IntegrationRuntime', - 'IntegrationRuntimeAuthKeys', - 'IntegrationRuntimeComputeProperties', - 'IntegrationRuntimeConnectionInfo', - 'IntegrationRuntimeCustomSetupScriptProperties', - 'IntegrationRuntimeDataFlowProperties', - 'IntegrationRuntimeDataProxyProperties', - 'IntegrationRuntimeListResponse', - 'IntegrationRuntimeMonitoringData', - 'IntegrationRuntimeNodeIpAddress', - 'IntegrationRuntimeNodeMonitoringData', - 'IntegrationRuntimeOutboundNetworkDependenciesCategoryEndpoint', - 'IntegrationRuntimeOutboundNetworkDependenciesEndpoint', - 'IntegrationRuntimeOutboundNetworkDependenciesEndpointDetails', - 'IntegrationRuntimeOutboundNetworkDependenciesEndpointsResponse', - 'IntegrationRuntimeRegenerateKeyParameters', - 'IntegrationRuntimeResource', - 'IntegrationRuntimeSsisCatalogInfo', - 'IntegrationRuntimeSsisProperties', - 'IntegrationRuntimeStatus', - 'IntegrationRuntimeStatusResponse', - 'IntegrationRuntimeVNetProperties', - 'IotHubDataConnection', - 'IpFirewallRuleInfo', - 'IpFirewallRuleInfoListResult', - 'IpFirewallRuleProperties', - 'KekIdentityProperties', - 'Key', - 'KeyInfoListResult', - 'KustoPool', - 'KustoPoolCheckNameRequest', - 'KustoPoolListResult', - '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', - 'PrivateEndpoint', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionForPrivateLinkHub', - 'PrivateEndpointConnectionForPrivateLinkHubBasic', - 'PrivateEndpointConnectionForPrivateLinkHubBasicAutoGenerated', - 'PrivateEndpointConnectionForPrivateLinkHubResourceCollectionResponse', - 'PrivateEndpointConnectionList', - 'PrivateEndpointConnectionProperties', - 'PrivateLinkHub', - 'PrivateLinkHubInfoListResult', - 'PrivateLinkHubPatchInfo', - 'PrivateLinkResource', - 'PrivateLinkResourceListResult', - 'PrivateLinkResourceProperties', - 'PrivateLinkServiceConnectionState', - 'ProxyResource', - 'PurviewConfiguration', - 'QueryInterval', - 'QueryMetric', - 'QueryStatistic', - 'ReadOnlyFollowingDatabase', - 'ReadWriteDatabase', - 'RecommendedSensitivityLabelUpdate', - 'RecommendedSensitivityLabelUpdateList', - 'RecoverableSqlPool', - 'RecoverableSqlPoolListResult', - 'ReplaceAllFirewallRulesOperationResponse', - 'ReplaceAllIpFirewallRulesRequest', - 'ReplicationLink', - 'ReplicationLinkListResult', - 'Resource', - 'ResourceMoveDefinition', - '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', - 'AzureADOnlyAuthenticationName', - 'AzureScaleType', - 'BlobAuditingPolicyName', - 'BlobAuditingPolicyState', - 'BlobStorageEventType', - 'ClusterPrincipalRole', - 'ColumnDataType', - 'Compression', - 'ConfigurationType', - 'ConnectionPolicyName', - 'CreateMode', - 'CreatedByType', - 'DataConnectionKind', - 'DataFlowComputeType', - 'DataMaskingFunction', - 'DataMaskingRuleState', - 'DataMaskingState', - 'DataWarehouseUserActivityName', - 'DatabasePrincipalRole', - 'DayOfWeek', - 'DedicatedSQLMinimalTlsSettingsName', - 'DefaultPrincipalsModificationKind', - 'EncryptionProtectorName', - 'EventGridDataFormat', - 'EventHubDataFormat', - 'GeoBackupPolicyName', - 'GeoBackupPolicyState', - 'IntegrationRuntimeAuthKeyName', - 'IntegrationRuntimeAutoUpdate', - 'IntegrationRuntimeEdition', - 'IntegrationRuntimeEntityReferenceType', - 'IntegrationRuntimeInternalChannelEncryptionMode', - 'IntegrationRuntimeLicenseType', - 'IntegrationRuntimeSsisCatalogPricingTier', - 'IntegrationRuntimeState', - 'IntegrationRuntimeType', - 'IntegrationRuntimeUpdateResult', - 'IotHubDataFormat', - 'Kind', - 'LanguageExtensionName', - 'ManagedIdentitySqlControlSettingsModelPropertiesGrantSqlControlToManagedIdentityActualState', - 'ManagedIdentitySqlControlSettingsModelPropertiesGrantSqlControlToManagedIdentityDesiredState', - 'ManagedIntegrationRuntimeNodeStatus', - 'ManagementOperationState', - 'NodeSize', - 'NodeSizeFamily', - 'OperationStatus', - 'PrincipalType', - 'PrincipalsModificationKind', - 'ProvisioningState', - 'QueryAggregationFunction', - 'QueryExecutionType', - 'QueryMetricUnit', - 'QueryObservedMetricType', - 'Reason', - 'RecommendedSensitivityLabelUpdateKind', - 'ReplicationRole', - 'ReplicationState', - 'ResourceIdentityType', - 'ResourceProvisioningState', - 'RestorePointType', - 'SecurityAlertPolicyName', - 'SecurityAlertPolicyNameAutoGenerated', - 'SecurityAlertPolicyState', - 'SelfHostedIntegrationRuntimeNodeStatus', - 'SensitivityLabelRank', - 'SensitivityLabelSource', - 'SensitivityLabelUpdateKind', - 'ServerKeyType', - 'SkuName', - 'SkuSize', - 'SsisObjectMetadataType', - 'State', - 'StateValue', - 'StorageAccountType', - 'TransparentDataEncryptionName', - 'TransparentDataEncryptionStatus', - 'Type', - 'VulnerabilityAssessmentName', - 'VulnerabilityAssessmentPolicyBaselineName', - 'VulnerabilityAssessmentScanState', - 'VulnerabilityAssessmentScanTriggerType', - 'WorkspacePublicNetworkAccess', + "AttachedDatabaseConfiguration", + "AttachedDatabaseConfigurationListResult", + "AutoPauseProperties", + "AutoScaleProperties", + "AvailableRpOperation", + "AvailableRpOperationDisplayInfo", + "AzureADOnlyAuthentication", + "AzureADOnlyAuthenticationListResult", + "AzureCapacity", + "AzureEntityResource", + "AzureResourceSku", + "AzureSku", + "BigDataPoolPatchInfo", + "BigDataPoolResourceInfo", + "BigDataPoolResourceInfoListResult", + "CheckNameAvailabilityRequest", + "CheckNameAvailabilityResponse", + "CheckNameResult", + "ClusterPrincipalAssignment", + "ClusterPrincipalAssignmentCheckNameRequest", + "ClusterPrincipalAssignmentListResult", + "CmdkeySetup", + "ComponentSetup", + "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", + "IntegrationRuntimeListResponse", + "IntegrationRuntimeMonitoringData", + "IntegrationRuntimeNodeIpAddress", + "IntegrationRuntimeNodeMonitoringData", + "IntegrationRuntimeOutboundNetworkDependenciesCategoryEndpoint", + "IntegrationRuntimeOutboundNetworkDependenciesEndpoint", + "IntegrationRuntimeOutboundNetworkDependenciesEndpointDetails", + "IntegrationRuntimeOutboundNetworkDependenciesEndpointsResponse", + "IntegrationRuntimeRegenerateKeyParameters", + "IntegrationRuntimeResource", + "IntegrationRuntimeSsisCatalogInfo", + "IntegrationRuntimeSsisProperties", + "IntegrationRuntimeStatus", + "IntegrationRuntimeStatusResponse", + "IntegrationRuntimeVNetProperties", + "IotHubDataConnection", + "IpFirewallRuleInfo", + "IpFirewallRuleInfoListResult", + "IpFirewallRuleProperties", + "KekIdentityProperties", + "Key", + "KeyInfoListResult", + "KustoPool", + "KustoPoolCheckNameRequest", + "KustoPoolListResult", + "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", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionForPrivateLinkHub", + "PrivateEndpointConnectionForPrivateLinkHubBasic", + "PrivateEndpointConnectionForPrivateLinkHubBasicAutoGenerated", + "PrivateEndpointConnectionForPrivateLinkHubResourceCollectionResponse", + "PrivateEndpointConnectionList", + "PrivateEndpointConnectionProperties", + "PrivateLinkHub", + "PrivateLinkHubInfoListResult", + "PrivateLinkHubPatchInfo", + "PrivateLinkResource", + "PrivateLinkResourceListResult", + "PrivateLinkResourceProperties", + "PrivateLinkServiceConnectionState", + "ProxyResource", + "PurviewConfiguration", + "QueryInterval", + "QueryMetric", + "QueryStatistic", + "ReadOnlyFollowingDatabase", + "ReadWriteDatabase", + "RecommendedSensitivityLabelUpdate", + "RecommendedSensitivityLabelUpdateList", + "RecoverableSqlPool", + "RecoverableSqlPoolListResult", + "ReplaceAllFirewallRulesOperationResponse", + "ReplaceAllIpFirewallRulesRequest", + "ReplicationLink", + "ReplicationLinkListResult", + "Resource", + "ResourceMoveDefinition", + "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", + "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", + "SelfHostedIntegrationRuntimeNodeStatus", + "SensitivityLabelRank", + "SensitivityLabelSource", + "SensitivityLabelUpdateKind", + "ServerKeyType", + "SkuName", + "SkuSize", + "SsisObjectMetadataType", + "State", + "StateValue", + "StorageAccountType", + "TransparentDataEncryptionName", + "TransparentDataEncryptionStatus", + "Type", + "VulnerabilityAssessmentName", + "VulnerabilityAssessmentPolicyBaselineName", + "VulnerabilityAssessmentScanState", + "VulnerabilityAssessmentScanTriggerType", + "WorkspacePublicNetworkAccess", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_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 57539614f993..b78454630af0 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,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,15 +8,22 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from .. import _serialization -from ._synapse_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """Common fields that are returned in the response for all Azure Resource Manager resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -31,24 +39,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -70,27 +74,23 @@ class ProxyResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) -class AttachedDatabaseConfiguration(ProxyResource): +class AttachedDatabaseConfiguration(ProxyResource): # pylint: disable=too-many-instance-attributes """Class representing an attached database configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -108,8 +108,8 @@ class AttachedDatabaseConfiguration(ProxyResource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.synapse.models.SystemData - :ivar provisioning_state: The provisioned state of the resource. Possible values include: - "Running", "Creating", "Deleting", "Succeeded", "Failed", "Moving", "Canceled". + :ivar provisioning_state: The provisioned state of the resource. Known values are: "Running", + "Creating", "Deleting", "Succeeded", "Failed", "Moving", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.synapse.models.ResourceProvisioningState :ivar database_name: The name of the database which you would like to attach, use * if you want to follow all current and future databases. @@ -120,8 +120,8 @@ class AttachedDatabaseConfiguration(ProxyResource): :ivar attached_database_names: The list of databases from the clusterResourceId which are currently attached to the kusto pool. :vartype attached_database_names: list[str] - :ivar default_principals_modification_kind: The default principals modification kind. Possible - values include: "Union", "Replace", "None". + :ivar default_principals_modification_kind: The default principals modification kind. Known + values are: "Union", "Replace", and "None". :vartype default_principals_modification_kind: str or ~azure.mgmt.synapse.models.DefaultPrincipalsModificationKind :ivar table_level_sharing_properties: Table level sharing specifications. @@ -129,26 +129,29 @@ class AttachedDatabaseConfiguration(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'attached_database_names': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "attached_database_names": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'database_name': {'key': 'properties.databaseName', 'type': 'str'}, - 'kusto_pool_resource_id': {'key': 'properties.clusterResourceId', 'type': 'str'}, - 'attached_database_names': {'key': 'properties.attachedDatabaseNames', 'type': '[str]'}, - 'default_principals_modification_kind': {'key': 'properties.defaultPrincipalsModificationKind', 'type': 'str'}, - 'table_level_sharing_properties': {'key': 'properties.tableLevelSharingProperties', 'type': 'TableLevelSharingProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "database_name": {"key": "properties.databaseName", "type": "str"}, + "kusto_pool_resource_id": {"key": "properties.clusterResourceId", "type": "str"}, + "attached_database_names": {"key": "properties.attachedDatabaseNames", "type": "[str]"}, + "default_principals_modification_kind": {"key": "properties.defaultPrincipalsModificationKind", "type": "str"}, + "table_level_sharing_properties": { + "key": "properties.tableLevelSharingProperties", + "type": "TableLevelSharingProperties", + }, } def __init__( @@ -157,8 +160,8 @@ def __init__( location: Optional[str] = None, database_name: Optional[str] = None, kusto_pool_resource_id: Optional[str] = None, - default_principals_modification_kind: Optional[Union[str, "DefaultPrincipalsModificationKind"]] = None, - table_level_sharing_properties: Optional["TableLevelSharingProperties"] = None, + default_principals_modification_kind: Optional[Union[str, "_models.DefaultPrincipalsModificationKind"]] = None, + table_level_sharing_properties: Optional["_models.TableLevelSharingProperties"] = None, **kwargs ): """ @@ -170,15 +173,15 @@ def __init__( :keyword kusto_pool_resource_id: The resource id of the kusto pool where the databases you would like to attach reside. :paramtype kusto_pool_resource_id: str - :keyword default_principals_modification_kind: The default principals modification kind. - Possible values include: "Union", "Replace", "None". + :keyword default_principals_modification_kind: The default principals modification kind. Known + values are: "Union", "Replace", and "None". :paramtype default_principals_modification_kind: str or ~azure.mgmt.synapse.models.DefaultPrincipalsModificationKind :keyword table_level_sharing_properties: Table level sharing specifications. :paramtype table_level_sharing_properties: ~azure.mgmt.synapse.models.TableLevelSharingProperties """ - super(AttachedDatabaseConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.system_data = None self.provisioning_state = None @@ -189,7 +192,7 @@ def __init__( self.table_level_sharing_properties = table_level_sharing_properties -class AttachedDatabaseConfigurationListResult(msrest.serialization.Model): +class AttachedDatabaseConfigurationListResult(_serialization.Model): """The list attached database configurations operation response. :ivar value: The list of attached database configurations. @@ -197,24 +200,19 @@ class AttachedDatabaseConfigurationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[AttachedDatabaseConfiguration]'}, + "value": {"key": "value", "type": "[AttachedDatabaseConfiguration]"}, } - def __init__( - self, - *, - value: Optional[List["AttachedDatabaseConfiguration"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.AttachedDatabaseConfiguration"]] = None, **kwargs): """ :keyword value: The list of attached database configurations. :paramtype value: list[~azure.mgmt.synapse.models.AttachedDatabaseConfiguration] """ - super(AttachedDatabaseConfigurationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class AutoPauseProperties(msrest.serialization.Model): +class AutoPauseProperties(_serialization.Model): """Auto-pausing properties of a Big Data pool powered by Apache Spark. :ivar delay_in_minutes: Number of minutes of idle time before the Big Data pool is @@ -225,17 +223,11 @@ class AutoPauseProperties(msrest.serialization.Model): """ _attribute_map = { - 'delay_in_minutes': {'key': 'delayInMinutes', 'type': 'int'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, + "delay_in_minutes": {"key": "delayInMinutes", "type": "int"}, + "enabled": {"key": "enabled", "type": "bool"}, } - def __init__( - self, - *, - delay_in_minutes: Optional[int] = None, - enabled: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, delay_in_minutes: Optional[int] = None, enabled: Optional[bool] = None, **kwargs): """ :keyword delay_in_minutes: Number of minutes of idle time before the Big Data pool is automatically paused. @@ -243,12 +235,12 @@ def __init__( :keyword enabled: Whether auto-pausing is enabled for the Big Data pool. :paramtype enabled: bool """ - super(AutoPauseProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.delay_in_minutes = delay_in_minutes self.enabled = enabled -class AutoScaleProperties(msrest.serialization.Model): +class AutoScaleProperties(_serialization.Model): """Auto-scaling properties of a Big Data pool powered by Apache Spark. :ivar min_node_count: The minimum number of nodes the Big Data pool can support. @@ -260,9 +252,9 @@ class AutoScaleProperties(msrest.serialization.Model): """ _attribute_map = { - 'min_node_count': {'key': 'minNodeCount', 'type': 'int'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'max_node_count': {'key': 'maxNodeCount', 'type': 'int'}, + "min_node_count": {"key": "minNodeCount", "type": "int"}, + "enabled": {"key": "enabled", "type": "bool"}, + "max_node_count": {"key": "maxNodeCount", "type": "int"}, } def __init__( @@ -281,13 +273,13 @@ def __init__( :keyword max_node_count: The maximum number of nodes the Big Data pool can support. :paramtype max_node_count: int """ - super(AutoScaleProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.min_node_count = min_node_count self.enabled = enabled self.max_node_count = max_node_count -class AvailableRpOperation(msrest.serialization.Model): +class AvailableRpOperation(_serialization.Model): """An operation that is available in this resource provider. :ivar display: Display properties of the operation. @@ -303,21 +295,24 @@ class AvailableRpOperation(msrest.serialization.Model): """ _attribute_map = { - 'display': {'key': 'display', 'type': 'AvailableRpOperationDisplayInfo'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'OperationMetaServiceSpecification'}, + "display": {"key": "display", "type": "AvailableRpOperationDisplayInfo"}, + "is_data_action": {"key": "isDataAction", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "origin": {"key": "origin", "type": "str"}, + "service_specification": { + "key": "properties.serviceSpecification", + "type": "OperationMetaServiceSpecification", + }, } def __init__( self, *, - display: Optional["AvailableRpOperationDisplayInfo"] = None, + display: Optional["_models.AvailableRpOperationDisplayInfo"] = None, is_data_action: Optional[str] = None, name: Optional[str] = None, origin: Optional[str] = None, - service_specification: Optional["OperationMetaServiceSpecification"] = None, + service_specification: Optional["_models.OperationMetaServiceSpecification"] = None, **kwargs ): """ @@ -332,7 +327,7 @@ def __init__( :keyword service_specification: Operation service specification. :paramtype service_specification: ~azure.mgmt.synapse.models.OperationMetaServiceSpecification """ - super(AvailableRpOperation, self).__init__(**kwargs) + super().__init__(**kwargs) self.display = display self.is_data_action = is_data_action self.name = name @@ -340,7 +335,7 @@ def __init__( self.service_specification = service_specification -class AvailableRpOperationDisplayInfo(msrest.serialization.Model): +class AvailableRpOperationDisplayInfo(_serialization.Model): """Description of an available operation. :ivar description: Operation description. @@ -354,10 +349,10 @@ class AvailableRpOperationDisplayInfo(msrest.serialization.Model): """ _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'provider': {'key': 'provider', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, + "description": {"key": "description", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "provider": {"key": "provider", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, } def __init__( @@ -379,7 +374,7 @@ def __init__( :keyword operation: Operation name. :paramtype operation: str """ - super(AvailableRpOperationDisplayInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.resource = resource self.provider = provider @@ -401,47 +396,42 @@ class AzureADOnlyAuthentication(ProxyResource): :vartype type: str :ivar azure_ad_only_authentication: Azure Active Directory only Authentication enabled. :vartype azure_ad_only_authentication: bool - :ivar state: property configuration state. Possible values include: "Consistent", - "InConsistent", "Updating". + :ivar state: property configuration state. Known values are: "Consistent", "InConsistent", and + "Updating". :vartype state: str or ~azure.mgmt.synapse.models.StateValue :ivar creation_date: property configuration date. :vartype creation_date: ~datetime.datetime """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'state': {'readonly': True}, - 'creation_date': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "state": {"readonly": True}, + "creation_date": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'azure_ad_only_authentication': {'key': 'properties.azureADOnlyAuthentication', 'type': 'bool'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "azure_ad_only_authentication": {"key": "properties.azureADOnlyAuthentication", "type": "bool"}, + "state": {"key": "properties.state", "type": "str"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, } - def __init__( - self, - *, - azure_ad_only_authentication: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, azure_ad_only_authentication: Optional[bool] = None, **kwargs): """ :keyword azure_ad_only_authentication: Azure Active Directory only Authentication enabled. :paramtype azure_ad_only_authentication: bool """ - super(AzureADOnlyAuthentication, self).__init__(**kwargs) + super().__init__(**kwargs) self.azure_ad_only_authentication = azure_ad_only_authentication self.state = None self.creation_date = None -class AzureADOnlyAuthenticationListResult(msrest.serialization.Model): +class AzureADOnlyAuthenticationListResult(_serialization.Model): """A list of active directory only authentications. Variables are only populated by the server, and will be ignored when sending a request. @@ -453,76 +443,65 @@ class AzureADOnlyAuthenticationListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[AzureADOnlyAuthentication]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[AzureADOnlyAuthentication]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(AzureADOnlyAuthenticationListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class AzureCapacity(msrest.serialization.Model): +class AzureCapacity(_serialization.Model): """Azure capacity definition. All required parameters must be populated in order to send to Azure. - :ivar scale_type: Required. Scale type. Possible values include: "automatic", "manual", "none". + :ivar scale_type: Scale type. Required. Known values are: "automatic", "manual", and "none". :vartype scale_type: str or ~azure.mgmt.synapse.models.AzureScaleType - :ivar minimum: Required. Minimum allowed capacity. + :ivar minimum: Minimum allowed capacity. Required. :vartype minimum: int - :ivar maximum: Required. Maximum allowed capacity. + :ivar maximum: Maximum allowed capacity. Required. :vartype maximum: int - :ivar default: Required. The default capacity that would be used. + :ivar default: The default capacity that would be used. Required. :vartype default: int """ _validation = { - 'scale_type': {'required': True}, - 'minimum': {'required': True}, - 'maximum': {'required': True}, - 'default': {'required': True}, + "scale_type": {"required": True}, + "minimum": {"required": True}, + "maximum": {"required": True}, + "default": {"required": True}, } _attribute_map = { - 'scale_type': {'key': 'scaleType', 'type': 'str'}, - 'minimum': {'key': 'minimum', 'type': 'int'}, - 'maximum': {'key': 'maximum', 'type': 'int'}, - 'default': {'key': 'default', 'type': 'int'}, + "scale_type": {"key": "scaleType", "type": "str"}, + "minimum": {"key": "minimum", "type": "int"}, + "maximum": {"key": "maximum", "type": "int"}, + "default": {"key": "default", "type": "int"}, } def __init__( - self, - *, - scale_type: Union[str, "AzureScaleType"], - minimum: int, - maximum: int, - default: int, - **kwargs + self, *, scale_type: Union[str, "_models.AzureScaleType"], minimum: int, maximum: int, default: int, **kwargs ): """ - :keyword scale_type: Required. Scale type. Possible values include: "automatic", "manual", - "none". + :keyword scale_type: Scale type. Required. Known values are: "automatic", "manual", and "none". :paramtype scale_type: str or ~azure.mgmt.synapse.models.AzureScaleType - :keyword minimum: Required. Minimum allowed capacity. + :keyword minimum: Minimum allowed capacity. Required. :paramtype minimum: int - :keyword maximum: Required. Maximum allowed capacity. + :keyword maximum: Maximum allowed capacity. Required. :paramtype maximum: int - :keyword default: Required. The default capacity that would be used. + :keyword default: The default capacity that would be used. Required. :paramtype default: int """ - super(AzureCapacity, self).__init__(**kwargs) + super().__init__(**kwargs) self.scale_type = scale_type self.minimum = minimum self.maximum = maximum @@ -547,30 +526,26 @@ class AzureEntityResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, + "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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(AzureEntityResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.etag = None -class AzureResourceSku(msrest.serialization.Model): +class AzureResourceSku(_serialization.Model): """Azure resource SKU definition. :ivar resource_type: Resource Namespace and Type. @@ -582,17 +557,17 @@ class AzureResourceSku(msrest.serialization.Model): """ _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'AzureSku'}, - 'capacity': {'key': 'capacity', 'type': 'AzureCapacity'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "sku": {"key": "sku", "type": "AzureSku"}, + "capacity": {"key": "capacity", "type": "AzureCapacity"}, } def __init__( self, *, resource_type: Optional[str] = None, - sku: Optional["AzureSku"] = None, - capacity: Optional["AzureCapacity"] = None, + sku: Optional["_models.AzureSku"] = None, + capacity: Optional["_models.AzureCapacity"] = None, **kwargs ): """ @@ -603,84 +578,78 @@ def __init__( :keyword capacity: The number of instances of the cluster. :paramtype capacity: ~azure.mgmt.synapse.models.AzureCapacity """ - super(AzureResourceSku, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource_type = resource_type self.sku = sku self.capacity = capacity -class AzureSku(msrest.serialization.Model): +class AzureSku(_serialization.Model): """Azure SKU definition. All required parameters must be populated in order to send to Azure. - :ivar name: Required. SKU name. Possible values include: "Compute optimized", "Storage - optimized". + :ivar name: SKU name. Required. Known values are: "Compute optimized" and "Storage optimized". :vartype name: str or ~azure.mgmt.synapse.models.SkuName :ivar capacity: The number of instances of the cluster. :vartype capacity: int - :ivar size: Required. SKU size. Possible values include: "Extra small", "Small", "Medium", + :ivar size: SKU size. Required. Known values are: "Extra small", "Small", "Medium", and "Large". :vartype size: str or ~azure.mgmt.synapse.models.SkuSize """ _validation = { - 'name': {'required': True}, - 'size': {'required': True}, + "name": {"required": True}, + "size": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, - 'size': {'key': 'size', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, + "size": {"key": "size", "type": "str"}, } def __init__( self, *, - name: Union[str, "SkuName"], - size: Union[str, "SkuSize"], + name: Union[str, "_models.SkuName"], + size: Union[str, "_models.SkuSize"], capacity: Optional[int] = None, **kwargs ): """ - :keyword name: Required. SKU name. Possible values include: "Compute optimized", "Storage + :keyword name: SKU name. Required. Known values are: "Compute optimized" and "Storage optimized". :paramtype name: str or ~azure.mgmt.synapse.models.SkuName :keyword capacity: The number of instances of the cluster. :paramtype capacity: int - :keyword size: Required. SKU size. Possible values include: "Extra small", "Small", "Medium", + :keyword size: SKU size. Required. Known values are: "Extra small", "Small", "Medium", and "Large". :paramtype size: str or ~azure.mgmt.synapse.models.SkuSize """ - super(AzureSku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.capacity = capacity self.size = size -class BigDataPoolPatchInfo(msrest.serialization.Model): +class BigDataPoolPatchInfo(_serialization.Model): """Properties patch for a Big Data pool. - :ivar tags: A set of tags. Updated tags for the Big Data pool. + :ivar tags: Updated tags for the Big Data pool. :vartype tags: dict[str, str] """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Updated tags for the Big Data pool. + :keyword tags: Updated tags for the Big Data pool. :paramtype tags: dict[str, str] """ - super(BigDataPoolPatchInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags @@ -699,46 +668,40 @@ class TrackedResource(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.location = location -class BigDataPoolResourceInfo(TrackedResource): +class BigDataPoolResourceInfo(TrackedResource): # pylint: disable=too-many-instance-attributes """A Big Data pool. Variables are only populated by the server, and will be ignored when sending a request. @@ -753,9 +716,9 @@ class BigDataPoolResourceInfo(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar provisioning_state: The state of the Big Data pool. :vartype provisioning_state: str @@ -767,6 +730,8 @@ class BigDataPoolResourceInfo(TrackedResource): :vartype auto_pause: ~azure.mgmt.synapse.models.AutoPauseProperties :ivar is_compute_isolation_enabled: Whether compute isolation is required or not. :vartype is_compute_isolation_enabled: bool + :ivar is_autotune_enabled: Whether autotune is required or not. + :vartype is_autotune_enabled: bool :ivar session_level_packages_enabled: Whether session level packages enabled. :vartype session_level_packages_enabled: bool :ivar cache_size: The cache size. @@ -787,78 +752,83 @@ class BigDataPoolResourceInfo(TrackedResource): :vartype spark_version: str :ivar default_spark_log_folder: The default folder where Spark logs will be written. :vartype default_spark_log_folder: str - :ivar node_size: The level of compute power that each node in the Big Data pool has. Possible - values include: "None", "Small", "Medium", "Large", "XLarge", "XXLarge", "XXXLarge". + :ivar node_size: The level of compute power that each node in the Big Data pool has. Known + values are: "None", "Small", "Medium", "Large", "XLarge", "XXLarge", and "XXXLarge". :vartype node_size: str or ~azure.mgmt.synapse.models.NodeSize - :ivar node_size_family: The kind of nodes that the Big Data pool provides. Possible values - include: "None", "MemoryOptimized", "HardwareAcceleratedFPGA", "HardwareAcceleratedGPU". + :ivar node_size_family: The kind of nodes that the Big Data pool provides. Known values are: + "None", "MemoryOptimized", "HardwareAcceleratedFPGA", and "HardwareAcceleratedGPU". :vartype node_size_family: str or ~azure.mgmt.synapse.models.NodeSizeFamily :ivar last_succeeded_timestamp: The time when the Big Data pool was updated successfully. :vartype last_succeeded_timestamp: ~datetime.datetime """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'creation_date': {'readonly': True}, - 'last_succeeded_timestamp': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'auto_scale': {'key': 'properties.autoScale', 'type': 'AutoScaleProperties'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'auto_pause': {'key': 'properties.autoPause', 'type': 'AutoPauseProperties'}, - 'is_compute_isolation_enabled': {'key': 'properties.isComputeIsolationEnabled', 'type': 'bool'}, - 'session_level_packages_enabled': {'key': 'properties.sessionLevelPackagesEnabled', 'type': 'bool'}, - 'cache_size': {'key': 'properties.cacheSize', 'type': 'int'}, - 'dynamic_executor_allocation': {'key': 'properties.dynamicExecutorAllocation', 'type': 'DynamicExecutorAllocation'}, - 'spark_events_folder': {'key': 'properties.sparkEventsFolder', 'type': 'str'}, - 'node_count': {'key': 'properties.nodeCount', 'type': 'int'}, - 'library_requirements': {'key': 'properties.libraryRequirements', 'type': 'LibraryRequirements'}, - 'custom_libraries': {'key': 'properties.customLibraries', 'type': '[LibraryInfo]'}, - 'spark_config_properties': {'key': 'properties.sparkConfigProperties', 'type': 'SparkConfigProperties'}, - 'spark_version': {'key': 'properties.sparkVersion', 'type': 'str'}, - 'default_spark_log_folder': {'key': 'properties.defaultSparkLogFolder', 'type': 'str'}, - 'node_size': {'key': 'properties.nodeSize', 'type': 'str'}, - 'node_size_family': {'key': 'properties.nodeSizeFamily', 'type': 'str'}, - 'last_succeeded_timestamp': {'key': 'properties.lastSucceededTimestamp', 'type': 'iso-8601'}, - } - - def __init__( + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "creation_date": {"readonly": True}, + "last_succeeded_timestamp": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "auto_scale": {"key": "properties.autoScale", "type": "AutoScaleProperties"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "auto_pause": {"key": "properties.autoPause", "type": "AutoPauseProperties"}, + "is_compute_isolation_enabled": {"key": "properties.isComputeIsolationEnabled", "type": "bool"}, + "is_autotune_enabled": {"key": "properties.isAutotuneEnabled", "type": "bool"}, + "session_level_packages_enabled": {"key": "properties.sessionLevelPackagesEnabled", "type": "bool"}, + "cache_size": {"key": "properties.cacheSize", "type": "int"}, + "dynamic_executor_allocation": { + "key": "properties.dynamicExecutorAllocation", + "type": "DynamicExecutorAllocation", + }, + "spark_events_folder": {"key": "properties.sparkEventsFolder", "type": "str"}, + "node_count": {"key": "properties.nodeCount", "type": "int"}, + "library_requirements": {"key": "properties.libraryRequirements", "type": "LibraryRequirements"}, + "custom_libraries": {"key": "properties.customLibraries", "type": "[LibraryInfo]"}, + "spark_config_properties": {"key": "properties.sparkConfigProperties", "type": "SparkConfigProperties"}, + "spark_version": {"key": "properties.sparkVersion", "type": "str"}, + "default_spark_log_folder": {"key": "properties.defaultSparkLogFolder", "type": "str"}, + "node_size": {"key": "properties.nodeSize", "type": "str"}, + "node_size_family": {"key": "properties.nodeSizeFamily", "type": "str"}, + "last_succeeded_timestamp": {"key": "properties.lastSucceededTimestamp", "type": "iso-8601"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, location: str, tags: Optional[Dict[str, str]] = None, provisioning_state: Optional[str] = None, - auto_scale: Optional["AutoScaleProperties"] = None, - auto_pause: Optional["AutoPauseProperties"] = None, + auto_scale: Optional["_models.AutoScaleProperties"] = None, + auto_pause: Optional["_models.AutoPauseProperties"] = None, is_compute_isolation_enabled: Optional[bool] = None, + is_autotune_enabled: Optional[bool] = None, session_level_packages_enabled: Optional[bool] = None, cache_size: Optional[int] = None, - dynamic_executor_allocation: Optional["DynamicExecutorAllocation"] = None, + dynamic_executor_allocation: Optional["_models.DynamicExecutorAllocation"] = None, spark_events_folder: Optional[str] = None, node_count: Optional[int] = None, - library_requirements: Optional["LibraryRequirements"] = None, - custom_libraries: Optional[List["LibraryInfo"]] = None, - spark_config_properties: Optional["SparkConfigProperties"] = None, + library_requirements: Optional["_models.LibraryRequirements"] = None, + custom_libraries: Optional[List["_models.LibraryInfo"]] = None, + spark_config_properties: Optional["_models.SparkConfigProperties"] = None, spark_version: Optional[str] = None, default_spark_log_folder: Optional[str] = None, - node_size: Optional[Union[str, "NodeSize"]] = None, - node_size_family: Optional[Union[str, "NodeSizeFamily"]] = None, + node_size: Optional[Union[str, "_models.NodeSize"]] = None, + node_size_family: Optional[Union[str, "_models.NodeSizeFamily"]] = None, **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str :keyword provisioning_state: The state of the Big Data pool. :paramtype provisioning_state: str @@ -868,6 +838,8 @@ def __init__( :paramtype auto_pause: ~azure.mgmt.synapse.models.AutoPauseProperties :keyword is_compute_isolation_enabled: Whether compute isolation is required or not. :paramtype is_compute_isolation_enabled: bool + :keyword is_autotune_enabled: Whether autotune is required or not. + :paramtype is_autotune_enabled: bool :keyword session_level_packages_enabled: Whether session level packages enabled. :paramtype session_level_packages_enabled: bool :keyword cache_size: The cache size. @@ -888,19 +860,20 @@ def __init__( :paramtype spark_version: str :keyword default_spark_log_folder: The default folder where Spark logs will be written. :paramtype default_spark_log_folder: str - :keyword node_size: The level of compute power that each node in the Big Data pool has. - Possible values include: "None", "Small", "Medium", "Large", "XLarge", "XXLarge", "XXXLarge". + :keyword node_size: The level of compute power that each node in the Big Data pool has. Known + values are: "None", "Small", "Medium", "Large", "XLarge", "XXLarge", and "XXXLarge". :paramtype node_size: str or ~azure.mgmt.synapse.models.NodeSize - :keyword node_size_family: The kind of nodes that the Big Data pool provides. Possible values - include: "None", "MemoryOptimized", "HardwareAcceleratedFPGA", "HardwareAcceleratedGPU". + :keyword node_size_family: The kind of nodes that the Big Data pool provides. Known values are: + "None", "MemoryOptimized", "HardwareAcceleratedFPGA", and "HardwareAcceleratedGPU". :paramtype node_size_family: str or ~azure.mgmt.synapse.models.NodeSizeFamily """ - super(BigDataPoolResourceInfo, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.provisioning_state = provisioning_state self.auto_scale = auto_scale self.creation_date = None self.auto_pause = auto_pause self.is_compute_isolation_enabled = is_compute_isolation_enabled + self.is_autotune_enabled = is_autotune_enabled self.session_level_packages_enabled = session_level_packages_enabled self.cache_size = cache_size self.dynamic_executor_allocation = dynamic_executor_allocation @@ -916,7 +889,7 @@ def __init__( self.last_succeeded_timestamp = None -class BigDataPoolResourceInfoListResult(msrest.serialization.Model): +class BigDataPoolResourceInfoListResult(_serialization.Model): """Collection of Big Data pool information. :ivar next_link: Link to the next page of results. @@ -926,15 +899,15 @@ class BigDataPoolResourceInfoListResult(msrest.serialization.Model): """ _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[BigDataPoolResourceInfo]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[BigDataPoolResourceInfo]"}, } def __init__( self, *, next_link: Optional[str] = None, - value: Optional[List["BigDataPoolResourceInfo"]] = None, + value: Optional[List["_models.BigDataPoolResourceInfo"]] = None, **kwargs ): """ @@ -943,12 +916,12 @@ def __init__( :keyword value: List of Big Data pools. :paramtype value: list[~azure.mgmt.synapse.models.BigDataPoolResourceInfo] """ - super(BigDataPoolResourceInfoListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.next_link = next_link self.value = value -class CheckNameAvailabilityRequest(msrest.serialization.Model): +class CheckNameAvailabilityRequest(_serialization.Model): """A request about whether a workspace name is available. :ivar name: Workspace name. @@ -958,29 +931,23 @@ class CheckNameAvailabilityRequest(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - type: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, type: Optional[str] = None, **kwargs): """ :keyword name: Workspace name. :paramtype name: str :keyword type: Type: workspace. :paramtype type: str """ - super(CheckNameAvailabilityRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.type = type -class CheckNameAvailabilityResponse(msrest.serialization.Model): +class CheckNameAvailabilityResponse(_serialization.Model): """A response saying whether the workspace name is available. :ivar message: Validation message. @@ -994,10 +961,10 @@ class CheckNameAvailabilityResponse(msrest.serialization.Model): """ _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'available': {'key': 'available', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "message": {"key": "message", "type": "str"}, + "available": {"key": "available", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "name": {"key": "name", "type": "str"}, } def __init__( @@ -1019,14 +986,14 @@ def __init__( :keyword name: Workspace name. :paramtype name: str """ - super(CheckNameAvailabilityResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.message = message self.available = available self.reason = reason self.name = name -class CheckNameResult(msrest.serialization.Model): +class CheckNameResult(_serialization.Model): """The result returned from a check name availability request. :ivar name_available: Specifies a Boolean value that indicates if the name is available. @@ -1036,16 +1003,16 @@ class CheckNameResult(msrest.serialization.Model): :ivar message: Message indicating an unavailable name due to a conflict, or a description of the naming rules that are violated. :vartype message: str - :ivar reason: Message providing the reason why the given name is invalid. Possible values - include: "Invalid", "AlreadyExists". + :ivar reason: Message providing the reason why the given name is invalid. Known values are: + "Invalid" and "AlreadyExists". :vartype reason: str or ~azure.mgmt.synapse.models.Reason """ _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "reason": {"key": "reason", "type": "str"}, } def __init__( @@ -1054,7 +1021,7 @@ def __init__( name_available: Optional[bool] = None, name: Optional[str] = None, message: Optional[str] = None, - reason: Optional[Union[str, "Reason"]] = None, + reason: Optional[Union[str, "_models.Reason"]] = None, **kwargs ): """ @@ -1065,18 +1032,18 @@ def __init__( :keyword message: Message indicating an unavailable name due to a conflict, or a description of the naming rules that are violated. :paramtype message: str - :keyword reason: Message providing the reason why the given name is invalid. Possible values - include: "Invalid", "AlreadyExists". + :keyword reason: Message providing the reason why the given name is invalid. Known values are: + "Invalid" and "AlreadyExists". :paramtype reason: str or ~azure.mgmt.synapse.models.Reason """ - super(CheckNameResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = name_available self.name = name self.message = message self.reason = reason -class ClusterPrincipalAssignment(ProxyResource): +class ClusterPrincipalAssignment(ProxyResource): # pylint: disable=too-many-instance-attributes """Class representing a cluster principal assignment. Variables are only populated by the server, and will be ignored when sending a request. @@ -1095,68 +1062,72 @@ class ClusterPrincipalAssignment(ProxyResource): :ivar principal_id: The principal ID assigned to the cluster principal. It can be a user email, application ID, or security group name. :vartype principal_id: str - :ivar role: Cluster principal role. Possible values include: "AllDatabasesAdmin", + :ivar role: Cluster principal role. Known values are: "AllDatabasesAdmin" and "AllDatabasesViewer". :vartype role: str or ~azure.mgmt.synapse.models.ClusterPrincipalRole :ivar tenant_id: The tenant id of the principal. :vartype tenant_id: str - :ivar principal_type: Principal type. Possible values include: "App", "Group", "User". + :ivar principal_type: Principal type. Known values are: "App", "Group", and "User". :vartype principal_type: str or ~azure.mgmt.synapse.models.PrincipalType :ivar tenant_name: The tenant name of the principal. :vartype tenant_name: str :ivar principal_name: The principal name. :vartype principal_name: str - :ivar provisioning_state: The provisioned state of the resource. Possible values include: - "Running", "Creating", "Deleting", "Succeeded", "Failed", "Moving", "Canceled". + :ivar provisioning_state: The provisioned state of the resource. Known values are: "Running", + "Creating", "Deleting", "Succeeded", "Failed", "Moving", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.synapse.models.ResourceProvisioningState + :ivar aad_object_id: The service principal object id in AAD (Azure active directory). + :vartype aad_object_id: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'tenant_name': {'readonly': True}, - 'principal_name': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "tenant_name": {"readonly": True}, + "principal_name": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "aad_object_id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'principal_id': {'key': 'properties.principalId', 'type': 'str'}, - 'role': {'key': 'properties.role', 'type': 'str'}, - 'tenant_id': {'key': 'properties.tenantId', 'type': 'str'}, - 'principal_type': {'key': 'properties.principalType', 'type': 'str'}, - 'tenant_name': {'key': 'properties.tenantName', 'type': 'str'}, - 'principal_name': {'key': 'properties.principalName', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "principal_id": {"key": "properties.principalId", "type": "str"}, + "role": {"key": "properties.role", "type": "str"}, + "tenant_id": {"key": "properties.tenantId", "type": "str"}, + "principal_type": {"key": "properties.principalType", "type": "str"}, + "tenant_name": {"key": "properties.tenantName", "type": "str"}, + "principal_name": {"key": "properties.principalName", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "aad_object_id": {"key": "properties.aadObjectId", "type": "str"}, } def __init__( self, *, principal_id: Optional[str] = None, - role: Optional[Union[str, "ClusterPrincipalRole"]] = None, + role: Optional[Union[str, "_models.ClusterPrincipalRole"]] = None, tenant_id: Optional[str] = None, - principal_type: Optional[Union[str, "PrincipalType"]] = None, + principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, **kwargs ): """ :keyword principal_id: The principal ID assigned to the cluster principal. It can be a user email, application ID, or security group name. :paramtype principal_id: str - :keyword role: Cluster principal role. Possible values include: "AllDatabasesAdmin", + :keyword role: Cluster principal role. Known values are: "AllDatabasesAdmin" and "AllDatabasesViewer". :paramtype role: str or ~azure.mgmt.synapse.models.ClusterPrincipalRole :keyword tenant_id: The tenant id of the principal. :paramtype tenant_id: str - :keyword principal_type: Principal type. Possible values include: "App", "Group", "User". + :keyword principal_type: Principal type. Known values are: "App", "Group", and "User". :paramtype principal_type: str or ~azure.mgmt.synapse.models.PrincipalType """ - super(ClusterPrincipalAssignment, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.principal_id = principal_id self.role = role @@ -1165,49 +1136,45 @@ def __init__( self.tenant_name = None self.principal_name = None self.provisioning_state = None + self.aad_object_id = None -class ClusterPrincipalAssignmentCheckNameRequest(msrest.serialization.Model): +class ClusterPrincipalAssignmentCheckNameRequest(_serialization.Model): """A principal assignment check name availability request. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Principal Assignment resource name. + :ivar name: Principal Assignment resource name. Required. :vartype name: str :ivar type: The type of resource, Microsoft.Synapse/workspaces/kustoPools/principalAssignments. - Has constant value: "Microsoft.Synapse/workspaces/kustoPools/principalAssignments". + Required. Default value is "Microsoft.Synapse/workspaces/kustoPools/principalAssignments". :vartype type: str """ _validation = { - 'name': {'required': True}, - 'type': {'required': True, 'constant': True}, + "name": {"required": True}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "Microsoft.Synapse/workspaces/kustoPools/principalAssignments" - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. Principal Assignment resource name. + :keyword name: Principal Assignment resource name. Required. :paramtype name: str """ - super(ClusterPrincipalAssignmentCheckNameRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class ClusterPrincipalAssignmentListResult(msrest.serialization.Model): +class ClusterPrincipalAssignmentListResult(_serialization.Model): """The list Kusto cluster principal assignments operation response. :ivar value: The list of Kusto cluster principal assignments. @@ -1215,54 +1182,49 @@ class ClusterPrincipalAssignmentListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ClusterPrincipalAssignment]'}, + "value": {"key": "value", "type": "[ClusterPrincipalAssignment]"}, } - def __init__( - self, - *, - value: Optional[List["ClusterPrincipalAssignment"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ClusterPrincipalAssignment"]] = None, **kwargs): """ :keyword value: The list of Kusto cluster principal assignments. :paramtype value: list[~azure.mgmt.synapse.models.ClusterPrincipalAssignment] """ - super(ClusterPrincipalAssignmentListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class CustomSetupBase(msrest.serialization.Model): +class CustomSetupBase(_serialization.Model): """The base definition of the custom setup. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: CmdkeySetup, ComponentSetup, EnvironmentVariableSetup. + 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. - :ivar type: Required. The type of custom setup.Constant filled by server. + :ivar type: The type of custom setup. Required. :vartype type: str """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, } _subtype_map = { - 'type': {'CmdkeySetup': 'CmdkeySetup', 'ComponentSetup': 'ComponentSetup', 'EnvironmentVariableSetup': 'EnvironmentVariableSetup'} + "type": { + "CmdkeySetup": "CmdkeySetup", + "ComponentSetup": "ComponentSetup", + "EnvironmentVariableSetup": "EnvironmentVariableSetup", + } } - def __init__( - self, - **kwargs - ): - """ - """ - super(CustomSetupBase, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None # type: Optional[str] @@ -1271,48 +1233,41 @@ class CmdkeySetup(CustomSetupBase): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of custom setup.Constant filled by server. + :ivar type: The type of custom setup. Required. :vartype type: str - :ivar target_name: Required. The server name of data source access. - :vartype target_name: any - :ivar user_name: Required. The user name of data source access. - :vartype user_name: any - :ivar password: Required. The password of data source access. + :ivar target_name: The server name of data source access. Required. + :vartype target_name: JSON + :ivar user_name: The user name of data source access. Required. + :vartype user_name: JSON + :ivar password: The password of data source access. Required. :vartype password: ~azure.mgmt.synapse.models.SecretBase """ _validation = { - 'type': {'required': True}, - 'target_name': {'required': True}, - 'user_name': {'required': True}, - 'password': {'required': True}, + "type": {"required": True}, + "target_name": {"required": True}, + "user_name": {"required": True}, + "password": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'target_name': {'key': 'typeProperties.targetName', 'type': 'object'}, - 'user_name': {'key': 'typeProperties.userName', 'type': 'object'}, - 'password': {'key': 'typeProperties.password', 'type': 'SecretBase'}, + "type": {"key": "type", "type": "str"}, + "target_name": {"key": "typeProperties.targetName", "type": "object"}, + "user_name": {"key": "typeProperties.userName", "type": "object"}, + "password": {"key": "typeProperties.password", "type": "SecretBase"}, } - def __init__( - self, - *, - target_name: Any, - user_name: Any, - password: "SecretBase", - **kwargs - ): + def __init__(self, *, target_name: JSON, user_name: JSON, password: "_models.SecretBase", **kwargs): """ - :keyword target_name: Required. The server name of data source access. - :paramtype target_name: any - :keyword user_name: Required. The user name of data source access. - :paramtype user_name: any - :keyword password: Required. The password of data source access. + :keyword target_name: The server name of data source access. Required. + :paramtype target_name: JSON + :keyword user_name: The user name of data source access. Required. + :paramtype user_name: JSON + :keyword password: The password of data source access. Required. :paramtype password: ~azure.mgmt.synapse.models.SecretBase """ - super(CmdkeySetup, self).__init__(**kwargs) - self.type = 'CmdkeySetup' # type: str + super().__init__(**kwargs) + self.type = "CmdkeySetup" # type: str self.target_name = target_name self.user_name = user_name self.password = password @@ -1323,76 +1278,65 @@ class ComponentSetup(CustomSetupBase): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of custom setup.Constant filled by server. + :ivar type: The type of custom setup. Required. :vartype type: str - :ivar component_name: Required. The name of the 3rd party component. + :ivar component_name: The name of the 3rd party component. Required. :vartype component_name: str :ivar license_key: The license key to activate the component. :vartype license_key: ~azure.mgmt.synapse.models.SecretBase """ _validation = { - 'type': {'required': True}, - 'component_name': {'required': True}, + "type": {"required": True}, + "component_name": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'component_name': {'key': 'typeProperties.componentName', 'type': 'str'}, - 'license_key': {'key': 'typeProperties.licenseKey', 'type': 'SecretBase'}, + "type": {"key": "type", "type": "str"}, + "component_name": {"key": "typeProperties.componentName", "type": "str"}, + "license_key": {"key": "typeProperties.licenseKey", "type": "SecretBase"}, } - def __init__( - self, - *, - component_name: str, - license_key: Optional["SecretBase"] = None, - **kwargs - ): + def __init__(self, *, component_name: str, license_key: Optional["_models.SecretBase"] = None, **kwargs): """ - :keyword component_name: Required. The name of the 3rd party component. + :keyword component_name: The name of the 3rd party component. Required. :paramtype component_name: str :keyword license_key: The license key to activate the component. :paramtype license_key: ~azure.mgmt.synapse.models.SecretBase """ - super(ComponentSetup, self).__init__(**kwargs) - self.type = 'ComponentSetup' # type: str + super().__init__(**kwargs) + self.type = "ComponentSetup" # type: str self.component_name = component_name self.license_key = license_key -class CreateSqlPoolRestorePointDefinition(msrest.serialization.Model): +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. - :ivar restore_point_label: Required. The restore point label to apply. + :ivar restore_point_label: The restore point label to apply. Required. :vartype restore_point_label: str """ _validation = { - 'restore_point_label': {'required': True}, + "restore_point_label": {"required": True}, } _attribute_map = { - 'restore_point_label': {'key': 'restorePointLabel', 'type': 'str'}, + "restore_point_label": {"key": "restorePointLabel", "type": "str"}, } - def __init__( - self, - *, - restore_point_label: str, - **kwargs - ): + def __init__(self, *, restore_point_label: str, **kwargs): """ - :keyword restore_point_label: Required. The restore point label to apply. + :keyword restore_point_label: The restore point label to apply. Required. :paramtype restore_point_label: str """ - super(CreateSqlPoolRestorePointDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.restore_point_label = restore_point_label -class CspWorkspaceAdminProperties(msrest.serialization.Model): +class CspWorkspaceAdminProperties(_serialization.Model): """Initial workspace AAD admin properties for a CSP subscription. :ivar initial_workspace_admin_object_id: AAD object ID of initial workspace admin. @@ -1400,24 +1344,19 @@ class CspWorkspaceAdminProperties(msrest.serialization.Model): """ _attribute_map = { - 'initial_workspace_admin_object_id': {'key': 'initialWorkspaceAdminObjectId', 'type': 'str'}, + "initial_workspace_admin_object_id": {"key": "initialWorkspaceAdminObjectId", "type": "str"}, } - def __init__( - self, - *, - initial_workspace_admin_object_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, initial_workspace_admin_object_id: Optional[str] = None, **kwargs): """ :keyword initial_workspace_admin_object_id: AAD object ID of initial workspace admin. :paramtype initial_workspace_admin_object_id: str """ - super(CspWorkspaceAdminProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.initial_workspace_admin_object_id = initial_workspace_admin_object_id -class CustomerManagedKeyDetails(msrest.serialization.Model): +class CustomerManagedKeyDetails(_serialization.Model): """Details of the customer managed key associated with the workspace. Variables are only populated by the server, and will be ignored when sending a request. @@ -1431,20 +1370,20 @@ class CustomerManagedKeyDetails(msrest.serialization.Model): """ _validation = { - 'status': {'readonly': True}, + "status": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'WorkspaceKeyDetails'}, - 'kek_identity': {'key': 'kekIdentity', 'type': 'KekIdentityProperties'}, + "status": {"key": "status", "type": "str"}, + "key": {"key": "key", "type": "WorkspaceKeyDetails"}, + "kek_identity": {"key": "kekIdentity", "type": "KekIdentityProperties"}, } def __init__( self, *, - key: Optional["WorkspaceKeyDetails"] = None, - kek_identity: Optional["KekIdentityProperties"] = None, + key: Optional["_models.WorkspaceKeyDetails"] = None, + kek_identity: Optional["_models.KekIdentityProperties"] = None, **kwargs ): """ @@ -1453,7 +1392,7 @@ def __init__( :keyword kek_identity: Key encryption key. :paramtype kek_identity: ~azure.mgmt.synapse.models.KekIdentityProperties """ - super(CustomerManagedKeyDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = None self.key = key self.kek_identity = kek_identity @@ -1462,8 +1401,8 @@ def __init__( class Database(ProxyResource): """Class representing a Kusto database. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: ReadOnlyFollowingDatabase, ReadWriteDatabase. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ReadOnlyFollowingDatabase, ReadWriteDatabase Variables are only populated by the server, and will be ignored when sending a request. @@ -1479,8 +1418,8 @@ class Database(ProxyResource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar kind: Required. Kind of the database.Constant filled by server. Possible values include: - "ReadWrite", "ReadOnlyFollowing". + :ivar kind: Kind of the database. Required. Known values are: "ReadWrite" and + "ReadOnlyFollowing". :vartype kind: str or ~azure.mgmt.synapse.models.Kind :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. @@ -1488,88 +1427,75 @@ class Database(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - _subtype_map = { - 'kind': {'ReadOnlyFollowing': 'ReadOnlyFollowingDatabase', 'ReadWrite': 'ReadWriteDatabase'} - } + _subtype_map = {"kind": {"ReadOnlyFollowing": "ReadOnlyFollowingDatabase", "ReadWrite": "ReadWriteDatabase"}} - def __init__( - self, - *, - location: Optional[str] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, **kwargs): """ :keyword location: Resource location. :paramtype location: str """ - super(Database, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location - self.kind = 'Database' # type: str + self.kind = None # type: Optional[str] self.system_data = None -class DatabaseCheckNameRequest(msrest.serialization.Model): +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. - :ivar name: Required. Resource name. + :ivar name: Resource name. Required. :vartype name: str - :ivar type: Required. The type of resource, for instance - Microsoft.Synapse/workspaces/kustoPools/databases. Possible values include: - "Microsoft.Synapse/workspaces/kustoPools/databases", + :ivar type: The type of resource, for instance + Microsoft.Synapse/workspaces/kustoPools/databases. Required. Known values are: + "Microsoft.Synapse/workspaces/kustoPools/databases" and "Microsoft.Synapse/workspaces/kustoPools/attachedDatabaseConfigurations". :vartype type: str or ~azure.mgmt.synapse.models.Type """ _validation = { - 'name': {'required': True}, - 'type': {'required': True}, + "name": {"required": True}, + "type": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - name: str, - type: Union[str, "Type"], - **kwargs - ): + def __init__(self, *, name: str, type: Union[str, "_models.Type"], **kwargs): """ - :keyword name: Required. Resource name. + :keyword name: Resource name. Required. :paramtype name: str - :keyword type: Required. The type of resource, for instance - Microsoft.Synapse/workspaces/kustoPools/databases. Possible values include: - "Microsoft.Synapse/workspaces/kustoPools/databases", + :keyword type: The type of resource, for instance + Microsoft.Synapse/workspaces/kustoPools/databases. Required. Known values are: + "Microsoft.Synapse/workspaces/kustoPools/databases" and "Microsoft.Synapse/workspaces/kustoPools/attachedDatabaseConfigurations". :paramtype type: str or ~azure.mgmt.synapse.models.Type """ - super(DatabaseCheckNameRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.type = type -class DatabaseListResult(msrest.serialization.Model): +class DatabaseListResult(_serialization.Model): """The list Kusto databases operation response. :ivar value: The list of Kusto databases. @@ -1577,24 +1503,19 @@ class DatabaseListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Database]'}, + "value": {"key": "value", "type": "[Database]"}, } - def __init__( - self, - *, - value: Optional[List["Database"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Database"]] = None, **kwargs): """ :keyword value: The list of Kusto databases. :paramtype value: list[~azure.mgmt.synapse.models.Database] """ - super(DatabaseListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class DatabasePrincipalAssignment(ProxyResource): +class DatabasePrincipalAssignment(ProxyResource): # pylint: disable=too-many-instance-attributes """Class representing a database principal assignment. Variables are only populated by the server, and will be ignored when sending a request. @@ -1613,68 +1534,72 @@ class DatabasePrincipalAssignment(ProxyResource): :ivar principal_id: The principal ID assigned to the database principal. It can be a user email, application ID, or security group name. :vartype principal_id: str - :ivar role: Database principal role. Possible values include: "Admin", "Ingestor", "Monitor", - "User", "UnrestrictedViewer", "Viewer". + :ivar role: Database principal role. Known values are: "Admin", "Ingestor", "Monitor", "User", + "UnrestrictedViewer", and "Viewer". :vartype role: str or ~azure.mgmt.synapse.models.DatabasePrincipalRole :ivar tenant_id: The tenant id of the principal. :vartype tenant_id: str - :ivar principal_type: Principal type. Possible values include: "App", "Group", "User". + :ivar principal_type: Principal type. Known values are: "App", "Group", and "User". :vartype principal_type: str or ~azure.mgmt.synapse.models.PrincipalType :ivar tenant_name: The tenant name of the principal. :vartype tenant_name: str :ivar principal_name: The principal name. :vartype principal_name: str - :ivar provisioning_state: The provisioned state of the resource. Possible values include: - "Running", "Creating", "Deleting", "Succeeded", "Failed", "Moving", "Canceled". + :ivar provisioning_state: The provisioned state of the resource. Known values are: "Running", + "Creating", "Deleting", "Succeeded", "Failed", "Moving", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.synapse.models.ResourceProvisioningState + :ivar aad_object_id: The service principal object id in AAD (Azure active directory). + :vartype aad_object_id: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'tenant_name': {'readonly': True}, - 'principal_name': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "tenant_name": {"readonly": True}, + "principal_name": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "aad_object_id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'principal_id': {'key': 'properties.principalId', 'type': 'str'}, - 'role': {'key': 'properties.role', 'type': 'str'}, - 'tenant_id': {'key': 'properties.tenantId', 'type': 'str'}, - 'principal_type': {'key': 'properties.principalType', 'type': 'str'}, - 'tenant_name': {'key': 'properties.tenantName', 'type': 'str'}, - 'principal_name': {'key': 'properties.principalName', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "principal_id": {"key": "properties.principalId", "type": "str"}, + "role": {"key": "properties.role", "type": "str"}, + "tenant_id": {"key": "properties.tenantId", "type": "str"}, + "principal_type": {"key": "properties.principalType", "type": "str"}, + "tenant_name": {"key": "properties.tenantName", "type": "str"}, + "principal_name": {"key": "properties.principalName", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "aad_object_id": {"key": "properties.aadObjectId", "type": "str"}, } def __init__( self, *, principal_id: Optional[str] = None, - role: Optional[Union[str, "DatabasePrincipalRole"]] = None, + role: Optional[Union[str, "_models.DatabasePrincipalRole"]] = None, tenant_id: Optional[str] = None, - principal_type: Optional[Union[str, "PrincipalType"]] = None, + principal_type: Optional[Union[str, "_models.PrincipalType"]] = None, **kwargs ): """ :keyword principal_id: The principal ID assigned to the database principal. It can be a user email, application ID, or security group name. :paramtype principal_id: str - :keyword role: Database principal role. Possible values include: "Admin", "Ingestor", - "Monitor", "User", "UnrestrictedViewer", "Viewer". + :keyword role: Database principal role. Known values are: "Admin", "Ingestor", "Monitor", + "User", "UnrestrictedViewer", and "Viewer". :paramtype role: str or ~azure.mgmt.synapse.models.DatabasePrincipalRole :keyword tenant_id: The tenant id of the principal. :paramtype tenant_id: str - :keyword principal_type: Principal type. Possible values include: "App", "Group", "User". + :keyword principal_type: Principal type. Known values are: "App", "Group", and "User". :paramtype principal_type: str or ~azure.mgmt.synapse.models.PrincipalType """ - super(DatabasePrincipalAssignment, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.principal_id = principal_id self.role = role @@ -1683,50 +1608,46 @@ def __init__( self.tenant_name = None self.principal_name = None self.provisioning_state = None + self.aad_object_id = None -class DatabasePrincipalAssignmentCheckNameRequest(msrest.serialization.Model): +class DatabasePrincipalAssignmentCheckNameRequest(_serialization.Model): """A principal assignment check name availability request. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Principal Assignment resource name. + :ivar name: Principal Assignment resource name. Required. :vartype name: str :ivar type: The type of resource, - Microsoft.Synapse/workspaces/kustoPools/databases/principalAssignments. Has constant value: - "Microsoft.Synapse/workspaces/kustoPools/databases/principalAssignments". + Microsoft.Synapse/workspaces/kustoPools/databases/principalAssignments. Required. Default value + is "Microsoft.Synapse/workspaces/kustoPools/databases/principalAssignments". :vartype type: str """ _validation = { - 'name': {'required': True}, - 'type': {'required': True, 'constant': True}, + "name": {"required": True}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "Microsoft.Synapse/workspaces/kustoPools/databases/principalAssignments" - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. Principal Assignment resource name. + :keyword name: Principal Assignment resource name. Required. :paramtype name: str """ - super(DatabasePrincipalAssignmentCheckNameRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class DatabasePrincipalAssignmentListResult(msrest.serialization.Model): +class DatabasePrincipalAssignmentListResult(_serialization.Model): """The list Kusto database principal assignments operation response. :ivar value: The list of Kusto database principal assignments. @@ -1734,24 +1655,19 @@ class DatabasePrincipalAssignmentListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[DatabasePrincipalAssignment]'}, + "value": {"key": "value", "type": "[DatabasePrincipalAssignment]"}, } - def __init__( - self, - *, - value: Optional[List["DatabasePrincipalAssignment"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DatabasePrincipalAssignment"]] = None, **kwargs): """ :keyword value: The list of Kusto database principal assignments. :paramtype value: list[~azure.mgmt.synapse.models.DatabasePrincipalAssignment] """ - super(DatabasePrincipalAssignmentListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class DatabaseStatistics(msrest.serialization.Model): +class DatabaseStatistics(_serialization.Model): """A class that contains database statistics information. :ivar size: The database size - the total size of compressed data and index in bytes. @@ -1759,28 +1675,23 @@ class DatabaseStatistics(msrest.serialization.Model): """ _attribute_map = { - 'size': {'key': 'size', 'type': 'float'}, + "size": {"key": "size", "type": "float"}, } - def __init__( - self, - *, - size: Optional[float] = None, - **kwargs - ): + def __init__(self, *, size: Optional[float] = None, **kwargs): """ :keyword size: The database size - the total size of compressed data and index in bytes. :paramtype size: float """ - super(DatabaseStatistics, self).__init__(**kwargs) + super().__init__(**kwargs) self.size = size class DataConnection(ProxyResource): """Class representing a data connection. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: EventGridDataConnection, EventHubDataConnection, IotHubDataConnection. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + EventGridDataConnection, EventHubDataConnection, IotHubDataConnection Variables are only populated by the server, and will be ignored when sending a request. @@ -1796,8 +1707,8 @@ class DataConnection(ProxyResource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar kind: Required. Kind of the endpoint for the data connection.Constant filled by server. - Possible values include: "EventHub", "EventGrid", "IotHub". + :ivar kind: Kind of the endpoint for the data connection. Required. Known values are: + "EventHub", "EventGrid", and "IotHub". :vartype kind: str or ~azure.mgmt.synapse.models.DataConnectionKind :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. @@ -1805,84 +1716,78 @@ class DataConnection(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } _subtype_map = { - 'kind': {'EventGrid': 'EventGridDataConnection', 'EventHub': 'EventHubDataConnection', 'IotHub': 'IotHubDataConnection'} + "kind": { + "EventGrid": "EventGridDataConnection", + "EventHub": "EventHubDataConnection", + "IotHub": "IotHubDataConnection", + } } - def __init__( - self, - *, - location: Optional[str] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, **kwargs): """ :keyword location: Resource location. :paramtype location: str """ - super(DataConnection, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location - self.kind = 'DataConnection' # type: str + self.kind = None # type: Optional[str] self.system_data = None -class DataConnectionCheckNameRequest(msrest.serialization.Model): +class DataConnectionCheckNameRequest(_serialization.Model): """A data connection check name availability request. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Data Connection name. + :ivar name: Data Connection name. Required. :vartype name: str :ivar type: The type of resource, - Microsoft.Synapse/workspaces/kustoPools/databases/dataConnections. Has constant value: + Microsoft.Synapse/workspaces/kustoPools/databases/dataConnections. Required. Default value is "Microsoft.Synapse/workspaces/kustoPools/databases/dataConnections". :vartype type: str """ _validation = { - 'name': {'required': True}, - 'type': {'required': True, 'constant': True}, + "name": {"required": True}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "Microsoft.Synapse/workspaces/kustoPools/databases/dataConnections" - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. Data Connection name. + :keyword name: Data Connection name. Required. :paramtype name: str """ - super(DataConnectionCheckNameRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class DataConnectionListResult(msrest.serialization.Model): +class DataConnectionListResult(_serialization.Model): """The list Kusto data connections operation response. :ivar value: The list of Kusto data connections. @@ -1890,24 +1795,19 @@ class DataConnectionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[DataConnection]'}, + "value": {"key": "value", "type": "[DataConnection]"}, } - def __init__( - self, - *, - value: Optional[List["DataConnection"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DataConnection"]] = None, **kwargs): """ :keyword value: The list of Kusto data connections. :paramtype value: list[~azure.mgmt.synapse.models.DataConnection] """ - super(DataConnectionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class DataConnectionValidation(msrest.serialization.Model): +class DataConnectionValidation(_serialization.Model): """Class representing an data connection validation. :ivar data_connection_name: The name of the data connection. @@ -1917,15 +1817,15 @@ class DataConnectionValidation(msrest.serialization.Model): """ _attribute_map = { - 'data_connection_name': {'key': 'dataConnectionName', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'DataConnection'}, + "data_connection_name": {"key": "dataConnectionName", "type": "str"}, + "properties": {"key": "properties", "type": "DataConnection"}, } def __init__( self, *, data_connection_name: Optional[str] = None, - properties: Optional["DataConnection"] = None, + properties: Optional["_models.DataConnection"] = None, **kwargs ): """ @@ -1934,12 +1834,12 @@ def __init__( :keyword properties: The data connection properties to validate. :paramtype properties: ~azure.mgmt.synapse.models.DataConnection """ - super(DataConnectionValidation, self).__init__(**kwargs) + super().__init__(**kwargs) self.data_connection_name = data_connection_name self.properties = properties -class DataConnectionValidationListResult(msrest.serialization.Model): +class DataConnectionValidationListResult(_serialization.Model): """The list Kusto data connection validation result. :ivar value: The list of Kusto data connection validation errors. @@ -1947,24 +1847,19 @@ class DataConnectionValidationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[DataConnectionValidationResult]'}, + "value": {"key": "value", "type": "[DataConnectionValidationResult]"}, } - def __init__( - self, - *, - value: Optional[List["DataConnectionValidationResult"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DataConnectionValidationResult"]] = None, **kwargs): """ :keyword value: The list of Kusto data connection validation errors. :paramtype value: list[~azure.mgmt.synapse.models.DataConnectionValidationResult] """ - super(DataConnectionValidationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class DataConnectionValidationResult(msrest.serialization.Model): +class DataConnectionValidationResult(_serialization.Model): """The result returned from a data connection validation request. :ivar error_message: A message which indicates a problem in data connection validation. @@ -1972,24 +1867,19 @@ class DataConnectionValidationResult(msrest.serialization.Model): """ _attribute_map = { - 'error_message': {'key': 'errorMessage', 'type': 'str'}, + "error_message": {"key": "errorMessage", "type": "str"}, } - def __init__( - self, - *, - error_message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, error_message: Optional[str] = None, **kwargs): """ :keyword error_message: A message which indicates a problem in data connection validation. :paramtype error_message: str """ - super(DataConnectionValidationResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.error_message = error_message -class DataLakeStorageAccountDetails(msrest.serialization.Model): +class DataLakeStorageAccountDetails(_serialization.Model): """Details of the data lake storage account associated with the workspace. :ivar account_url: Account URL. @@ -2004,10 +1894,10 @@ class DataLakeStorageAccountDetails(msrest.serialization.Model): """ _attribute_map = { - 'account_url': {'key': 'accountUrl', 'type': 'str'}, - 'filesystem': {'key': 'filesystem', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'create_managed_private_endpoint': {'key': 'createManagedPrivateEndpoint', 'type': 'bool'}, + "account_url": {"key": "accountUrl", "type": "str"}, + "filesystem": {"key": "filesystem", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "create_managed_private_endpoint": {"key": "createManagedPrivateEndpoint", "type": "bool"}, } def __init__( @@ -2030,7 +1920,7 @@ def __init__( account or not. :paramtype create_managed_private_endpoint: bool """ - super(DataLakeStorageAccountDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.account_url = account_url self.filesystem = filesystem self.resource_id = resource_id @@ -2056,8 +1946,8 @@ class DataMaskingPolicy(ProxyResource): :vartype kind: str :ivar managed_by: Fully qualified resource ID of the sql pool. :vartype managed_by: str - :ivar data_masking_state: The state of the data masking policy. Possible values include: - "Disabled", "Enabled". + :ivar data_masking_state: The state of the data masking policy. Known values are: "Disabled" + and "Enabled". :vartype data_masking_state: str or ~azure.mgmt.synapse.models.DataMaskingState :ivar exempt_principals: The list of the exempt principals. Specifies the semicolon-separated list of database users for which the data masking policy does not apply. The specified users @@ -2071,46 +1961,46 @@ class DataMaskingPolicy(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'kind': {'readonly': True}, - 'managed_by': {'readonly': True}, - 'application_principals': {'readonly': True}, - 'masking_level': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": True}, + "kind": {"readonly": True}, + "managed_by": {"readonly": True}, + "application_principals": {"readonly": True}, + "masking_level": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'data_masking_state': {'key': 'properties.dataMaskingState', 'type': 'str'}, - 'exempt_principals': {'key': 'properties.exemptPrincipals', 'type': 'str'}, - 'application_principals': {'key': 'properties.applicationPrincipals', 'type': 'str'}, - 'masking_level': {'key': 'properties.maskingLevel', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "data_masking_state": {"key": "properties.dataMaskingState", "type": "str"}, + "exempt_principals": {"key": "properties.exemptPrincipals", "type": "str"}, + "application_principals": {"key": "properties.applicationPrincipals", "type": "str"}, + "masking_level": {"key": "properties.maskingLevel", "type": "str"}, } def __init__( self, *, - data_masking_state: Optional[Union[str, "DataMaskingState"]] = None, + data_masking_state: Optional[Union[str, "_models.DataMaskingState"]] = None, exempt_principals: Optional[str] = None, **kwargs ): """ - :keyword data_masking_state: The state of the data masking policy. Possible values include: - "Disabled", "Enabled". + :keyword data_masking_state: The state of the data masking policy. Known values are: "Disabled" + and "Enabled". :paramtype data_masking_state: str or ~azure.mgmt.synapse.models.DataMaskingState :keyword exempt_principals: The list of the exempt principals. Specifies the semicolon-separated list of database users for which the data masking policy does not apply. The specified users receive data results without masking for all of the database queries. :paramtype exempt_principals: str """ - super(DataMaskingPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = None self.kind = None self.managed_by = None @@ -2120,7 +2010,7 @@ def __init__( self.masking_level = None -class DataMaskingRule(ProxyResource): +class DataMaskingRule(ProxyResource): # pylint: disable=too-many-instance-attributes """Represents a Sql pool data masking rule. Variables are only populated by the server, and will be ignored when sending a request. @@ -2144,7 +2034,7 @@ class DataMaskingRule(ProxyResource): :ivar rule_state: The rule state. Used to delete a rule. To delete an existing rule, specify the schemaName, tableName, columnName, maskingFunction, and specify ruleState as disabled. However, if the rule doesn't already exist, the rule will be created with ruleState set to - enabled, regardless of the provided value of ruleState. Possible values include: "Disabled", + enabled, regardless of the provided value of ruleState. Known values are: "Disabled" and "Enabled". :vartype rule_state: str or ~azure.mgmt.synapse.models.DataMaskingRuleState :ivar schema_name: The schema name on which the data masking rule is applied. @@ -2153,8 +2043,8 @@ class DataMaskingRule(ProxyResource): :vartype table_name: str :ivar column_name: The column name on which the data masking rule is applied. :vartype column_name: str - :ivar masking_function: The masking function that is used for the data masking rule. Possible - values include: "Default", "CCN", "Email", "Number", "SSN", "Text". + :ivar masking_function: The masking function that is used for the data masking rule. Known + values are: "Default", "CCN", "Email", "Number", "SSN", and "Text". :vartype masking_function: str or ~azure.mgmt.synapse.models.DataMaskingFunction :ivar number_from: The numberFrom property of the masking rule. Required if maskingFunction is set to Number, otherwise this parameter will be ignored. @@ -2174,43 +2064,43 @@ class DataMaskingRule(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'kind': {'readonly': True}, - 'id_properties_id': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": True}, + "kind": {"readonly": True}, + "id_properties_id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'id_properties_id': {'key': 'properties.id', 'type': 'str'}, - 'alias_name': {'key': 'properties.aliasName', 'type': 'str'}, - 'rule_state': {'key': 'properties.ruleState', 'type': 'str'}, - 'schema_name': {'key': 'properties.schemaName', 'type': 'str'}, - 'table_name': {'key': 'properties.tableName', 'type': 'str'}, - 'column_name': {'key': 'properties.columnName', 'type': 'str'}, - 'masking_function': {'key': 'properties.maskingFunction', 'type': 'str'}, - 'number_from': {'key': 'properties.numberFrom', 'type': 'str'}, - 'number_to': {'key': 'properties.numberTo', 'type': 'str'}, - 'prefix_size': {'key': 'properties.prefixSize', 'type': 'str'}, - 'suffix_size': {'key': 'properties.suffixSize', 'type': 'str'}, - 'replacement_string': {'key': 'properties.replacementString', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "id_properties_id": {"key": "properties.id", "type": "str"}, + "alias_name": {"key": "properties.aliasName", "type": "str"}, + "rule_state": {"key": "properties.ruleState", "type": "str"}, + "schema_name": {"key": "properties.schemaName", "type": "str"}, + "table_name": {"key": "properties.tableName", "type": "str"}, + "column_name": {"key": "properties.columnName", "type": "str"}, + "masking_function": {"key": "properties.maskingFunction", "type": "str"}, + "number_from": {"key": "properties.numberFrom", "type": "str"}, + "number_to": {"key": "properties.numberTo", "type": "str"}, + "prefix_size": {"key": "properties.prefixSize", "type": "str"}, + "suffix_size": {"key": "properties.suffixSize", "type": "str"}, + "replacement_string": {"key": "properties.replacementString", "type": "str"}, } def __init__( self, *, alias_name: Optional[str] = None, - rule_state: Optional[Union[str, "DataMaskingRuleState"]] = None, + rule_state: Optional[Union[str, "_models.DataMaskingRuleState"]] = None, schema_name: Optional[str] = None, table_name: Optional[str] = None, column_name: Optional[str] = None, - masking_function: Optional[Union[str, "DataMaskingFunction"]] = None, + masking_function: Optional[Union[str, "_models.DataMaskingFunction"]] = None, number_from: Optional[str] = None, number_to: Optional[str] = None, prefix_size: Optional[str] = None, @@ -2224,7 +2114,7 @@ def __init__( :keyword rule_state: The rule state. Used to delete a rule. To delete an existing rule, specify the schemaName, tableName, columnName, maskingFunction, and specify ruleState as disabled. However, if the rule doesn't already exist, the rule will be created with ruleState set to - enabled, regardless of the provided value of ruleState. Possible values include: "Disabled", + enabled, regardless of the provided value of ruleState. Known values are: "Disabled" and "Enabled". :paramtype rule_state: str or ~azure.mgmt.synapse.models.DataMaskingRuleState :keyword schema_name: The schema name on which the data masking rule is applied. @@ -2233,8 +2123,8 @@ def __init__( :paramtype table_name: str :keyword column_name: The column name on which the data masking rule is applied. :paramtype column_name: str - :keyword masking_function: The masking function that is used for the data masking rule. - Possible values include: "Default", "CCN", "Email", "Number", "SSN", "Text". + :keyword masking_function: The masking function that is used for the data masking rule. Known + values are: "Default", "CCN", "Email", "Number", "SSN", and "Text". :paramtype masking_function: str or ~azure.mgmt.synapse.models.DataMaskingFunction :keyword number_from: The numberFrom property of the masking rule. Required if maskingFunction is set to Number, otherwise this parameter will be ignored. @@ -2252,7 +2142,7 @@ def __init__( masking the unexposed part of the string. Otherwise, this parameter will be ignored. :paramtype replacement_string: str """ - super(DataMaskingRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = None self.kind = None self.id_properties_id = None @@ -2269,7 +2159,7 @@ def __init__( self.replacement_string = replacement_string -class DataMaskingRuleListResult(msrest.serialization.Model): +class DataMaskingRuleListResult(_serialization.Model): """The response to a list data masking rules request. :ivar value: The list of Sql pool data masking rules. @@ -2277,20 +2167,15 @@ class DataMaskingRuleListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[DataMaskingRule]'}, + "value": {"key": "value", "type": "[DataMaskingRule]"}, } - def __init__( - self, - *, - value: Optional[List["DataMaskingRule"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DataMaskingRule"]] = None, **kwargs): """ :keyword value: The list of Sql pool data masking rules. :paramtype value: list[~azure.mgmt.synapse.models.DataMaskingRule] """ - super(DataMaskingRuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value @@ -2312,26 +2197,22 @@ class DataWarehouseUserActivities(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'active_queries_count': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "active_queries_count": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'active_queries_count': {'key': 'properties.activeQueriesCount', 'type': 'int'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "active_queries_count": {"key": "properties.activeQueriesCount", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(DataWarehouseUserActivities, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.active_queries_count = None @@ -2355,36 +2236,31 @@ class DedicatedSQLminimalTlsSettings(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'minimal_tls_version': {'key': 'properties.minimalTlsVersion', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "minimal_tls_version": {"key": "properties.minimalTlsVersion", "type": "str"}, } - def __init__( - self, - *, - minimal_tls_version: Optional[str] = None, - **kwargs - ): + def __init__(self, *, minimal_tls_version: Optional[str] = None, **kwargs): """ :keyword minimal_tls_version: The minimal tls version of the sql server. :paramtype minimal_tls_version: str """ - super(DedicatedSQLminimalTlsSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = None self.minimal_tls_version = minimal_tls_version -class DedicatedSQLminimalTlsSettingsListResult(msrest.serialization.Model): +class DedicatedSQLminimalTlsSettingsListResult(_serialization.Model): """A list of the server's dedicated sql minimal tls settings. Variables are only populated by the server, and will be ignored when sending a request. @@ -2396,27 +2272,23 @@ class DedicatedSQLminimalTlsSettingsListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DedicatedSQLminimalTlsSettings]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DedicatedSQLminimalTlsSettings]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(DedicatedSQLminimalTlsSettingsListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class DedicatedSQLminimalTlsSettingsPatchInfo(msrest.serialization.Model): +class DedicatedSQLminimalTlsSettingsPatchInfo(_serialization.Model): """Dedicated SQL minimal tls settings patch info. :ivar minimal_tls_version: minimal tls version. @@ -2424,24 +2296,19 @@ class DedicatedSQLminimalTlsSettingsPatchInfo(msrest.serialization.Model): """ _attribute_map = { - 'minimal_tls_version': {'key': 'minimalTlsVersion', 'type': 'str'}, + "minimal_tls_version": {"key": "minimalTlsVersion", "type": "str"}, } - def __init__( - self, - *, - minimal_tls_version: Optional[str] = None, - **kwargs - ): + def __init__(self, *, minimal_tls_version: Optional[str] = None, **kwargs): """ :keyword minimal_tls_version: minimal tls version. :paramtype minimal_tls_version: str """ - super(DedicatedSQLminimalTlsSettingsPatchInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.minimal_tls_version = minimal_tls_version -class DynamicExecutorAllocation(msrest.serialization.Model): +class DynamicExecutorAllocation(_serialization.Model): """Dynamic Executor Allocation Properties. :ivar enabled: Indicates whether Dynamic Executor Allocation is enabled or not. @@ -2453,9 +2320,9 @@ class DynamicExecutorAllocation(msrest.serialization.Model): """ _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'min_executors': {'key': 'minExecutors', 'type': 'int'}, - 'max_executors': {'key': 'maxExecutors', 'type': 'int'}, + "enabled": {"key": "enabled", "type": "bool"}, + "min_executors": {"key": "minExecutors", "type": "int"}, + "max_executors": {"key": "maxExecutors", "type": "int"}, } def __init__( @@ -2474,13 +2341,13 @@ def __init__( :keyword max_executors: The maximum number of executors alloted. :paramtype max_executors: int """ - super(DynamicExecutorAllocation, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.min_executors = min_executors self.max_executors = max_executors -class EncryptionDetails(msrest.serialization.Model): +class EncryptionDetails(_serialization.Model): """Details of the encryption associated with the workspace. Variables are only populated by the server, and will be ignored when sending a request. @@ -2492,25 +2359,20 @@ class EncryptionDetails(msrest.serialization.Model): """ _validation = { - 'double_encryption_enabled': {'readonly': True}, + "double_encryption_enabled": {"readonly": True}, } _attribute_map = { - 'double_encryption_enabled': {'key': 'doubleEncryptionEnabled', 'type': 'bool'}, - 'cmk': {'key': 'cmk', 'type': 'CustomerManagedKeyDetails'}, + "double_encryption_enabled": {"key": "doubleEncryptionEnabled", "type": "bool"}, + "cmk": {"key": "cmk", "type": "CustomerManagedKeyDetails"}, } - def __init__( - self, - *, - cmk: Optional["CustomerManagedKeyDetails"] = None, - **kwargs - ): + def __init__(self, *, cmk: Optional["_models.CustomerManagedKeyDetails"] = None, **kwargs): """ :keyword cmk: Customer Managed Key Details. :paramtype cmk: ~azure.mgmt.synapse.models.CustomerManagedKeyDetails """ - super(EncryptionDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.double_encryption_enabled = None self.cmk = cmk @@ -2538,7 +2400,7 @@ class EncryptionProtector(ProxyResource): :ivar server_key_name: The name of the server key. :vartype server_key_name: str :ivar server_key_type: The encryption protector type like 'ServiceManaged', 'AzureKeyVault'. - Possible values include: "ServiceManaged", "AzureKeyVault". + Known values are: "ServiceManaged" and "AzureKeyVault". :vartype server_key_type: str or ~azure.mgmt.synapse.models.ServerKeyType :ivar uri: The URI of the server key. :vartype uri: str @@ -2547,44 +2409,44 @@ class EncryptionProtector(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'readonly': True}, - 'location': {'readonly': True}, - 'subregion': {'readonly': True}, - 'uri': {'readonly': True}, - 'thumbprint': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"readonly": True}, + "location": {"readonly": True}, + "subregion": {"readonly": True}, + "uri": {"readonly": True}, + "thumbprint": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'subregion': {'key': 'properties.subregion', 'type': 'str'}, - 'server_key_name': {'key': 'properties.serverKeyName', 'type': 'str'}, - 'server_key_type': {'key': 'properties.serverKeyType', 'type': 'str'}, - 'uri': {'key': 'properties.uri', 'type': 'str'}, - 'thumbprint': {'key': 'properties.thumbprint', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "subregion": {"key": "properties.subregion", "type": "str"}, + "server_key_name": {"key": "properties.serverKeyName", "type": "str"}, + "server_key_type": {"key": "properties.serverKeyType", "type": "str"}, + "uri": {"key": "properties.uri", "type": "str"}, + "thumbprint": {"key": "properties.thumbprint", "type": "str"}, } def __init__( self, *, server_key_name: Optional[str] = None, - server_key_type: Optional[Union[str, "ServerKeyType"]] = None, + server_key_type: Optional[Union[str, "_models.ServerKeyType"]] = None, **kwargs ): """ :keyword server_key_name: The name of the server key. :paramtype server_key_name: str :keyword server_key_type: The encryption protector type like 'ServiceManaged', 'AzureKeyVault'. - Possible values include: "ServiceManaged", "AzureKeyVault". + Known values are: "ServiceManaged" and "AzureKeyVault". :paramtype server_key_type: str or ~azure.mgmt.synapse.models.ServerKeyType """ - super(EncryptionProtector, self).__init__(**kwargs) + super().__init__(**kwargs) self.kind = None self.location = None self.subregion = None @@ -2594,7 +2456,7 @@ def __init__( self.thumbprint = None -class EncryptionProtectorListResult(msrest.serialization.Model): +class EncryptionProtectorListResult(_serialization.Model): """A list of server encryption protectors. Variables are only populated by the server, and will be ignored when sending a request. @@ -2606,56 +2468,52 @@ class EncryptionProtectorListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[EncryptionProtector]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[EncryptionProtector]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(EncryptionProtectorListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class EntityReference(msrest.serialization.Model): +class EntityReference(_serialization.Model): """The entity reference. - :ivar type: The type of this referenced entity. Possible values include: - "IntegrationRuntimeReference", "LinkedServiceReference". + :ivar type: The type of this referenced entity. Known values are: "IntegrationRuntimeReference" + and "LinkedServiceReference". :vartype type: str or ~azure.mgmt.synapse.models.IntegrationRuntimeEntityReferenceType :ivar reference_name: The name of this referenced entity. :vartype reference_name: str """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'reference_name': {'key': 'referenceName', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "reference_name": {"key": "referenceName", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "IntegrationRuntimeEntityReferenceType"]] = None, + type: Optional[Union[str, "_models.IntegrationRuntimeEntityReferenceType"]] = None, reference_name: Optional[str] = None, **kwargs ): """ - :keyword type: The type of this referenced entity. Possible values include: - "IntegrationRuntimeReference", "LinkedServiceReference". + :keyword type: The type of this referenced entity. Known values are: + "IntegrationRuntimeReference" and "LinkedServiceReference". :paramtype type: str or ~azure.mgmt.synapse.models.IntegrationRuntimeEntityReferenceType :keyword reference_name: The name of this referenced entity. :paramtype reference_name: str """ - super(EntityReference, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.reference_name = reference_name @@ -2665,46 +2523,40 @@ class EnvironmentVariableSetup(CustomSetupBase): All required parameters must be populated in order to send to Azure. - :ivar type: Required. The type of custom setup.Constant filled by server. + :ivar type: The type of custom setup. Required. :vartype type: str - :ivar variable_name: Required. The name of the environment variable. + :ivar variable_name: The name of the environment variable. Required. :vartype variable_name: str - :ivar variable_value: Required. The value of the environment variable. + :ivar variable_value: The value of the environment variable. Required. :vartype variable_value: str """ _validation = { - 'type': {'required': True}, - 'variable_name': {'required': True}, - 'variable_value': {'required': True}, + "type": {"required": True}, + "variable_name": {"required": True}, + "variable_value": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'variable_name': {'key': 'typeProperties.variableName', 'type': 'str'}, - 'variable_value': {'key': 'typeProperties.variableValue', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "variable_name": {"key": "typeProperties.variableName", "type": "str"}, + "variable_value": {"key": "typeProperties.variableValue", "type": "str"}, } - def __init__( - self, - *, - variable_name: str, - variable_value: str, - **kwargs - ): + def __init__(self, *, variable_name: str, variable_value: str, **kwargs): """ - :keyword variable_name: Required. The name of the environment variable. + :keyword variable_name: The name of the environment variable. Required. :paramtype variable_name: str - :keyword variable_value: Required. The value of the environment variable. + :keyword variable_value: The value of the environment variable. Required. :paramtype variable_value: str """ - super(EnvironmentVariableSetup, self).__init__(**kwargs) - self.type = 'EnvironmentVariableSetup' # type: str + super().__init__(**kwargs) + self.type = "EnvironmentVariableSetup" # type: str self.variable_name = variable_name self.variable_value = variable_value -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -2712,31 +2564,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorDetail(msrest.serialization.Model): +class ErrorDetail(_serialization.Model): """The error detail. Variables are only populated by the server, and will be ignored when sending a request. @@ -2754,28 +2602,24 @@ class ErrorDetail(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDetail]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorDetail, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -2783,7 +2627,7 @@ def __init__( self.additional_info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). :ivar error: The error object. @@ -2791,24 +2635,62 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, + "error": {"key": "error", "type": "ErrorDetail"}, } - def __init__( - self, - *, - error: Optional["ErrorDetail"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs): """ :keyword error: The error object. :paramtype error: ~azure.mgmt.synapse.models.ErrorDetail """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class EventGridDataConnection(DataConnection): +class ErrorResponseAutoGenerated(_serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.synapse.models.ErrorResponseAutoGenerated] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.synapse.models.ErrorAdditionalInfo] + """ + + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorResponseAutoGenerated]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class EventGridDataConnection(DataConnection): # pylint: disable=too-many-instance-attributes """Class representing an Event Grid data connection. Variables are only populated by the server, and will be ignored when sending a request. @@ -2825,8 +2707,8 @@ class EventGridDataConnection(DataConnection): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar kind: Required. Kind of the endpoint for the data connection.Constant filled by server. - Possible values include: "EventHub", "EventGrid", "IotHub". + :ivar kind: Kind of the endpoint for the data connection. Required. Known values are: + "EventHub", "EventGrid", and "IotHub". :vartype kind: str or ~azure.mgmt.synapse.models.DataConnectionKind :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. @@ -2845,46 +2727,45 @@ class EventGridDataConnection(DataConnection): information can be added to each message. :vartype mapping_rule_name: str :ivar data_format: The data format of the message. Optionally the data format can be added to - each message. Possible values include: "MULTIJSON", "JSON", "CSV", "TSV", "SCSV", "SOHSV", - "PSV", "TXT", "RAW", "SINGLEJSON", "AVRO", "TSVE", "PARQUET", "ORC", "APACHEAVRO", - "W3CLOGFILE". + each message. Known values are: "MULTIJSON", "JSON", "CSV", "TSV", "SCSV", "SOHSV", "PSV", + "TXT", "RAW", "SINGLEJSON", "AVRO", "TSVE", "PARQUET", "ORC", "APACHEAVRO", and "W3CLOGFILE". :vartype data_format: str or ~azure.mgmt.synapse.models.EventGridDataFormat :ivar ignore_first_record: A Boolean value that, if set to true, indicates that ingestion should ignore the first record of every file. :vartype ignore_first_record: bool - :ivar blob_storage_event_type: The name of blob storage event type to process. Possible values - include: "Microsoft.Storage.BlobCreated", "Microsoft.Storage.BlobRenamed". + :ivar blob_storage_event_type: The name of blob storage event type to process. Known values + are: "Microsoft.Storage.BlobCreated" and "Microsoft.Storage.BlobRenamed". :vartype blob_storage_event_type: str or ~azure.mgmt.synapse.models.BlobStorageEventType - :ivar provisioning_state: The provisioned state of the resource. Possible values include: - "Running", "Creating", "Deleting", "Succeeded", "Failed", "Moving", "Canceled". + :ivar provisioning_state: The provisioned state of the resource. Known values are: "Running", + "Creating", "Deleting", "Succeeded", "Failed", "Moving", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.synapse.models.ResourceProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'storage_account_resource_id': {'key': 'properties.storageAccountResourceId', 'type': 'str'}, - 'event_hub_resource_id': {'key': 'properties.eventHubResourceId', 'type': 'str'}, - 'consumer_group': {'key': 'properties.consumerGroup', 'type': 'str'}, - 'table_name': {'key': 'properties.tableName', 'type': 'str'}, - 'mapping_rule_name': {'key': 'properties.mappingRuleName', 'type': 'str'}, - 'data_format': {'key': 'properties.dataFormat', 'type': 'str'}, - 'ignore_first_record': {'key': 'properties.ignoreFirstRecord', 'type': 'bool'}, - 'blob_storage_event_type': {'key': 'properties.blobStorageEventType', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "storage_account_resource_id": {"key": "properties.storageAccountResourceId", "type": "str"}, + "event_hub_resource_id": {"key": "properties.eventHubResourceId", "type": "str"}, + "consumer_group": {"key": "properties.consumerGroup", "type": "str"}, + "table_name": {"key": "properties.tableName", "type": "str"}, + "mapping_rule_name": {"key": "properties.mappingRuleName", "type": "str"}, + "data_format": {"key": "properties.dataFormat", "type": "str"}, + "ignore_first_record": {"key": "properties.ignoreFirstRecord", "type": "bool"}, + "blob_storage_event_type": {"key": "properties.blobStorageEventType", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -2896,9 +2777,9 @@ def __init__( consumer_group: Optional[str] = None, table_name: Optional[str] = None, mapping_rule_name: Optional[str] = None, - data_format: Optional[Union[str, "EventGridDataFormat"]] = None, + data_format: Optional[Union[str, "_models.EventGridDataFormat"]] = None, ignore_first_record: Optional[bool] = None, - blob_storage_event_type: Optional[Union[str, "BlobStorageEventType"]] = None, + blob_storage_event_type: Optional[Union[str, "_models.BlobStorageEventType"]] = None, **kwargs ): """ @@ -2919,19 +2800,18 @@ def __init__( mapping information can be added to each message. :paramtype mapping_rule_name: str :keyword data_format: The data format of the message. Optionally the data format can be added - to each message. Possible values include: "MULTIJSON", "JSON", "CSV", "TSV", "SCSV", "SOHSV", - "PSV", "TXT", "RAW", "SINGLEJSON", "AVRO", "TSVE", "PARQUET", "ORC", "APACHEAVRO", - "W3CLOGFILE". + to each message. Known values are: "MULTIJSON", "JSON", "CSV", "TSV", "SCSV", "SOHSV", "PSV", + "TXT", "RAW", "SINGLEJSON", "AVRO", "TSVE", "PARQUET", "ORC", "APACHEAVRO", and "W3CLOGFILE". :paramtype data_format: str or ~azure.mgmt.synapse.models.EventGridDataFormat :keyword ignore_first_record: A Boolean value that, if set to true, indicates that ingestion should ignore the first record of every file. :paramtype ignore_first_record: bool - :keyword blob_storage_event_type: The name of blob storage event type to process. Possible - values include: "Microsoft.Storage.BlobCreated", "Microsoft.Storage.BlobRenamed". + :keyword blob_storage_event_type: The name of blob storage event type to process. Known values + are: "Microsoft.Storage.BlobCreated" and "Microsoft.Storage.BlobRenamed". :paramtype blob_storage_event_type: str or ~azure.mgmt.synapse.models.BlobStorageEventType """ - super(EventGridDataConnection, self).__init__(location=location, **kwargs) - self.kind = 'EventGrid' # type: str + super().__init__(location=location, **kwargs) + self.kind = "EventGrid" # type: str self.storage_account_resource_id = storage_account_resource_id self.event_hub_resource_id = event_hub_resource_id self.consumer_group = consumer_group @@ -2943,7 +2823,7 @@ def __init__( self.provisioning_state = None -class EventHubDataConnection(DataConnection): +class EventHubDataConnection(DataConnection): # pylint: disable=too-many-instance-attributes """Class representing an event hub data connection. Variables are only populated by the server, and will be ignored when sending a request. @@ -2960,8 +2840,8 @@ class EventHubDataConnection(DataConnection): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar kind: Required. Kind of the endpoint for the data connection.Constant filled by server. - Possible values include: "EventHub", "EventGrid", "IotHub". + :ivar kind: Kind of the endpoint for the data connection. Required. Known values are: + "EventHub", "EventGrid", and "IotHub". :vartype kind: str or ~azure.mgmt.synapse.models.DataConnectionKind :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. @@ -2978,17 +2858,16 @@ class EventHubDataConnection(DataConnection): information can be added to each message. :vartype mapping_rule_name: str :ivar data_format: The data format of the message. Optionally the data format can be added to - each message. Possible values include: "MULTIJSON", "JSON", "CSV", "TSV", "SCSV", "SOHSV", - "PSV", "TXT", "RAW", "SINGLEJSON", "AVRO", "TSVE", "PARQUET", "ORC", "APACHEAVRO", - "W3CLOGFILE". + each message. Known values are: "MULTIJSON", "JSON", "CSV", "TSV", "SCSV", "SOHSV", "PSV", + "TXT", "RAW", "SINGLEJSON", "AVRO", "TSVE", "PARQUET", "ORC", "APACHEAVRO", and "W3CLOGFILE". :vartype data_format: str or ~azure.mgmt.synapse.models.EventHubDataFormat :ivar event_system_properties: System properties of the event hub. :vartype event_system_properties: list[str] - :ivar compression: The event hub messages compression type. Possible values include: "None", + :ivar compression: The event hub messages compression type. Known values are: "None" and "GZip". :vartype compression: str or ~azure.mgmt.synapse.models.Compression - :ivar provisioning_state: The provisioned state of the resource. Possible values include: - "Running", "Creating", "Deleting", "Succeeded", "Failed", "Moving", "Canceled". + :ivar provisioning_state: The provisioned state of the resource. Known values are: "Running", + "Creating", "Deleting", "Succeeded", "Failed", "Moving", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.synapse.models.ResourceProvisioningState :ivar managed_identity_resource_id: The resource ID of a managed identity (system or user assigned) to be used to authenticate with event hub. @@ -2996,30 +2875,30 @@ class EventHubDataConnection(DataConnection): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'event_hub_resource_id': {'key': 'properties.eventHubResourceId', 'type': 'str'}, - 'consumer_group': {'key': 'properties.consumerGroup', 'type': 'str'}, - 'table_name': {'key': 'properties.tableName', 'type': 'str'}, - 'mapping_rule_name': {'key': 'properties.mappingRuleName', 'type': 'str'}, - 'data_format': {'key': 'properties.dataFormat', 'type': 'str'}, - 'event_system_properties': {'key': 'properties.eventSystemProperties', 'type': '[str]'}, - 'compression': {'key': 'properties.compression', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'managed_identity_resource_id': {'key': 'properties.managedIdentityResourceId', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "event_hub_resource_id": {"key": "properties.eventHubResourceId", "type": "str"}, + "consumer_group": {"key": "properties.consumerGroup", "type": "str"}, + "table_name": {"key": "properties.tableName", "type": "str"}, + "mapping_rule_name": {"key": "properties.mappingRuleName", "type": "str"}, + "data_format": {"key": "properties.dataFormat", "type": "str"}, + "event_system_properties": {"key": "properties.eventSystemProperties", "type": "[str]"}, + "compression": {"key": "properties.compression", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "managed_identity_resource_id": {"key": "properties.managedIdentityResourceId", "type": "str"}, } def __init__( @@ -3030,9 +2909,9 @@ def __init__( consumer_group: Optional[str] = None, table_name: Optional[str] = None, mapping_rule_name: Optional[str] = None, - data_format: Optional[Union[str, "EventHubDataFormat"]] = None, + data_format: Optional[Union[str, "_models.EventHubDataFormat"]] = None, event_system_properties: Optional[List[str]] = None, - compression: Optional[Union[str, "Compression"]] = None, + compression: Optional[Union[str, "_models.Compression"]] = None, managed_identity_resource_id: Optional[str] = None, **kwargs ): @@ -3051,21 +2930,20 @@ def __init__( mapping information can be added to each message. :paramtype mapping_rule_name: str :keyword data_format: The data format of the message. Optionally the data format can be added - to each message. Possible values include: "MULTIJSON", "JSON", "CSV", "TSV", "SCSV", "SOHSV", - "PSV", "TXT", "RAW", "SINGLEJSON", "AVRO", "TSVE", "PARQUET", "ORC", "APACHEAVRO", - "W3CLOGFILE". + to each message. Known values are: "MULTIJSON", "JSON", "CSV", "TSV", "SCSV", "SOHSV", "PSV", + "TXT", "RAW", "SINGLEJSON", "AVRO", "TSVE", "PARQUET", "ORC", "APACHEAVRO", and "W3CLOGFILE". :paramtype data_format: str or ~azure.mgmt.synapse.models.EventHubDataFormat :keyword event_system_properties: System properties of the event hub. :paramtype event_system_properties: list[str] - :keyword compression: The event hub messages compression type. Possible values include: "None", + :keyword compression: The event hub messages compression type. Known values are: "None" and "GZip". :paramtype compression: str or ~azure.mgmt.synapse.models.Compression :keyword managed_identity_resource_id: The resource ID of a managed identity (system or user assigned) to be used to authenticate with event hub. :paramtype managed_identity_resource_id: str """ - super(EventHubDataConnection, self).__init__(location=location, **kwargs) - self.kind = 'EventHub' # type: str + super().__init__(location=location, **kwargs) + self.kind = "EventHub" # type: str self.event_hub_resource_id = event_hub_resource_id self.consumer_group = consumer_group self.table_name = table_name @@ -3077,7 +2955,7 @@ def __init__( self.managed_identity_resource_id = managed_identity_resource_id -class ExtendedServerBlobAuditingPolicy(ProxyResource): +class ExtendedServerBlobAuditingPolicy(ProxyResource): # pylint: disable=too-many-instance-attributes """An extended server blob auditing policy. Variables are only populated by the server, and will be ignored when sending a request. @@ -3093,7 +2971,7 @@ class ExtendedServerBlobAuditingPolicy(ProxyResource): :ivar predicate_expression: Specifies condition of where clause when creating an audit. :vartype predicate_expression: str :ivar state: Specifies the state of the policy. If state is Enabled, storageEndpoint or - isAzureMonitorTargetEnabled are required. Possible values include: "Enabled", "Disabled". + isAzureMonitorTargetEnabled are required. Known values are: "Enabled" and "Disabled". :vartype state: str or ~azure.mgmt.synapse.models.BlobAuditingPolicyState :ivar storage_endpoint: Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or @@ -3104,8 +2982,8 @@ class ExtendedServerBlobAuditingPolicy(ProxyResource): storageAccountAccessKey will use SQL server system-assigned managed identity to access the storage. Prerequisites for using managed identity authentication: - - + + #. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). #. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data Contributor' RBAC role to the server identity. @@ -3116,21 +2994,21 @@ class ExtendedServerBlobAuditingPolicy(ProxyResource): account. :vartype retention_days: int :ivar audit_actions_and_groups: Specifies the Actions-Groups and Actions to audit. - + The recommended set of action groups to use is the following combination - this will audit all the queries and stored procedures executed against the database, as well as successful and failed logins: - + BATCH_COMPLETED_GROUP, SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, FAILED_DATABASE_AUTHENTICATION_GROUP. - + This above combination is also the set that is configured by default when enabling auditing from the Azure portal. - + The supported action groups to audit are (note: choose only specific groups that cover your auditing needs. Using unnecessary groups could lead to very large quantities of audit records): - + APPLICATION_ROLE_CHANGE_PASSWORD_GROUP BACKUP_RESTORE_GROUP DATABASE_LOGOUT_GROUP @@ -3151,14 +3029,14 @@ class ExtendedServerBlobAuditingPolicy(ProxyResource): USER_CHANGE_PASSWORD_GROUP BATCH_STARTED_GROUP BATCH_COMPLETED_GROUP - + These are groups that cover all sql statements and stored procedures executed against the database, and should not be used in combination with other groups as this will result in duplicate audit logs. - + For more information, see `Database-Level Audit Action Groups `_. - + 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: SELECT @@ -3168,19 +3046,19 @@ class ExtendedServerBlobAuditingPolicy(ProxyResource): EXECUTE RECEIVE REFERENCES - + The general form for defining an action to be audited is: {action} ON {object} BY {principal} - + Note that :code:`` in the above format can refer to an object like a table, view, or stored procedure, or an entire database or schema. For the latter cases, the forms DATABASE::{db_name} and SCHEMA::{schema_name} are used, respectively. - + For example: SELECT on dbo.myTable by public SELECT on DATABASE::myDatabase by public SELECT on SCHEMA::mySchema by public - + For more information, see `Database-Level Audit Actions `_. :vartype audit_actions_and_groups: list[str] @@ -3193,15 +3071,15 @@ class ExtendedServerBlobAuditingPolicy(ProxyResource): Monitor. In order to send the events to Azure Monitor, specify 'state' as 'Enabled' and 'isAzureMonitorTargetEnabled' as true. - + When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' diagnostic logs category on the database should be also created. Note that for server level audit you should use the 'master' database as {databaseName}. - + 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 - + For more information, see `Diagnostic Settings REST API `_ or `Diagnostic Settings PowerShell `_. @@ -3214,14 +3092,14 @@ class ExtendedServerBlobAuditingPolicy(ProxyResource): logs will be sent to Azure Monitor. In order to send the events to Azure Monitor, specify 'State' as 'Enabled', 'IsAzureMonitorTargetEnabled' as true and 'IsDevopsAuditEnabled' as true - + When using REST API to configure auditing, Diagnostic Settings with 'DevOpsOperationsAudit' diagnostic logs category on the master database should also be created. - + 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 - + For more information, see `Diagnostic Settings REST API `_ or `Diagnostic Settings PowerShell `_. @@ -3229,33 +3107,33 @@ class ExtendedServerBlobAuditingPolicy(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'predicate_expression': {'key': 'properties.predicateExpression', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'storage_endpoint': {'key': 'properties.storageEndpoint', 'type': 'str'}, - 'storage_account_access_key': {'key': 'properties.storageAccountAccessKey', 'type': 'str'}, - 'retention_days': {'key': 'properties.retentionDays', 'type': 'int'}, - 'audit_actions_and_groups': {'key': 'properties.auditActionsAndGroups', 'type': '[str]'}, - 'storage_account_subscription_id': {'key': 'properties.storageAccountSubscriptionId', 'type': 'str'}, - 'is_storage_secondary_key_in_use': {'key': 'properties.isStorageSecondaryKeyInUse', 'type': 'bool'}, - 'is_azure_monitor_target_enabled': {'key': 'properties.isAzureMonitorTargetEnabled', 'type': 'bool'}, - 'queue_delay_ms': {'key': 'properties.queueDelayMs', 'type': 'int'}, - 'is_devops_audit_enabled': {'key': 'properties.isDevopsAuditEnabled', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "predicate_expression": {"key": "properties.predicateExpression", "type": "str"}, + "state": {"key": "properties.state", "type": "str"}, + "storage_endpoint": {"key": "properties.storageEndpoint", "type": "str"}, + "storage_account_access_key": {"key": "properties.storageAccountAccessKey", "type": "str"}, + "retention_days": {"key": "properties.retentionDays", "type": "int"}, + "audit_actions_and_groups": {"key": "properties.auditActionsAndGroups", "type": "[str]"}, + "storage_account_subscription_id": {"key": "properties.storageAccountSubscriptionId", "type": "str"}, + "is_storage_secondary_key_in_use": {"key": "properties.isStorageSecondaryKeyInUse", "type": "bool"}, + "is_azure_monitor_target_enabled": {"key": "properties.isAzureMonitorTargetEnabled", "type": "bool"}, + "queue_delay_ms": {"key": "properties.queueDelayMs", "type": "int"}, + "is_devops_audit_enabled": {"key": "properties.isDevopsAuditEnabled", "type": "bool"}, } def __init__( self, *, predicate_expression: Optional[str] = None, - state: Optional[Union[str, "BlobAuditingPolicyState"]] = None, + state: Optional[Union[str, "_models.BlobAuditingPolicyState"]] = None, storage_endpoint: Optional[str] = None, storage_account_access_key: Optional[str] = None, retention_days: Optional[int] = None, @@ -3271,7 +3149,7 @@ def __init__( :keyword predicate_expression: Specifies condition of where clause when creating an audit. :paramtype predicate_expression: str :keyword state: Specifies the state of the policy. If state is Enabled, storageEndpoint or - isAzureMonitorTargetEnabled are required. Possible values include: "Enabled", "Disabled". + isAzureMonitorTargetEnabled are required. Known values are: "Enabled" and "Disabled". :paramtype state: str or ~azure.mgmt.synapse.models.BlobAuditingPolicyState :keyword storage_endpoint: Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or @@ -3283,8 +3161,8 @@ def __init__( storageAccountAccessKey will use SQL server system-assigned managed identity to access the storage. Prerequisites for using managed identity authentication: - - + + #. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). #. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data Contributor' RBAC role to the server identity. @@ -3295,21 +3173,21 @@ def __init__( account. :paramtype retention_days: int :keyword audit_actions_and_groups: Specifies the Actions-Groups and Actions to audit. - + The recommended set of action groups to use is the following combination - this will audit all the queries and stored procedures executed against the database, as well as successful and failed logins: - + BATCH_COMPLETED_GROUP, SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, FAILED_DATABASE_AUTHENTICATION_GROUP. - + This above combination is also the set that is configured by default when enabling auditing from the Azure portal. - + The supported action groups to audit are (note: choose only specific groups that cover your auditing needs. Using unnecessary groups could lead to very large quantities of audit records): - + APPLICATION_ROLE_CHANGE_PASSWORD_GROUP BACKUP_RESTORE_GROUP DATABASE_LOGOUT_GROUP @@ -3330,14 +3208,14 @@ def __init__( USER_CHANGE_PASSWORD_GROUP BATCH_STARTED_GROUP BATCH_COMPLETED_GROUP - + These are groups that cover all sql statements and stored procedures executed against the database, and should not be used in combination with other groups as this will result in duplicate audit logs. - + For more information, see `Database-Level Audit Action Groups `_. - + 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: SELECT @@ -3347,19 +3225,19 @@ def __init__( EXECUTE RECEIVE REFERENCES - + The general form for defining an action to be audited is: {action} ON {object} BY {principal} - + Note that :code:`` in the above format can refer to an object like a table, view, or stored procedure, or an entire database or schema. For the latter cases, the forms DATABASE::{db_name} and SCHEMA::{schema_name} are used, respectively. - + For example: SELECT on dbo.myTable by public SELECT on DATABASE::myDatabase by public SELECT on SCHEMA::mySchema by public - + For more information, see `Database-Level Audit Actions `_. :paramtype audit_actions_and_groups: list[str] @@ -3372,15 +3250,15 @@ def __init__( Monitor. In order to send the events to Azure Monitor, specify 'state' as 'Enabled' and 'isAzureMonitorTargetEnabled' as true. - + When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' diagnostic logs category on the database should be also created. Note that for server level audit you should use the 'master' database as {databaseName}. - + 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 - + For more information, see `Diagnostic Settings REST API `_ or `Diagnostic Settings PowerShell `_. @@ -3393,20 +3271,20 @@ def __init__( devops logs will be sent to Azure Monitor. In order to send the events to Azure Monitor, specify 'State' as 'Enabled', 'IsAzureMonitorTargetEnabled' as true and 'IsDevopsAuditEnabled' as true - + When using REST API to configure auditing, Diagnostic Settings with 'DevOpsOperationsAudit' diagnostic logs category on the master database should also be created. - + 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 - + For more information, see `Diagnostic Settings REST API `_ or `Diagnostic Settings PowerShell `_. :paramtype is_devops_audit_enabled: bool """ - super(ExtendedServerBlobAuditingPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.predicate_expression = predicate_expression self.state = state self.storage_endpoint = storage_endpoint @@ -3420,7 +3298,7 @@ def __init__( self.is_devops_audit_enabled = is_devops_audit_enabled -class ExtendedServerBlobAuditingPolicyListResult(msrest.serialization.Model): +class ExtendedServerBlobAuditingPolicyListResult(_serialization.Model): """A list of server extended auditing settings. Variables are only populated by the server, and will be ignored when sending a request. @@ -3432,27 +3310,23 @@ class ExtendedServerBlobAuditingPolicyListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ExtendedServerBlobAuditingPolicy]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ExtendedServerBlobAuditingPolicy]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ExtendedServerBlobAuditingPolicyListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ExtendedSqlPoolBlobAuditingPolicy(ProxyResource): +class ExtendedSqlPoolBlobAuditingPolicy(ProxyResource): # pylint: disable=too-many-instance-attributes """An extended Sql pool blob auditing policy. Variables are only populated by the server, and will be ignored when sending a request. @@ -3468,7 +3342,7 @@ class ExtendedSqlPoolBlobAuditingPolicy(ProxyResource): :ivar predicate_expression: Specifies condition of where clause when creating an audit. :vartype predicate_expression: str :ivar state: Specifies the state of the policy. If state is Enabled, storageEndpoint or - isAzureMonitorTargetEnabled are required. Possible values include: "Enabled", "Disabled". + isAzureMonitorTargetEnabled are required. Known values are: "Enabled" and "Disabled". :vartype state: str or ~azure.mgmt.synapse.models.BlobAuditingPolicyState :ivar storage_endpoint: Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or @@ -3479,8 +3353,8 @@ class ExtendedSqlPoolBlobAuditingPolicy(ProxyResource): storageAccountAccessKey will use SQL server system-assigned managed identity to access the storage. Prerequisites for using managed identity authentication: - - + + #. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). #. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data Contributor' RBAC role to the server identity. @@ -3491,21 +3365,21 @@ class ExtendedSqlPoolBlobAuditingPolicy(ProxyResource): account. :vartype retention_days: int :ivar audit_actions_and_groups: Specifies the Actions-Groups and Actions to audit. - + The recommended set of action groups to use is the following combination - this will audit all the queries and stored procedures executed against the database, as well as successful and failed logins: - + BATCH_COMPLETED_GROUP, SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, FAILED_DATABASE_AUTHENTICATION_GROUP. - + This above combination is also the set that is configured by default when enabling auditing from the Azure portal. - + The supported action groups to audit are (note: choose only specific groups that cover your auditing needs. Using unnecessary groups could lead to very large quantities of audit records): - + APPLICATION_ROLE_CHANGE_PASSWORD_GROUP BACKUP_RESTORE_GROUP DATABASE_LOGOUT_GROUP @@ -3526,14 +3400,14 @@ class ExtendedSqlPoolBlobAuditingPolicy(ProxyResource): USER_CHANGE_PASSWORD_GROUP BATCH_STARTED_GROUP BATCH_COMPLETED_GROUP - + These are groups that cover all sql statements and stored procedures executed against the database, and should not be used in combination with other groups as this will result in duplicate audit logs. - + For more information, see `Database-Level Audit Action Groups `_. - + 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: SELECT @@ -3543,19 +3417,19 @@ class ExtendedSqlPoolBlobAuditingPolicy(ProxyResource): EXECUTE RECEIVE REFERENCES - + The general form for defining an action to be audited is: {action} ON {object} BY {principal} - + Note that :code:`` in the above format can refer to an object like a table, view, or stored procedure, or an entire database or schema. For the latter cases, the forms DATABASE::{db_name} and SCHEMA::{schema_name} are used, respectively. - + For example: SELECT on dbo.myTable by public SELECT on DATABASE::myDatabase by public SELECT on SCHEMA::mySchema by public - + For more information, see `Database-Level Audit Actions `_. :vartype audit_actions_and_groups: list[str] @@ -3568,15 +3442,15 @@ class ExtendedSqlPoolBlobAuditingPolicy(ProxyResource): Monitor. In order to send the events to Azure Monitor, specify 'state' as 'Enabled' and 'isAzureMonitorTargetEnabled' as true. - + When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' diagnostic logs category on the database should be also created. Note that for server level audit you should use the 'master' database as {databaseName}. - + 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 - + For more information, see `Diagnostic Settings REST API `_ or `Diagnostic Settings PowerShell `_. @@ -3588,32 +3462,32 @@ class ExtendedSqlPoolBlobAuditingPolicy(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'predicate_expression': {'key': 'properties.predicateExpression', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'storage_endpoint': {'key': 'properties.storageEndpoint', 'type': 'str'}, - 'storage_account_access_key': {'key': 'properties.storageAccountAccessKey', 'type': 'str'}, - 'retention_days': {'key': 'properties.retentionDays', 'type': 'int'}, - 'audit_actions_and_groups': {'key': 'properties.auditActionsAndGroups', 'type': '[str]'}, - 'storage_account_subscription_id': {'key': 'properties.storageAccountSubscriptionId', 'type': 'str'}, - 'is_storage_secondary_key_in_use': {'key': 'properties.isStorageSecondaryKeyInUse', 'type': 'bool'}, - 'is_azure_monitor_target_enabled': {'key': 'properties.isAzureMonitorTargetEnabled', 'type': 'bool'}, - 'queue_delay_ms': {'key': 'properties.queueDelayMs', 'type': 'int'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "predicate_expression": {"key": "properties.predicateExpression", "type": "str"}, + "state": {"key": "properties.state", "type": "str"}, + "storage_endpoint": {"key": "properties.storageEndpoint", "type": "str"}, + "storage_account_access_key": {"key": "properties.storageAccountAccessKey", "type": "str"}, + "retention_days": {"key": "properties.retentionDays", "type": "int"}, + "audit_actions_and_groups": {"key": "properties.auditActionsAndGroups", "type": "[str]"}, + "storage_account_subscription_id": {"key": "properties.storageAccountSubscriptionId", "type": "str"}, + "is_storage_secondary_key_in_use": {"key": "properties.isStorageSecondaryKeyInUse", "type": "bool"}, + "is_azure_monitor_target_enabled": {"key": "properties.isAzureMonitorTargetEnabled", "type": "bool"}, + "queue_delay_ms": {"key": "properties.queueDelayMs", "type": "int"}, } def __init__( self, *, predicate_expression: Optional[str] = None, - state: Optional[Union[str, "BlobAuditingPolicyState"]] = None, + state: Optional[Union[str, "_models.BlobAuditingPolicyState"]] = None, storage_endpoint: Optional[str] = None, storage_account_access_key: Optional[str] = None, retention_days: Optional[int] = None, @@ -3628,7 +3502,7 @@ def __init__( :keyword predicate_expression: Specifies condition of where clause when creating an audit. :paramtype predicate_expression: str :keyword state: Specifies the state of the policy. If state is Enabled, storageEndpoint or - isAzureMonitorTargetEnabled are required. Possible values include: "Enabled", "Disabled". + isAzureMonitorTargetEnabled are required. Known values are: "Enabled" and "Disabled". :paramtype state: str or ~azure.mgmt.synapse.models.BlobAuditingPolicyState :keyword storage_endpoint: Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or @@ -3640,8 +3514,8 @@ def __init__( storageAccountAccessKey will use SQL server system-assigned managed identity to access the storage. Prerequisites for using managed identity authentication: - - + + #. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). #. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data Contributor' RBAC role to the server identity. @@ -3652,21 +3526,21 @@ def __init__( account. :paramtype retention_days: int :keyword audit_actions_and_groups: Specifies the Actions-Groups and Actions to audit. - + The recommended set of action groups to use is the following combination - this will audit all the queries and stored procedures executed against the database, as well as successful and failed logins: - + BATCH_COMPLETED_GROUP, SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, FAILED_DATABASE_AUTHENTICATION_GROUP. - + This above combination is also the set that is configured by default when enabling auditing from the Azure portal. - + The supported action groups to audit are (note: choose only specific groups that cover your auditing needs. Using unnecessary groups could lead to very large quantities of audit records): - + APPLICATION_ROLE_CHANGE_PASSWORD_GROUP BACKUP_RESTORE_GROUP DATABASE_LOGOUT_GROUP @@ -3687,14 +3561,14 @@ def __init__( USER_CHANGE_PASSWORD_GROUP BATCH_STARTED_GROUP BATCH_COMPLETED_GROUP - + These are groups that cover all sql statements and stored procedures executed against the database, and should not be used in combination with other groups as this will result in duplicate audit logs. - + For more information, see `Database-Level Audit Action Groups `_. - + 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: SELECT @@ -3704,19 +3578,19 @@ def __init__( EXECUTE RECEIVE REFERENCES - + The general form for defining an action to be audited is: {action} ON {object} BY {principal} - + Note that :code:`` in the above format can refer to an object like a table, view, or stored procedure, or an entire database or schema. For the latter cases, the forms DATABASE::{db_name} and SCHEMA::{schema_name} are used, respectively. - + For example: SELECT on dbo.myTable by public SELECT on DATABASE::myDatabase by public SELECT on SCHEMA::mySchema by public - + For more information, see `Database-Level Audit Actions `_. :paramtype audit_actions_and_groups: list[str] @@ -3729,15 +3603,15 @@ def __init__( Monitor. In order to send the events to Azure Monitor, specify 'state' as 'Enabled' and 'isAzureMonitorTargetEnabled' as true. - + When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' diagnostic logs category on the database should be also created. Note that for server level audit you should use the 'master' database as {databaseName}. - + 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 - + For more information, see `Diagnostic Settings REST API `_ or `Diagnostic Settings PowerShell `_. @@ -3747,7 +3621,7 @@ def __init__( The default minimum value is 1000 (1 second). The maximum is 2,147,483,647. :paramtype queue_delay_ms: int """ - super(ExtendedSqlPoolBlobAuditingPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.predicate_expression = predicate_expression self.state = state self.storage_endpoint = storage_endpoint @@ -3760,7 +3634,7 @@ def __init__( self.queue_delay_ms = queue_delay_ms -class ExtendedSqlPoolBlobAuditingPolicyListResult(msrest.serialization.Model): +class ExtendedSqlPoolBlobAuditingPolicyListResult(_serialization.Model): """A list of sql pool extended auditing settings. Variables are only populated by the server, and will be ignored when sending a request. @@ -3772,38 +3646,34 @@ class ExtendedSqlPoolBlobAuditingPolicyListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ExtendedSqlPoolBlobAuditingPolicy]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ExtendedSqlPoolBlobAuditingPolicy]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ExtendedSqlPoolBlobAuditingPolicyListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class FollowerDatabaseDefinition(msrest.serialization.Model): +class FollowerDatabaseDefinition(_serialization.Model): """A class representing follower database request. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar kusto_pool_resource_id: Required. Resource id of the cluster that follows a database - owned by this cluster. + :ivar kusto_pool_resource_id: Resource id of the cluster that follows a database owned by this + cluster. Required. :vartype kusto_pool_resource_id: str - :ivar attached_database_configuration_name: Required. Resource name of the attached database - configuration in the follower cluster. + :ivar attached_database_configuration_name: Resource name of the attached database + configuration in the follower cluster. Required. :vartype attached_database_configuration_name: str :ivar database_name: The database name owned by this cluster that was followed. * in case following all databases. @@ -3811,39 +3681,33 @@ class FollowerDatabaseDefinition(msrest.serialization.Model): """ _validation = { - 'kusto_pool_resource_id': {'required': True}, - 'attached_database_configuration_name': {'required': True}, - 'database_name': {'readonly': True}, + "kusto_pool_resource_id": {"required": True}, + "attached_database_configuration_name": {"required": True}, + "database_name": {"readonly": True}, } _attribute_map = { - 'kusto_pool_resource_id': {'key': 'clusterResourceId', 'type': 'str'}, - 'attached_database_configuration_name': {'key': 'attachedDatabaseConfigurationName', 'type': 'str'}, - 'database_name': {'key': 'databaseName', 'type': 'str'}, + "kusto_pool_resource_id": {"key": "clusterResourceId", "type": "str"}, + "attached_database_configuration_name": {"key": "attachedDatabaseConfigurationName", "type": "str"}, + "database_name": {"key": "databaseName", "type": "str"}, } - def __init__( - self, - *, - kusto_pool_resource_id: str, - attached_database_configuration_name: str, - **kwargs - ): + def __init__(self, *, kusto_pool_resource_id: str, attached_database_configuration_name: str, **kwargs): """ - :keyword kusto_pool_resource_id: Required. Resource id of the cluster that follows a database - owned by this cluster. + :keyword kusto_pool_resource_id: Resource id of the cluster that follows a database owned by + this cluster. Required. :paramtype kusto_pool_resource_id: str - :keyword attached_database_configuration_name: Required. Resource name of the attached database - configuration in the follower cluster. + :keyword attached_database_configuration_name: Resource name of the attached database + configuration in the follower cluster. Required. :paramtype attached_database_configuration_name: str """ - super(FollowerDatabaseDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.kusto_pool_resource_id = kusto_pool_resource_id self.attached_database_configuration_name = attached_database_configuration_name self.database_name = None -class FollowerDatabaseListResult(msrest.serialization.Model): +class FollowerDatabaseListResult(_serialization.Model): """The list Kusto database principals operation response. :ivar value: The list of follower database result. @@ -3851,20 +3715,15 @@ class FollowerDatabaseListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[FollowerDatabaseDefinition]'}, + "value": {"key": "value", "type": "[FollowerDatabaseDefinition]"}, } - def __init__( - self, - *, - value: Optional[List["FollowerDatabaseDefinition"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.FollowerDatabaseDefinition"]] = None, **kwargs): """ :keyword value: The list of follower database result. :paramtype value: list[~azure.mgmt.synapse.models.FollowerDatabaseDefinition] """ - super(FollowerDatabaseListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value @@ -3887,7 +3746,7 @@ class GeoBackupPolicy(ProxyResource): :vartype kind: str :ivar location: Backup policy location. :vartype location: str - :ivar state: Required. The state of the geo backup policy. Possible values include: "Disabled", + :ivar state: The state of the geo backup policy. Required. Known values are: "Disabled" and "Enabled". :vartype state: str or ~azure.mgmt.synapse.models.GeoBackupPolicyState :ivar storage_type: The storage type of the geo backup policy. @@ -3895,44 +3754,39 @@ class GeoBackupPolicy(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'readonly': True}, - 'location': {'readonly': True}, - 'state': {'required': True}, - 'storage_type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"readonly": True}, + "location": {"readonly": True}, + "state": {"required": True}, + "storage_type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'storage_type': {'key': 'properties.storageType', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "state": {"key": "properties.state", "type": "str"}, + "storage_type": {"key": "properties.storageType", "type": "str"}, } - def __init__( - self, - *, - state: Union[str, "GeoBackupPolicyState"], - **kwargs - ): + def __init__(self, *, state: Union[str, "_models.GeoBackupPolicyState"], **kwargs): """ - :keyword state: Required. The state of the geo backup policy. Possible values include: - "Disabled", "Enabled". + :keyword state: The state of the geo backup policy. Required. Known values are: "Disabled" and + "Enabled". :paramtype state: str or ~azure.mgmt.synapse.models.GeoBackupPolicyState """ - super(GeoBackupPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.kind = None self.location = None self.state = state self.storage_type = None -class GeoBackupPolicyListResult(msrest.serialization.Model): +class GeoBackupPolicyListResult(_serialization.Model): """The response to a list geo backup policies request. :ivar value: The list of geo backup policies. @@ -3940,24 +3794,19 @@ class GeoBackupPolicyListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[GeoBackupPolicy]'}, + "value": {"key": "value", "type": "[GeoBackupPolicy]"}, } - def __init__( - self, - *, - value: Optional[List["GeoBackupPolicy"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.GeoBackupPolicy"]] = None, **kwargs): """ :keyword value: The list of geo backup policies. :paramtype value: list[~azure.mgmt.synapse.models.GeoBackupPolicy] """ - super(GeoBackupPolicyListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class GetSsisObjectMetadataRequest(msrest.serialization.Model): +class GetSsisObjectMetadataRequest(_serialization.Model): """The request payload of get SSIS object metadata. :ivar metadata_path: Metadata path. @@ -3965,76 +3814,65 @@ class GetSsisObjectMetadataRequest(msrest.serialization.Model): """ _attribute_map = { - 'metadata_path': {'key': 'metadataPath', 'type': 'str'}, + "metadata_path": {"key": "metadataPath", "type": "str"}, } - def __init__( - self, - *, - metadata_path: Optional[str] = None, - **kwargs - ): + def __init__(self, *, metadata_path: Optional[str] = None, **kwargs): """ :keyword metadata_path: Metadata path. :paramtype metadata_path: str """ - super(GetSsisObjectMetadataRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.metadata_path = metadata_path -class IntegrationRuntime(msrest.serialization.Model): +class IntegrationRuntime(_serialization.Model): """Azure Synapse nested object which serves as a compute resource for activities. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: ManagedIntegrationRuntime, SelfHostedIntegrationRuntime. + 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. :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :vartype additional_properties: dict[str, any] - :ivar type: Required. Type of integration runtime.Constant filled by server. Possible values - include: "Managed", "SelfHosted". + :vartype additional_properties: dict[str, JSON] + :ivar type: Type of integration runtime. Required. Known values are: "Managed" and + "SelfHosted". :vartype type: str or ~azure.mgmt.synapse.models.IntegrationRuntimeType :ivar description: Integration runtime description. :vartype description: str """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'type': {'key': 'type', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "additional_properties": {"key": "", "type": "{object}"}, + "type": {"key": "type", "type": "str"}, + "description": {"key": "description", "type": "str"}, } - _subtype_map = { - 'type': {'Managed': 'ManagedIntegrationRuntime', 'SelfHosted': 'SelfHostedIntegrationRuntime'} - } + _subtype_map = {"type": {"Managed": "ManagedIntegrationRuntime", "SelfHosted": "SelfHostedIntegrationRuntime"}} def __init__( - self, - *, - additional_properties: Optional[Dict[str, Any]] = None, - description: Optional[str] = None, - **kwargs + self, *, additional_properties: Optional[Dict[str, JSON]] = None, description: Optional[str] = None, **kwargs ): """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. - :paramtype additional_properties: dict[str, any] + :paramtype additional_properties: dict[str, JSON] :keyword description: Integration runtime description. :paramtype description: str """ - super(IntegrationRuntime, self).__init__(**kwargs) + super().__init__(**kwargs) self.additional_properties = additional_properties - self.type = 'IntegrationRuntime' # type: str + self.type = None # type: Optional[str] self.description = description -class IntegrationRuntimeAuthKeys(msrest.serialization.Model): +class IntegrationRuntimeAuthKeys(_serialization.Model): """The integration runtime authentication keys. :ivar auth_key1: The primary integration runtime authentication key. @@ -4044,34 +3882,28 @@ class IntegrationRuntimeAuthKeys(msrest.serialization.Model): """ _attribute_map = { - 'auth_key1': {'key': 'authKey1', 'type': 'str'}, - 'auth_key2': {'key': 'authKey2', 'type': 'str'}, + "auth_key1": {"key": "authKey1", "type": "str"}, + "auth_key2": {"key": "authKey2", "type": "str"}, } - def __init__( - self, - *, - auth_key1: Optional[str] = None, - auth_key2: Optional[str] = None, - **kwargs - ): + def __init__(self, *, auth_key1: Optional[str] = None, auth_key2: Optional[str] = None, **kwargs): """ :keyword auth_key1: The primary integration runtime authentication key. :paramtype auth_key1: str :keyword auth_key2: The secondary integration runtime authentication key. :paramtype auth_key2: str """ - super(IntegrationRuntimeAuthKeys, self).__init__(**kwargs) + super().__init__(**kwargs) self.auth_key1 = auth_key1 self.auth_key2 = auth_key2 -class IntegrationRuntimeComputeProperties(msrest.serialization.Model): +class IntegrationRuntimeComputeProperties(_serialization.Model): """The compute resource properties for managed integration runtime. :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :vartype additional_properties: dict[str, any] + :vartype additional_properties: dict[str, JSON] :ivar location: The location for managed integration runtime. The supported regions could be found on https://docs.microsoft.com/en-us/azure/data-factory/data-factory-data-movement-activities. @@ -4090,36 +3922,36 @@ class IntegrationRuntimeComputeProperties(msrest.serialization.Model): """ _validation = { - 'number_of_nodes': {'minimum': 1}, - 'max_parallel_executions_per_node': {'minimum': 1}, + "number_of_nodes": {"minimum": 1}, + "max_parallel_executions_per_node": {"minimum": 1}, } _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'node_size': {'key': 'nodeSize', 'type': 'str'}, - 'number_of_nodes': {'key': 'numberOfNodes', 'type': 'int'}, - 'max_parallel_executions_per_node': {'key': 'maxParallelExecutionsPerNode', 'type': 'int'}, - 'data_flow_properties': {'key': 'dataFlowProperties', 'type': 'IntegrationRuntimeDataFlowProperties'}, - 'v_net_properties': {'key': 'vNetProperties', 'type': 'IntegrationRuntimeVNetProperties'}, + "additional_properties": {"key": "", "type": "{object}"}, + "location": {"key": "location", "type": "str"}, + "node_size": {"key": "nodeSize", "type": "str"}, + "number_of_nodes": {"key": "numberOfNodes", "type": "int"}, + "max_parallel_executions_per_node": {"key": "maxParallelExecutionsPerNode", "type": "int"}, + "data_flow_properties": {"key": "dataFlowProperties", "type": "IntegrationRuntimeDataFlowProperties"}, + "v_net_properties": {"key": "vNetProperties", "type": "IntegrationRuntimeVNetProperties"}, } def __init__( self, *, - additional_properties: Optional[Dict[str, Any]] = None, + additional_properties: Optional[Dict[str, JSON]] = None, location: Optional[str] = None, node_size: Optional[str] = None, number_of_nodes: Optional[int] = None, max_parallel_executions_per_node: Optional[int] = None, - data_flow_properties: Optional["IntegrationRuntimeDataFlowProperties"] = None, - v_net_properties: Optional["IntegrationRuntimeVNetProperties"] = None, + data_flow_properties: Optional["_models.IntegrationRuntimeDataFlowProperties"] = None, + v_net_properties: Optional["_models.IntegrationRuntimeVNetProperties"] = None, **kwargs ): """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. - :paramtype additional_properties: dict[str, any] + :paramtype additional_properties: dict[str, JSON] :keyword location: The location for managed integration runtime. The supported regions could be found on https://docs.microsoft.com/en-us/azure/data-factory/data-factory-data-movement-activities. @@ -4137,7 +3969,7 @@ def __init__( :keyword v_net_properties: VNet properties for managed integration runtime. :paramtype v_net_properties: ~azure.mgmt.synapse.models.IntegrationRuntimeVNetProperties """ - super(IntegrationRuntimeComputeProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.additional_properties = additional_properties self.location = location self.node_size = node_size @@ -4147,14 +3979,14 @@ def __init__( self.v_net_properties = v_net_properties -class IntegrationRuntimeConnectionInfo(msrest.serialization.Model): +class IntegrationRuntimeConnectionInfo(_serialization.Model): """Connection information for encrypting the on-premises data source credentials. Variables are only populated by the server, and will be ignored when sending a request. :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :vartype additional_properties: dict[str, any] + :vartype additional_properties: dict[str, JSON] :ivar service_token: The token generated in service. Callers use this token to authenticate to integration runtime. :vartype service_token: str @@ -4173,36 +4005,31 @@ class IntegrationRuntimeConnectionInfo(msrest.serialization.Model): """ _validation = { - 'service_token': {'readonly': True}, - 'identity_cert_thumbprint': {'readonly': True}, - 'host_service_uri': {'readonly': True}, - 'version': {'readonly': True}, - 'public_key': {'readonly': True}, - 'is_identity_cert_exprired': {'readonly': True}, + "service_token": {"readonly": True}, + "identity_cert_thumbprint": {"readonly": True}, + "host_service_uri": {"readonly": True}, + "version": {"readonly": True}, + "public_key": {"readonly": True}, + "is_identity_cert_exprired": {"readonly": True}, } _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'service_token': {'key': 'serviceToken', 'type': 'str'}, - 'identity_cert_thumbprint': {'key': 'identityCertThumbprint', 'type': 'str'}, - 'host_service_uri': {'key': 'hostServiceUri', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'public_key': {'key': 'publicKey', 'type': 'str'}, - 'is_identity_cert_exprired': {'key': 'isIdentityCertExprired', 'type': 'bool'}, + "additional_properties": {"key": "", "type": "{object}"}, + "service_token": {"key": "serviceToken", "type": "str"}, + "identity_cert_thumbprint": {"key": "identityCertThumbprint", "type": "str"}, + "host_service_uri": {"key": "hostServiceUri", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "public_key": {"key": "publicKey", "type": "str"}, + "is_identity_cert_exprired": {"key": "isIdentityCertExprired", "type": "bool"}, } - def __init__( - self, - *, - additional_properties: Optional[Dict[str, Any]] = None, - **kwargs - ): + def __init__(self, *, additional_properties: Optional[Dict[str, JSON]] = None, **kwargs): """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. - :paramtype additional_properties: dict[str, any] + :paramtype additional_properties: dict[str, JSON] """ - super(IntegrationRuntimeConnectionInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.additional_properties = additional_properties self.service_token = None self.identity_cert_thumbprint = None @@ -4212,7 +4039,7 @@ def __init__( self.is_identity_cert_exprired = None -class IntegrationRuntimeCustomSetupScriptProperties(msrest.serialization.Model): +class IntegrationRuntimeCustomSetupScriptProperties(_serialization.Model): """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 @@ -4223,16 +4050,12 @@ class IntegrationRuntimeCustomSetupScriptProperties(msrest.serialization.Model): """ _attribute_map = { - 'blob_container_uri': {'key': 'blobContainerUri', 'type': 'str'}, - 'sas_token': {'key': 'sasToken', 'type': 'SecureString'}, + "blob_container_uri": {"key": "blobContainerUri", "type": "str"}, + "sas_token": {"key": "sasToken", "type": "SecureString"}, } def __init__( - self, - *, - blob_container_uri: Optional[str] = None, - sas_token: Optional["SecureString"] = None, - **kwargs + self, *, blob_container_uri: Optional[str] = None, sas_token: Optional["_models.SecureString"] = None, **kwargs ): """ :keyword blob_container_uri: The URI of the Azure blob container that contains the custom setup @@ -4241,19 +4064,19 @@ def __init__( :keyword sas_token: The SAS token of the Azure blob container. :paramtype sas_token: ~azure.mgmt.synapse.models.SecureString """ - super(IntegrationRuntimeCustomSetupScriptProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.blob_container_uri = blob_container_uri self.sas_token = sas_token -class IntegrationRuntimeDataFlowProperties(msrest.serialization.Model): +class IntegrationRuntimeDataFlowProperties(_serialization.Model): """Data flow properties for managed integration runtime. :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :vartype additional_properties: dict[str, any] - :ivar compute_type: Compute type of the cluster which will execute data flow job. Possible - values include: "General", "MemoryOptimized", "ComputeOptimized". + :vartype additional_properties: dict[str, JSON] + :ivar compute_type: Compute type of the cluster which will execute data flow job. Known values + are: "General", "MemoryOptimized", and "ComputeOptimized". :vartype compute_type: str or ~azure.mgmt.synapse.models.DataFlowComputeType :ivar core_count: Core count of the cluster which will execute data flow job. Supported values are: 8, 16, 32, 48, 80, 144 and 272. @@ -4267,22 +4090,22 @@ class IntegrationRuntimeDataFlowProperties(msrest.serialization.Model): """ _validation = { - 'time_to_live': {'minimum': 0}, + "time_to_live": {"minimum": 0}, } _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'compute_type': {'key': 'computeType', 'type': 'str'}, - 'core_count': {'key': 'coreCount', 'type': 'int'}, - 'time_to_live': {'key': 'timeToLive', 'type': 'int'}, - 'cleanup': {'key': 'cleanup', 'type': 'bool'}, + "additional_properties": {"key": "", "type": "{object}"}, + "compute_type": {"key": "computeType", "type": "str"}, + "core_count": {"key": "coreCount", "type": "int"}, + "time_to_live": {"key": "timeToLive", "type": "int"}, + "cleanup": {"key": "cleanup", "type": "bool"}, } def __init__( self, *, - additional_properties: Optional[Dict[str, Any]] = None, - compute_type: Optional[Union[str, "DataFlowComputeType"]] = None, + additional_properties: Optional[Dict[str, JSON]] = None, + compute_type: Optional[Union[str, "_models.DataFlowComputeType"]] = None, core_count: Optional[int] = None, time_to_live: Optional[int] = None, cleanup: Optional[bool] = None, @@ -4291,9 +4114,9 @@ def __init__( """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. - :paramtype additional_properties: dict[str, any] - :keyword compute_type: Compute type of the cluster which will execute data flow job. Possible - values include: "General", "MemoryOptimized", "ComputeOptimized". + :paramtype additional_properties: dict[str, JSON] + :keyword compute_type: Compute type of the cluster which will execute data flow job. Known + values are: "General", "MemoryOptimized", and "ComputeOptimized". :paramtype compute_type: str or ~azure.mgmt.synapse.models.DataFlowComputeType :keyword core_count: Core count of the cluster which will execute data flow job. Supported values are: 8, 16, 32, 48, 80, 144 and 272. @@ -4305,7 +4128,7 @@ def __init__( run until TTL (time to live) is reached if this is set as false. Default is true. :paramtype cleanup: bool """ - super(IntegrationRuntimeDataFlowProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.additional_properties = additional_properties self.compute_type = compute_type self.core_count = core_count @@ -4313,7 +4136,7 @@ def __init__( self.cleanup = cleanup -class IntegrationRuntimeDataProxyProperties(msrest.serialization.Model): +class IntegrationRuntimeDataProxyProperties(_serialization.Model): """Data proxy properties for a managed dedicated integration runtime. :ivar connect_via: The self-hosted integration runtime reference. @@ -4325,16 +4148,16 @@ class IntegrationRuntimeDataProxyProperties(msrest.serialization.Model): """ _attribute_map = { - 'connect_via': {'key': 'connectVia', 'type': 'EntityReference'}, - 'staging_linked_service': {'key': 'stagingLinkedService', 'type': 'EntityReference'}, - 'path': {'key': 'path', 'type': 'str'}, + "connect_via": {"key": "connectVia", "type": "EntityReference"}, + "staging_linked_service": {"key": "stagingLinkedService", "type": "EntityReference"}, + "path": {"key": "path", "type": "str"}, } def __init__( self, *, - connect_via: Optional["EntityReference"] = None, - staging_linked_service: Optional["EntityReference"] = None, + connect_via: Optional["_models.EntityReference"] = None, + staging_linked_service: Optional["_models.EntityReference"] = None, path: Optional[str] = None, **kwargs ): @@ -4346,51 +4169,45 @@ def __init__( :keyword path: The path to contain the staged data in the Blob storage. :paramtype path: str """ - super(IntegrationRuntimeDataProxyProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.connect_via = connect_via self.staging_linked_service = staging_linked_service self.path = path -class IntegrationRuntimeListResponse(msrest.serialization.Model): +class IntegrationRuntimeListResponse(_serialization.Model): """A list of integration runtime resources. All required parameters must be populated in order to send to Azure. - :ivar value: Required. List of integration runtimes. + :ivar value: List of integration runtimes. Required. :vartype value: list[~azure.mgmt.synapse.models.IntegrationRuntimeResource] :ivar next_link: The link to the next page of results, if any remaining results exist. :vartype next_link: str """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IntegrationRuntimeResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IntegrationRuntimeResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: List["IntegrationRuntimeResource"], - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: List["_models.IntegrationRuntimeResource"], next_link: Optional[str] = None, **kwargs): """ - :keyword value: Required. List of integration runtimes. + :keyword value: List of integration runtimes. Required. :paramtype value: list[~azure.mgmt.synapse.models.IntegrationRuntimeResource] :keyword next_link: The link to the next page of results, if any remaining results exist. :paramtype next_link: str """ - super(IntegrationRuntimeListResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class IntegrationRuntimeMonitoringData(msrest.serialization.Model): +class IntegrationRuntimeMonitoringData(_serialization.Model): """Get monitoring data response. :ivar name: Integration runtime name. @@ -4400,15 +4217,15 @@ class IntegrationRuntimeMonitoringData(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'nodes': {'key': 'nodes', 'type': '[IntegrationRuntimeNodeMonitoringData]'}, + "name": {"key": "name", "type": "str"}, + "nodes": {"key": "nodes", "type": "[IntegrationRuntimeNodeMonitoringData]"}, } def __init__( self, *, name: Optional[str] = None, - nodes: Optional[List["IntegrationRuntimeNodeMonitoringData"]] = None, + nodes: Optional[List["_models.IntegrationRuntimeNodeMonitoringData"]] = None, **kwargs ): """ @@ -4417,12 +4234,12 @@ def __init__( :keyword nodes: Integration runtime node monitoring data. :paramtype nodes: list[~azure.mgmt.synapse.models.IntegrationRuntimeNodeMonitoringData] """ - super(IntegrationRuntimeMonitoringData, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.nodes = nodes -class IntegrationRuntimeNodeIpAddress(msrest.serialization.Model): +class IntegrationRuntimeNodeIpAddress(_serialization.Model): """The IP address of self-hosted integration runtime node. Variables are only populated by the server, and will be ignored when sending a request. @@ -4432,31 +4249,27 @@ class IntegrationRuntimeNodeIpAddress(msrest.serialization.Model): """ _validation = { - 'ip_address': {'readonly': True}, + "ip_address": {"readonly": True}, } _attribute_map = { - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, + "ip_address": {"key": "ipAddress", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(IntegrationRuntimeNodeIpAddress, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.ip_address = None -class IntegrationRuntimeNodeMonitoringData(msrest.serialization.Model): +class IntegrationRuntimeNodeMonitoringData(_serialization.Model): """Monitoring data for integration runtime node. Variables are only populated by the server, and will be ignored when sending a request. :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :vartype additional_properties: dict[str, any] + :vartype additional_properties: dict[str, JSON] :ivar node_name: Name of the integration runtime node. :vartype node_name: str :ivar available_memory_in_mb: Available memory (MB) on the integration runtime node. @@ -4477,40 +4290,35 @@ class IntegrationRuntimeNodeMonitoringData(msrest.serialization.Model): """ _validation = { - 'node_name': {'readonly': True}, - 'available_memory_in_mb': {'readonly': True}, - 'cpu_utilization': {'readonly': True}, - 'concurrent_jobs_limit': {'readonly': True}, - 'concurrent_jobs_running': {'readonly': True}, - 'max_concurrent_jobs': {'readonly': True}, - 'sent_bytes': {'readonly': True}, - 'received_bytes': {'readonly': True}, + "node_name": {"readonly": True}, + "available_memory_in_mb": {"readonly": True}, + "cpu_utilization": {"readonly": True}, + "concurrent_jobs_limit": {"readonly": True}, + "concurrent_jobs_running": {"readonly": True}, + "max_concurrent_jobs": {"readonly": True}, + "sent_bytes": {"readonly": True}, + "received_bytes": {"readonly": True}, } _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'node_name': {'key': 'nodeName', 'type': 'str'}, - 'available_memory_in_mb': {'key': 'availableMemoryInMB', 'type': 'int'}, - 'cpu_utilization': {'key': 'cpuUtilization', 'type': 'int'}, - 'concurrent_jobs_limit': {'key': 'concurrentJobsLimit', 'type': 'int'}, - 'concurrent_jobs_running': {'key': 'concurrentJobsRunning', 'type': 'int'}, - 'max_concurrent_jobs': {'key': 'maxConcurrentJobs', 'type': 'int'}, - 'sent_bytes': {'key': 'sentBytes', 'type': 'float'}, - 'received_bytes': {'key': 'receivedBytes', 'type': 'float'}, + "additional_properties": {"key": "", "type": "{object}"}, + "node_name": {"key": "nodeName", "type": "str"}, + "available_memory_in_mb": {"key": "availableMemoryInMB", "type": "int"}, + "cpu_utilization": {"key": "cpuUtilization", "type": "int"}, + "concurrent_jobs_limit": {"key": "concurrentJobsLimit", "type": "int"}, + "concurrent_jobs_running": {"key": "concurrentJobsRunning", "type": "int"}, + "max_concurrent_jobs": {"key": "maxConcurrentJobs", "type": "int"}, + "sent_bytes": {"key": "sentBytes", "type": "float"}, + "received_bytes": {"key": "receivedBytes", "type": "float"}, } - def __init__( - self, - *, - additional_properties: Optional[Dict[str, Any]] = None, - **kwargs - ): + def __init__(self, *, additional_properties: Optional[Dict[str, JSON]] = None, **kwargs): """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. - :paramtype additional_properties: dict[str, any] + :paramtype additional_properties: dict[str, JSON] """ - super(IntegrationRuntimeNodeMonitoringData, self).__init__(**kwargs) + super().__init__(**kwargs) self.additional_properties = additional_properties self.node_name = None self.available_memory_in_mb = None @@ -4522,7 +4330,7 @@ def __init__( self.received_bytes = None -class IntegrationRuntimeOutboundNetworkDependenciesCategoryEndpoint(msrest.serialization.Model): +class IntegrationRuntimeOutboundNetworkDependenciesCategoryEndpoint(_serialization.Model): """Azure-SSIS integration runtime outbound network dependency endpoints for one category. :ivar category: The category of outbound network dependency. @@ -4533,15 +4341,15 @@ class IntegrationRuntimeOutboundNetworkDependenciesCategoryEndpoint(msrest.seria """ _attribute_map = { - 'category': {'key': 'category', 'type': 'str'}, - 'endpoints': {'key': 'endpoints', 'type': '[IntegrationRuntimeOutboundNetworkDependenciesEndpoint]'}, + "category": {"key": "category", "type": "str"}, + "endpoints": {"key": "endpoints", "type": "[IntegrationRuntimeOutboundNetworkDependenciesEndpoint]"}, } def __init__( self, *, category: Optional[str] = None, - endpoints: Optional[List["IntegrationRuntimeOutboundNetworkDependenciesEndpoint"]] = None, + endpoints: Optional[List["_models.IntegrationRuntimeOutboundNetworkDependenciesEndpoint"]] = None, **kwargs ): """ @@ -4551,12 +4359,12 @@ def __init__( :paramtype endpoints: list[~azure.mgmt.synapse.models.IntegrationRuntimeOutboundNetworkDependenciesEndpoint] """ - super(IntegrationRuntimeOutboundNetworkDependenciesCategoryEndpoint, self).__init__(**kwargs) + super().__init__(**kwargs) self.category = category self.endpoints = endpoints -class IntegrationRuntimeOutboundNetworkDependenciesEndpoint(msrest.serialization.Model): +class IntegrationRuntimeOutboundNetworkDependenciesEndpoint(_serialization.Model): """The endpoint for Azure-SSIS integration runtime outbound network dependency. :ivar domain_name: The domain name of endpoint. @@ -4567,15 +4375,18 @@ class IntegrationRuntimeOutboundNetworkDependenciesEndpoint(msrest.serialization """ _attribute_map = { - 'domain_name': {'key': 'domainName', 'type': 'str'}, - 'endpoint_details': {'key': 'endpointDetails', 'type': '[IntegrationRuntimeOutboundNetworkDependenciesEndpointDetails]'}, + "domain_name": {"key": "domainName", "type": "str"}, + "endpoint_details": { + "key": "endpointDetails", + "type": "[IntegrationRuntimeOutboundNetworkDependenciesEndpointDetails]", + }, } def __init__( self, *, domain_name: Optional[str] = None, - endpoint_details: Optional[List["IntegrationRuntimeOutboundNetworkDependenciesEndpointDetails"]] = None, + endpoint_details: Optional[List["_models.IntegrationRuntimeOutboundNetworkDependenciesEndpointDetails"]] = None, **kwargs ): """ @@ -4585,12 +4396,12 @@ def __init__( :paramtype endpoint_details: list[~azure.mgmt.synapse.models.IntegrationRuntimeOutboundNetworkDependenciesEndpointDetails] """ - super(IntegrationRuntimeOutboundNetworkDependenciesEndpoint, self).__init__(**kwargs) + super().__init__(**kwargs) self.domain_name = domain_name self.endpoint_details = endpoint_details -class IntegrationRuntimeOutboundNetworkDependenciesEndpointDetails(msrest.serialization.Model): +class IntegrationRuntimeOutboundNetworkDependenciesEndpointDetails(_serialization.Model): """The details of Azure-SSIS integration runtime outbound network dependency endpoint. :ivar port: The port of endpoint. @@ -4598,24 +4409,19 @@ class IntegrationRuntimeOutboundNetworkDependenciesEndpointDetails(msrest.serial """ _attribute_map = { - 'port': {'key': 'port', 'type': 'int'}, + "port": {"key": "port", "type": "int"}, } - def __init__( - self, - *, - port: Optional[int] = None, - **kwargs - ): + def __init__(self, *, port: Optional[int] = None, **kwargs): """ :keyword port: The port of endpoint. :paramtype port: int """ - super(IntegrationRuntimeOutboundNetworkDependenciesEndpointDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.port = port -class IntegrationRuntimeOutboundNetworkDependenciesEndpointsResponse(msrest.serialization.Model): +class IntegrationRuntimeOutboundNetworkDependenciesEndpointsResponse(_serialization.Model): """Azure-SSIS integration runtime outbound network dependency endpoints. :ivar value: The list of outbound network dependency endpoints. @@ -4624,13 +4430,13 @@ class IntegrationRuntimeOutboundNetworkDependenciesEndpointsResponse(msrest.seri """ _attribute_map = { - 'value': {'key': 'value', 'type': '[IntegrationRuntimeOutboundNetworkDependenciesCategoryEndpoint]'}, + "value": {"key": "value", "type": "[IntegrationRuntimeOutboundNetworkDependenciesCategoryEndpoint]"}, } def __init__( self, *, - value: Optional[List["IntegrationRuntimeOutboundNetworkDependenciesCategoryEndpoint"]] = None, + value: Optional[List["_models.IntegrationRuntimeOutboundNetworkDependenciesCategoryEndpoint"]] = None, **kwargs ): """ @@ -4638,34 +4444,29 @@ def __init__( :paramtype value: list[~azure.mgmt.synapse.models.IntegrationRuntimeOutboundNetworkDependenciesCategoryEndpoint] """ - super(IntegrationRuntimeOutboundNetworkDependenciesEndpointsResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class IntegrationRuntimeRegenerateKeyParameters(msrest.serialization.Model): +class IntegrationRuntimeRegenerateKeyParameters(_serialization.Model): """Parameters to regenerate the authentication key. - :ivar key_name: The name of the authentication key to regenerate. Possible values include: - "authKey1", "authKey2". + :ivar key_name: The name of the authentication key to regenerate. Known values are: "authKey1" + and "authKey2". :vartype key_name: str or ~azure.mgmt.synapse.models.IntegrationRuntimeAuthKeyName """ _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, } - def __init__( - self, - *, - key_name: Optional[Union[str, "IntegrationRuntimeAuthKeyName"]] = None, - **kwargs - ): + def __init__(self, *, key_name: Optional[Union[str, "_models.IntegrationRuntimeAuthKeyName"]] = None, **kwargs): """ - :keyword key_name: The name of the authentication key to regenerate. Possible values include: - "authKey1", "authKey2". + :keyword key_name: The name of the authentication key to regenerate. Known values are: + "authKey1" and "authKey2". :paramtype key_name: str or ~azure.mgmt.synapse.models.IntegrationRuntimeAuthKeyName """ - super(IntegrationRuntimeRegenerateKeyParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name @@ -4687,26 +4488,22 @@ class SubResource(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, + "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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SubResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) class IntegrationRuntimeResource(SubResource): @@ -4726,46 +4523,41 @@ class IntegrationRuntimeResource(SubResource): :vartype type: str :ivar etag: Resource Etag. :vartype etag: str - :ivar properties: Required. Integration runtime properties. + :ivar properties: Integration runtime properties. Required. :vartype properties: ~azure.mgmt.synapse.models.IntegrationRuntime """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'properties': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "properties": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'IntegrationRuntime'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "properties": {"key": "properties", "type": "IntegrationRuntime"}, } - def __init__( - self, - *, - properties: "IntegrationRuntime", - **kwargs - ): + def __init__(self, *, properties: "_models.IntegrationRuntime", **kwargs): """ - :keyword properties: Required. Integration runtime properties. + :keyword properties: Integration runtime properties. Required. :paramtype properties: ~azure.mgmt.synapse.models.IntegrationRuntime """ - super(IntegrationRuntimeResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class IntegrationRuntimeSsisCatalogInfo(msrest.serialization.Model): +class IntegrationRuntimeSsisCatalogInfo(_serialization.Model): """Catalog information for managed dedicated integration runtime. :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :vartype additional_properties: dict[str, any] + :vartype additional_properties: dict[str, JSON] :ivar catalog_server_endpoint: The catalog database server URL. :vartype catalog_server_endpoint: str :ivar catalog_admin_user_name: The administrator user name of catalog database. @@ -4774,38 +4566,38 @@ class IntegrationRuntimeSsisCatalogInfo(msrest.serialization.Model): database. :vartype catalog_admin_password: ~azure.mgmt.synapse.models.SecureString :ivar catalog_pricing_tier: The pricing tier for the catalog database. The valid values could - be found in https://azure.microsoft.com/en-us/pricing/details/sql-database/. Possible values - include: "Basic", "Standard", "Premium", "PremiumRS". + be found in https://azure.microsoft.com/en-us/pricing/details/sql-database/. Known values are: + "Basic", "Standard", "Premium", and "PremiumRS". :vartype catalog_pricing_tier: str or ~azure.mgmt.synapse.models.IntegrationRuntimeSsisCatalogPricingTier """ _validation = { - 'catalog_admin_user_name': {'max_length': 128, 'min_length': 1}, + "catalog_admin_user_name": {"max_length": 128, "min_length": 1}, } _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'catalog_server_endpoint': {'key': 'catalogServerEndpoint', 'type': 'str'}, - 'catalog_admin_user_name': {'key': 'catalogAdminUserName', 'type': 'str'}, - 'catalog_admin_password': {'key': 'catalogAdminPassword', 'type': 'SecureString'}, - 'catalog_pricing_tier': {'key': 'catalogPricingTier', 'type': 'str'}, + "additional_properties": {"key": "", "type": "{object}"}, + "catalog_server_endpoint": {"key": "catalogServerEndpoint", "type": "str"}, + "catalog_admin_user_name": {"key": "catalogAdminUserName", "type": "str"}, + "catalog_admin_password": {"key": "catalogAdminPassword", "type": "SecureString"}, + "catalog_pricing_tier": {"key": "catalogPricingTier", "type": "str"}, } def __init__( self, *, - additional_properties: Optional[Dict[str, Any]] = None, + additional_properties: Optional[Dict[str, JSON]] = None, catalog_server_endpoint: Optional[str] = None, catalog_admin_user_name: Optional[str] = None, - catalog_admin_password: Optional["SecureString"] = None, - catalog_pricing_tier: Optional[Union[str, "IntegrationRuntimeSsisCatalogPricingTier"]] = None, + catalog_admin_password: Optional["_models.SecureString"] = None, + catalog_pricing_tier: Optional[Union[str, "_models.IntegrationRuntimeSsisCatalogPricingTier"]] = None, **kwargs ): """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. - :paramtype additional_properties: dict[str, any] + :paramtype additional_properties: dict[str, JSON] :keyword catalog_server_endpoint: The catalog database server URL. :paramtype catalog_server_endpoint: str :keyword catalog_admin_user_name: The administrator user name of catalog database. @@ -4814,12 +4606,12 @@ def __init__( database. :paramtype catalog_admin_password: ~azure.mgmt.synapse.models.SecureString :keyword catalog_pricing_tier: The pricing tier for the catalog database. The valid values - could be found in https://azure.microsoft.com/en-us/pricing/details/sql-database/. Possible - values include: "Basic", "Standard", "Premium", "PremiumRS". + could be found in https://azure.microsoft.com/en-us/pricing/details/sql-database/. Known values + are: "Basic", "Standard", "Premium", and "PremiumRS". :paramtype catalog_pricing_tier: str or ~azure.mgmt.synapse.models.IntegrationRuntimeSsisCatalogPricingTier """ - super(IntegrationRuntimeSsisCatalogInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.additional_properties = additional_properties self.catalog_server_endpoint = catalog_server_endpoint self.catalog_admin_user_name = catalog_admin_user_name @@ -4827,16 +4619,16 @@ def __init__( self.catalog_pricing_tier = catalog_pricing_tier -class IntegrationRuntimeSsisProperties(msrest.serialization.Model): +class IntegrationRuntimeSsisProperties(_serialization.Model): """SSIS properties for managed integration runtime. :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :vartype additional_properties: dict[str, any] + :vartype additional_properties: dict[str, JSON] :ivar catalog_info: Catalog information for managed dedicated integration runtime. :vartype catalog_info: ~azure.mgmt.synapse.models.IntegrationRuntimeSsisCatalogInfo - :ivar license_type: License type for bringing your own license scenario. Possible values - include: "BasePrice", "LicenseIncluded". + :ivar license_type: License type for bringing your own license scenario. Known values are: + "BasePrice" and "LicenseIncluded". :vartype license_type: str or ~azure.mgmt.synapse.models.IntegrationRuntimeLicenseType :ivar custom_setup_script_properties: Custom setup script properties for a managed dedicated integration runtime. @@ -4845,8 +4637,8 @@ class IntegrationRuntimeSsisProperties(msrest.serialization.Model): :ivar data_proxy_properties: Data proxy properties for a managed dedicated integration runtime. :vartype data_proxy_properties: ~azure.mgmt.synapse.models.IntegrationRuntimeDataProxyProperties - :ivar edition: The edition for the SSIS Integration Runtime. Possible values include: - "Standard", "Enterprise". + :ivar edition: The edition for the SSIS Integration Runtime. Known values are: "Standard" and + "Enterprise". :vartype edition: str or ~azure.mgmt.synapse.models.IntegrationRuntimeEdition :ivar express_custom_setup_properties: Custom setup without script properties for a SSIS integration runtime. @@ -4854,35 +4646,38 @@ class IntegrationRuntimeSsisProperties(msrest.serialization.Model): """ _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'catalog_info': {'key': 'catalogInfo', 'type': 'IntegrationRuntimeSsisCatalogInfo'}, - 'license_type': {'key': 'licenseType', 'type': 'str'}, - 'custom_setup_script_properties': {'key': 'customSetupScriptProperties', 'type': 'IntegrationRuntimeCustomSetupScriptProperties'}, - 'data_proxy_properties': {'key': 'dataProxyProperties', 'type': 'IntegrationRuntimeDataProxyProperties'}, - 'edition': {'key': 'edition', 'type': 'str'}, - 'express_custom_setup_properties': {'key': 'expressCustomSetupProperties', 'type': '[CustomSetupBase]'}, + "additional_properties": {"key": "", "type": "{object}"}, + "catalog_info": {"key": "catalogInfo", "type": "IntegrationRuntimeSsisCatalogInfo"}, + "license_type": {"key": "licenseType", "type": "str"}, + "custom_setup_script_properties": { + "key": "customSetupScriptProperties", + "type": "IntegrationRuntimeCustomSetupScriptProperties", + }, + "data_proxy_properties": {"key": "dataProxyProperties", "type": "IntegrationRuntimeDataProxyProperties"}, + "edition": {"key": "edition", "type": "str"}, + "express_custom_setup_properties": {"key": "expressCustomSetupProperties", "type": "[CustomSetupBase]"}, } def __init__( self, *, - additional_properties: Optional[Dict[str, Any]] = None, - catalog_info: Optional["IntegrationRuntimeSsisCatalogInfo"] = None, - license_type: Optional[Union[str, "IntegrationRuntimeLicenseType"]] = None, - custom_setup_script_properties: Optional["IntegrationRuntimeCustomSetupScriptProperties"] = None, - data_proxy_properties: Optional["IntegrationRuntimeDataProxyProperties"] = None, - edition: Optional[Union[str, "IntegrationRuntimeEdition"]] = None, - express_custom_setup_properties: Optional[List["CustomSetupBase"]] = None, + additional_properties: Optional[Dict[str, JSON]] = None, + catalog_info: Optional["_models.IntegrationRuntimeSsisCatalogInfo"] = None, + license_type: Optional[Union[str, "_models.IntegrationRuntimeLicenseType"]] = None, + custom_setup_script_properties: Optional["_models.IntegrationRuntimeCustomSetupScriptProperties"] = None, + data_proxy_properties: Optional["_models.IntegrationRuntimeDataProxyProperties"] = None, + edition: Optional[Union[str, "_models.IntegrationRuntimeEdition"]] = None, + express_custom_setup_properties: Optional[List["_models.CustomSetupBase"]] = None, **kwargs ): """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. - :paramtype additional_properties: dict[str, any] + :paramtype additional_properties: dict[str, JSON] :keyword catalog_info: Catalog information for managed dedicated integration runtime. :paramtype catalog_info: ~azure.mgmt.synapse.models.IntegrationRuntimeSsisCatalogInfo - :keyword license_type: License type for bringing your own license scenario. Possible values - include: "BasePrice", "LicenseIncluded". + :keyword license_type: License type for bringing your own license scenario. Known values are: + "BasePrice" and "LicenseIncluded". :paramtype license_type: str or ~azure.mgmt.synapse.models.IntegrationRuntimeLicenseType :keyword custom_setup_script_properties: Custom setup script properties for a managed dedicated integration runtime. @@ -4892,14 +4687,14 @@ def __init__( runtime. :paramtype data_proxy_properties: ~azure.mgmt.synapse.models.IntegrationRuntimeDataProxyProperties - :keyword edition: The edition for the SSIS Integration Runtime. Possible values include: - "Standard", "Enterprise". + :keyword edition: The edition for the SSIS Integration Runtime. Known values are: "Standard" + and "Enterprise". :paramtype edition: str or ~azure.mgmt.synapse.models.IntegrationRuntimeEdition :keyword express_custom_setup_properties: Custom setup without script properties for a SSIS integration runtime. :paramtype express_custom_setup_properties: list[~azure.mgmt.synapse.models.CustomSetupBase] """ - super(IntegrationRuntimeSsisProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.additional_properties = additional_properties self.catalog_info = catalog_info self.license_type = license_type @@ -4909,11 +4704,11 @@ def __init__( self.express_custom_setup_properties = express_custom_setup_properties -class IntegrationRuntimeStatus(msrest.serialization.Model): +class IntegrationRuntimeStatus(_serialization.Model): """Integration runtime status. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: ManagedIntegrationRuntimeStatus, SelfHostedIntegrationRuntimeStatus. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ManagedIntegrationRuntimeStatus, SelfHostedIntegrationRuntimeStatus Variables are only populated by the server, and will be ignored when sending a request. @@ -4921,54 +4716,49 @@ class IntegrationRuntimeStatus(msrest.serialization.Model): :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :vartype additional_properties: dict[str, any] - :ivar type: Required. Type of integration runtime.Constant filled by server. Possible values - include: "Managed", "SelfHosted". + :vartype additional_properties: dict[str, JSON] + :ivar type: Type of integration runtime. Required. Known values are: "Managed" and + "SelfHosted". :vartype type: str or ~azure.mgmt.synapse.models.IntegrationRuntimeType :ivar data_factory_name: The workspace name which the integration runtime belong to. :vartype data_factory_name: str - :ivar state: The state of integration runtime. Possible values include: "Initial", "Stopped", - "Started", "Starting", "Stopping", "NeedRegistration", "Online", "Limited", "Offline", + :ivar state: The state of integration runtime. Known values are: "Initial", "Stopped", + "Started", "Starting", "Stopping", "NeedRegistration", "Online", "Limited", "Offline", and "AccessDenied". :vartype state: str or ~azure.mgmt.synapse.models.IntegrationRuntimeState """ _validation = { - 'type': {'required': True}, - 'data_factory_name': {'readonly': True}, - 'state': {'readonly': True}, + "type": {"required": True}, + "data_factory_name": {"readonly": True}, + "state": {"readonly": True}, } _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'type': {'key': 'type', 'type': 'str'}, - 'data_factory_name': {'key': 'dataFactoryName', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, + "additional_properties": {"key": "", "type": "{object}"}, + "type": {"key": "type", "type": "str"}, + "data_factory_name": {"key": "dataFactoryName", "type": "str"}, + "state": {"key": "state", "type": "str"}, } _subtype_map = { - 'type': {'Managed': 'ManagedIntegrationRuntimeStatus', 'SelfHosted': 'SelfHostedIntegrationRuntimeStatus'} + "type": {"Managed": "ManagedIntegrationRuntimeStatus", "SelfHosted": "SelfHostedIntegrationRuntimeStatus"} } - def __init__( - self, - *, - additional_properties: Optional[Dict[str, Any]] = None, - **kwargs - ): + def __init__(self, *, additional_properties: Optional[Dict[str, JSON]] = None, **kwargs): """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. - :paramtype additional_properties: dict[str, any] + :paramtype additional_properties: dict[str, JSON] """ - super(IntegrationRuntimeStatus, self).__init__(**kwargs) + super().__init__(**kwargs) self.additional_properties = additional_properties - self.type = 'IntegrationRuntimeStatus' # type: str + self.type = None # type: Optional[str] self.data_factory_name = None self.state = None -class IntegrationRuntimeStatusResponse(msrest.serialization.Model): +class IntegrationRuntimeStatusResponse(_serialization.Model): """Integration runtime status response. Variables are only populated by the server, and will be ignored when sending a request. @@ -4977,41 +4767,36 @@ class IntegrationRuntimeStatusResponse(msrest.serialization.Model): :ivar name: The integration runtime name. :vartype name: str - :ivar properties: Required. Integration runtime properties. + :ivar properties: Integration runtime properties. Required. :vartype properties: ~azure.mgmt.synapse.models.IntegrationRuntimeStatus """ _validation = { - 'name': {'readonly': True}, - 'properties': {'required': True}, + "name": {"readonly": True}, + "properties": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'IntegrationRuntimeStatus'}, + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "IntegrationRuntimeStatus"}, } - def __init__( - self, - *, - properties: "IntegrationRuntimeStatus", - **kwargs - ): + def __init__(self, *, properties: "_models.IntegrationRuntimeStatus", **kwargs): """ - :keyword properties: Required. Integration runtime properties. + :keyword properties: Integration runtime properties. Required. :paramtype properties: ~azure.mgmt.synapse.models.IntegrationRuntimeStatus """ - super(IntegrationRuntimeStatusResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = None self.properties = properties -class IntegrationRuntimeVNetProperties(msrest.serialization.Model): +class IntegrationRuntimeVNetProperties(_serialization.Model): """VNet properties for managed integration runtime. :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :vartype additional_properties: dict[str, any] + :vartype additional_properties: dict[str, JSON] :ivar v_net_id: The ID of the VNet that this integration runtime will join. :vartype v_net_id: str :ivar subnet: The name of the subnet this integration runtime will join. @@ -5024,17 +4809,17 @@ class IntegrationRuntimeVNetProperties(msrest.serialization.Model): """ _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'v_net_id': {'key': 'vNetId', 'type': 'str'}, - 'subnet': {'key': 'subnet', 'type': 'str'}, - 'public_i_ps': {'key': 'publicIPs', 'type': '[str]'}, - 'subnet_id': {'key': 'subnetId', 'type': 'str'}, + "additional_properties": {"key": "", "type": "{object}"}, + "v_net_id": {"key": "vNetId", "type": "str"}, + "subnet": {"key": "subnet", "type": "str"}, + "public_i_ps": {"key": "publicIPs", "type": "[str]"}, + "subnet_id": {"key": "subnetId", "type": "str"}, } def __init__( self, *, - additional_properties: Optional[Dict[str, Any]] = None, + additional_properties: Optional[Dict[str, JSON]] = None, v_net_id: Optional[str] = None, subnet: Optional[str] = None, public_i_ps: Optional[List[str]] = None, @@ -5044,7 +4829,7 @@ def __init__( """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. - :paramtype additional_properties: dict[str, any] + :paramtype additional_properties: dict[str, JSON] :keyword v_net_id: The ID of the VNet that this integration runtime will join. :paramtype v_net_id: str :keyword subnet: The name of the subnet this integration runtime will join. @@ -5056,7 +4841,7 @@ def __init__( joined. :paramtype subnet_id: str """ - super(IntegrationRuntimeVNetProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.additional_properties = additional_properties self.v_net_id = v_net_id self.subnet = subnet @@ -5064,7 +4849,7 @@ def __init__( self.subnet_id = subnet_id -class IotHubDataConnection(DataConnection): +class IotHubDataConnection(DataConnection): # pylint: disable=too-many-instance-attributes """Class representing an iot hub data connection. Variables are only populated by the server, and will be ignored when sending a request. @@ -5081,8 +4866,8 @@ class IotHubDataConnection(DataConnection): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar kind: Required. Kind of the endpoint for the data connection.Constant filled by server. - Possible values include: "EventHub", "EventGrid", "IotHub". + :ivar kind: Kind of the endpoint for the data connection. Required. Known values are: + "EventHub", "EventGrid", and "IotHub". :vartype kind: str or ~azure.mgmt.synapse.models.DataConnectionKind :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. @@ -5099,43 +4884,42 @@ class IotHubDataConnection(DataConnection): information can be added to each message. :vartype mapping_rule_name: str :ivar data_format: The data format of the message. Optionally the data format can be added to - each message. Possible values include: "MULTIJSON", "JSON", "CSV", "TSV", "SCSV", "SOHSV", - "PSV", "TXT", "RAW", "SINGLEJSON", "AVRO", "TSVE", "PARQUET", "ORC", "APACHEAVRO", - "W3CLOGFILE". + each message. Known values are: "MULTIJSON", "JSON", "CSV", "TSV", "SCSV", "SOHSV", "PSV", + "TXT", "RAW", "SINGLEJSON", "AVRO", "TSVE", "PARQUET", "ORC", "APACHEAVRO", and "W3CLOGFILE". :vartype data_format: str or ~azure.mgmt.synapse.models.IotHubDataFormat :ivar event_system_properties: System properties of the iot hub. :vartype event_system_properties: list[str] :ivar shared_access_policy_name: The name of the share access policy. :vartype shared_access_policy_name: str - :ivar provisioning_state: The provisioned state of the resource. Possible values include: - "Running", "Creating", "Deleting", "Succeeded", "Failed", "Moving", "Canceled". + :ivar provisioning_state: The provisioned state of the resource. Known values are: "Running", + "Creating", "Deleting", "Succeeded", "Failed", "Moving", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.synapse.models.ResourceProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'iot_hub_resource_id': {'key': 'properties.iotHubResourceId', 'type': 'str'}, - 'consumer_group': {'key': 'properties.consumerGroup', 'type': 'str'}, - 'table_name': {'key': 'properties.tableName', 'type': 'str'}, - 'mapping_rule_name': {'key': 'properties.mappingRuleName', 'type': 'str'}, - 'data_format': {'key': 'properties.dataFormat', 'type': 'str'}, - 'event_system_properties': {'key': 'properties.eventSystemProperties', 'type': '[str]'}, - 'shared_access_policy_name': {'key': 'properties.sharedAccessPolicyName', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "iot_hub_resource_id": {"key": "properties.iotHubResourceId", "type": "str"}, + "consumer_group": {"key": "properties.consumerGroup", "type": "str"}, + "table_name": {"key": "properties.tableName", "type": "str"}, + "mapping_rule_name": {"key": "properties.mappingRuleName", "type": "str"}, + "data_format": {"key": "properties.dataFormat", "type": "str"}, + "event_system_properties": {"key": "properties.eventSystemProperties", "type": "[str]"}, + "shared_access_policy_name": {"key": "properties.sharedAccessPolicyName", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -5146,7 +4930,7 @@ def __init__( consumer_group: Optional[str] = None, table_name: Optional[str] = None, mapping_rule_name: Optional[str] = None, - data_format: Optional[Union[str, "IotHubDataFormat"]] = None, + data_format: Optional[Union[str, "_models.IotHubDataFormat"]] = None, event_system_properties: Optional[List[str]] = None, shared_access_policy_name: Optional[str] = None, **kwargs @@ -5166,17 +4950,16 @@ def __init__( mapping information can be added to each message. :paramtype mapping_rule_name: str :keyword data_format: The data format of the message. Optionally the data format can be added - to each message. Possible values include: "MULTIJSON", "JSON", "CSV", "TSV", "SCSV", "SOHSV", - "PSV", "TXT", "RAW", "SINGLEJSON", "AVRO", "TSVE", "PARQUET", "ORC", "APACHEAVRO", - "W3CLOGFILE". + to each message. Known values are: "MULTIJSON", "JSON", "CSV", "TSV", "SCSV", "SOHSV", "PSV", + "TXT", "RAW", "SINGLEJSON", "AVRO", "TSVE", "PARQUET", "ORC", "APACHEAVRO", and "W3CLOGFILE". :paramtype data_format: str or ~azure.mgmt.synapse.models.IotHubDataFormat :keyword event_system_properties: System properties of the iot hub. :paramtype event_system_properties: list[str] :keyword shared_access_policy_name: The name of the share access policy. :paramtype shared_access_policy_name: str """ - super(IotHubDataConnection, self).__init__(location=location, **kwargs) - self.kind = 'IotHub' # type: str + super().__init__(location=location, **kwargs) + self.kind = "IotHub" # type: str self.iot_hub_resource_id = iot_hub_resource_id self.consumer_group = consumer_group self.table_name = table_name @@ -5203,36 +4986,30 @@ class IpFirewallRuleInfo(ProxyResource): :ivar end_ip_address: The end IP address of the firewall rule. Must be IPv4 format. Must be greater than or equal to startIpAddress. :vartype end_ip_address: str - :ivar provisioning_state: Resource provisioning state. Possible values include: "Provisioning", - "Succeeded", "Deleting", "Failed", "DeleteError". + :ivar provisioning_state: Resource provisioning state. Known values are: "Provisioning", + "Succeeded", "Deleting", "Failed", and "DeleteError". :vartype provisioning_state: str or ~azure.mgmt.synapse.models.ProvisioningState :ivar start_ip_address: The start IP address of the firewall rule. Must be IPv4 format. :vartype start_ip_address: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'end_ip_address': {'key': 'properties.endIpAddress', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'start_ip_address': {'key': 'properties.startIpAddress', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "end_ip_address": {"key": "properties.endIpAddress", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "start_ip_address": {"key": "properties.startIpAddress", "type": "str"}, } - def __init__( - self, - *, - end_ip_address: Optional[str] = None, - start_ip_address: Optional[str] = None, - **kwargs - ): + def __init__(self, *, end_ip_address: Optional[str] = None, start_ip_address: Optional[str] = None, **kwargs): """ :keyword end_ip_address: The end IP address of the firewall rule. Must be IPv4 format. Must be greater than or equal to startIpAddress. @@ -5240,13 +5017,13 @@ def __init__( :keyword start_ip_address: The start IP address of the firewall rule. Must be IPv4 format. :paramtype start_ip_address: str """ - super(IpFirewallRuleInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.end_ip_address = end_ip_address self.provisioning_state = None self.start_ip_address = start_ip_address -class IpFirewallRuleInfoListResult(msrest.serialization.Model): +class IpFirewallRuleInfoListResult(_serialization.Model): """List of IP firewall rules. :ivar next_link: Link to next page of results. @@ -5256,16 +5033,12 @@ class IpFirewallRuleInfoListResult(msrest.serialization.Model): """ _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[IpFirewallRuleInfo]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[IpFirewallRuleInfo]"}, } def __init__( - self, - *, - next_link: Optional[str] = None, - value: Optional[List["IpFirewallRuleInfo"]] = None, - **kwargs + self, *, next_link: Optional[str] = None, value: Optional[List["_models.IpFirewallRuleInfo"]] = None, **kwargs ): """ :keyword next_link: Link to next page of results. @@ -5273,12 +5046,12 @@ def __init__( :keyword value: List of IP firewall rules. :paramtype value: list[~azure.mgmt.synapse.models.IpFirewallRuleInfo] """ - super(IpFirewallRuleInfoListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.next_link = next_link self.value = value -class IpFirewallRuleProperties(msrest.serialization.Model): +class IpFirewallRuleProperties(_serialization.Model): """IP firewall rule properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -5286,30 +5059,24 @@ class IpFirewallRuleProperties(msrest.serialization.Model): :ivar end_ip_address: The end IP address of the firewall rule. Must be IPv4 format. Must be greater than or equal to startIpAddress. :vartype end_ip_address: str - :ivar provisioning_state: Resource provisioning state. Possible values include: "Provisioning", - "Succeeded", "Deleting", "Failed", "DeleteError". + :ivar provisioning_state: Resource provisioning state. Known values are: "Provisioning", + "Succeeded", "Deleting", "Failed", and "DeleteError". :vartype provisioning_state: str or ~azure.mgmt.synapse.models.ProvisioningState :ivar start_ip_address: The start IP address of the firewall rule. Must be IPv4 format. :vartype start_ip_address: str """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'end_ip_address': {'key': 'endIpAddress', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'start_ip_address': {'key': 'startIpAddress', 'type': 'str'}, + "end_ip_address": {"key": "endIpAddress", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "start_ip_address": {"key": "startIpAddress", "type": "str"}, } - def __init__( - self, - *, - end_ip_address: Optional[str] = None, - start_ip_address: Optional[str] = None, - **kwargs - ): + def __init__(self, *, end_ip_address: Optional[str] = None, start_ip_address: Optional[str] = None, **kwargs): """ :keyword end_ip_address: The end IP address of the firewall rule. Must be IPv4 format. Must be greater than or equal to startIpAddress. @@ -5317,13 +5084,13 @@ def __init__( :keyword start_ip_address: The start IP address of the firewall rule. Must be IPv4 format. :paramtype start_ip_address: str """ - super(IpFirewallRuleProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.end_ip_address = end_ip_address self.provisioning_state = None self.start_ip_address = start_ip_address -class KekIdentityProperties(msrest.serialization.Model): +class KekIdentityProperties(_serialization.Model): """Key encryption key properties. :ivar user_assigned_identity: User assigned identity resource Id. @@ -5334,8 +5101,8 @@ class KekIdentityProperties(msrest.serialization.Model): """ _attribute_map = { - 'user_assigned_identity': {'key': 'userAssignedIdentity', 'type': 'str'}, - 'use_system_assigned_identity': {'key': 'useSystemAssignedIdentity', 'type': 'object'}, + "user_assigned_identity": {"key": "userAssignedIdentity", "type": "str"}, + "use_system_assigned_identity": {"key": "useSystemAssignedIdentity", "type": "object"}, } def __init__( @@ -5352,7 +5119,7 @@ def __init__( identity or not. :paramtype use_system_assigned_identity: any """ - super(KekIdentityProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.user_assigned_identity = user_assigned_identity self.use_system_assigned_identity = use_system_assigned_identity @@ -5377,26 +5144,20 @@ class Key(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'is_active_cmk': {'key': 'properties.isActiveCMK', 'type': 'bool'}, - 'key_vault_url': {'key': 'properties.keyVaultUrl', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "is_active_cmk": {"key": "properties.isActiveCMK", "type": "bool"}, + "key_vault_url": {"key": "properties.keyVaultUrl", "type": "str"}, } - def __init__( - self, - *, - is_active_cmk: Optional[bool] = None, - key_vault_url: Optional[str] = None, - **kwargs - ): + def __init__(self, *, is_active_cmk: Optional[bool] = None, key_vault_url: Optional[str] = None, **kwargs): """ :keyword is_active_cmk: Used to activate the workspace after a customer managed key is provided. @@ -5404,12 +5165,12 @@ def __init__( :keyword key_vault_url: The Key Vault Url of the workspace key. :paramtype key_vault_url: str """ - super(Key, self).__init__(**kwargs) + super().__init__(**kwargs) self.is_active_cmk = is_active_cmk self.key_vault_url = key_vault_url -class KeyInfoListResult(msrest.serialization.Model): +class KeyInfoListResult(_serialization.Model): """List of keys. :ivar next_link: Link to the next page of results. @@ -5419,29 +5180,23 @@ class KeyInfoListResult(msrest.serialization.Model): """ _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[Key]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[Key]"}, } - def __init__( - self, - *, - next_link: Optional[str] = None, - value: Optional[List["Key"]] = None, - **kwargs - ): + def __init__(self, *, next_link: Optional[str] = None, value: Optional[List["_models.Key"]] = None, **kwargs): """ :keyword next_link: Link to the next page of results. :paramtype next_link: str :keyword value: List of keys. :paramtype value: list[~azure.mgmt.synapse.models.Key] """ - super(KeyInfoListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.next_link = next_link self.value = value -class KustoPool(TrackedResource): +class KustoPool(TrackedResource): # pylint: disable=too-many-instance-attributes """Class representing a Kusto kusto pool. Variables are only populated by the server, and will be ignored when sending a request. @@ -5456,22 +5211,22 @@ class KustoPool(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str - :ivar sku: Required. The SKU of the kusto pool. + :ivar sku: The SKU of the kusto pool. Required. :vartype sku: ~azure.mgmt.synapse.models.AzureSku :ivar etag: A unique read-only string that changes whenever the resource is updated. :vartype etag: str :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.synapse.models.SystemData - :ivar state: The state of the resource. Possible values include: "Creating", "Unavailable", - "Running", "Deleting", "Deleted", "Stopping", "Stopped", "Starting", "Updating". + :ivar state: The state of the resource. Known values are: "Creating", "Unavailable", "Running", + "Deleting", "Deleted", "Stopping", "Stopped", "Starting", and "Updating". :vartype state: str or ~azure.mgmt.synapse.models.State - :ivar provisioning_state: The provisioned state of the resource. Possible values include: - "Running", "Creating", "Deleting", "Succeeded", "Failed", "Moving", "Canceled". + :ivar provisioning_state: The provisioned state of the resource. Known values are: "Running", + "Creating", "Deleting", "Succeeded", "Failed", "Moving", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.synapse.models.ResourceProvisioningState :ivar uri: The Kusto Pool URI. :vartype uri: str @@ -5493,60 +5248,60 @@ class KustoPool(TrackedResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'sku': {'required': True}, - 'etag': {'readonly': True}, - 'system_data': {'readonly': True}, - 'state': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'uri': {'readonly': True}, - 'data_ingestion_uri': {'readonly': True}, - 'state_reason': {'readonly': True}, - 'language_extensions': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'AzureSku'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'uri': {'key': 'properties.uri', 'type': 'str'}, - 'data_ingestion_uri': {'key': 'properties.dataIngestionUri', 'type': 'str'}, - 'state_reason': {'key': 'properties.stateReason', 'type': 'str'}, - 'optimized_autoscale': {'key': 'properties.optimizedAutoscale', 'type': 'OptimizedAutoscale'}, - 'enable_streaming_ingest': {'key': 'properties.enableStreamingIngest', 'type': 'bool'}, - 'enable_purge': {'key': 'properties.enablePurge', 'type': 'bool'}, - 'language_extensions': {'key': 'properties.languageExtensions', 'type': 'LanguageExtensionsList'}, - 'workspace_uid': {'key': 'properties.workspaceUID', 'type': 'str'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "sku": {"required": True}, + "etag": {"readonly": True}, + "system_data": {"readonly": True}, + "state": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "uri": {"readonly": True}, + "data_ingestion_uri": {"readonly": True}, + "state_reason": {"readonly": True}, + "language_extensions": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "sku": {"key": "sku", "type": "AzureSku"}, + "etag": {"key": "etag", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "state": {"key": "properties.state", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "uri": {"key": "properties.uri", "type": "str"}, + "data_ingestion_uri": {"key": "properties.dataIngestionUri", "type": "str"}, + "state_reason": {"key": "properties.stateReason", "type": "str"}, + "optimized_autoscale": {"key": "properties.optimizedAutoscale", "type": "OptimizedAutoscale"}, + "enable_streaming_ingest": {"key": "properties.enableStreamingIngest", "type": "bool"}, + "enable_purge": {"key": "properties.enablePurge", "type": "bool"}, + "language_extensions": {"key": "properties.languageExtensions", "type": "LanguageExtensionsList"}, + "workspace_uid": {"key": "properties.workspaceUID", "type": "str"}, } def __init__( self, *, location: str, - sku: "AzureSku", + sku: "_models.AzureSku", tags: Optional[Dict[str, str]] = None, - optimized_autoscale: Optional["OptimizedAutoscale"] = None, - enable_streaming_ingest: Optional[bool] = False, - enable_purge: Optional[bool] = False, + optimized_autoscale: Optional["_models.OptimizedAutoscale"] = None, + enable_streaming_ingest: bool = False, + enable_purge: bool = False, workspace_uid: Optional[str] = None, **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str - :keyword sku: Required. The SKU of the kusto pool. + :keyword sku: The SKU of the kusto pool. Required. :paramtype sku: ~azure.mgmt.synapse.models.AzureSku :keyword optimized_autoscale: Optimized auto scale definition. :paramtype optimized_autoscale: ~azure.mgmt.synapse.models.OptimizedAutoscale @@ -5558,7 +5313,7 @@ def __init__( :keyword workspace_uid: The workspace unique identifier. :paramtype workspace_uid: str """ - super(KustoPool, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.sku = sku self.etag = None self.system_data = None @@ -5574,47 +5329,42 @@ def __init__( self.workspace_uid = workspace_uid -class KustoPoolCheckNameRequest(msrest.serialization.Model): +class KustoPoolCheckNameRequest(_serialization.Model): """The object sent for a kusto pool check name availability request. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Kusto Pool name. + :ivar name: Kusto Pool name. Required. :vartype name: str - :ivar type: The type of resource, Microsoft.Synapse/workspaces/kustoPools. Has constant value: - "Microsoft.Synapse/workspaces/kustoPools". + :ivar type: The type of resource, Microsoft.Synapse/workspaces/kustoPools. Required. Default + value is "Microsoft.Synapse/workspaces/kustoPools". :vartype type: str """ _validation = { - 'name': {'required': True}, - 'type': {'required': True, 'constant': True}, + "name": {"required": True}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "Microsoft.Synapse/workspaces/kustoPools" - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. Kusto Pool name. + :keyword name: Kusto Pool name. Required. :paramtype name: str """ - super(KustoPoolCheckNameRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class KustoPoolListResult(msrest.serialization.Model): +class KustoPoolListResult(_serialization.Model): """The list Kusto pools operation response. :ivar value: The list of Kusto pools. @@ -5622,24 +5372,19 @@ class KustoPoolListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[KustoPool]'}, + "value": {"key": "value", "type": "[KustoPool]"}, } - def __init__( - self, - *, - value: Optional[List["KustoPool"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.KustoPool"]] = None, **kwargs): """ :keyword value: The list of Kusto pools. :paramtype value: list[~azure.mgmt.synapse.models.KustoPool] """ - super(KustoPoolListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class KustoPoolUpdate(Resource): +class KustoPoolUpdate(Resource): # pylint: disable=too-many-instance-attributes """Class representing an update to a Kusto kusto pool. Variables are only populated by the server, and will be ignored when sending a request. @@ -5652,15 +5397,15 @@ class KustoPoolUpdate(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar sku: The SKU of the kusto pool. :vartype sku: ~azure.mgmt.synapse.models.AzureSku - :ivar state: The state of the resource. Possible values include: "Creating", "Unavailable", - "Running", "Deleting", "Deleted", "Stopping", "Stopped", "Starting", "Updating". + :ivar state: The state of the resource. Known values are: "Creating", "Unavailable", "Running", + "Deleting", "Deleted", "Stopping", "Stopped", "Starting", and "Updating". :vartype state: str or ~azure.mgmt.synapse.models.State - :ivar provisioning_state: The provisioned state of the resource. Possible values include: - "Running", "Creating", "Deleting", "Succeeded", "Failed", "Moving", "Canceled". + :ivar provisioning_state: The provisioned state of the resource. Known values are: "Running", + "Creating", "Deleting", "Succeeded", "Failed", "Moving", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.synapse.models.ResourceProvisioningState :ivar uri: The Kusto Pool URI. :vartype uri: str @@ -5682,48 +5427,48 @@ class KustoPoolUpdate(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'state': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'uri': {'readonly': True}, - 'data_ingestion_uri': {'readonly': True}, - 'state_reason': {'readonly': True}, - 'language_extensions': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "state": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "uri": {"readonly": True}, + "data_ingestion_uri": {"readonly": True}, + "state_reason": {"readonly": True}, + "language_extensions": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'sku', 'type': 'AzureSku'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'uri': {'key': 'properties.uri', 'type': 'str'}, - 'data_ingestion_uri': {'key': 'properties.dataIngestionUri', 'type': 'str'}, - 'state_reason': {'key': 'properties.stateReason', 'type': 'str'}, - 'optimized_autoscale': {'key': 'properties.optimizedAutoscale', 'type': 'OptimizedAutoscale'}, - 'enable_streaming_ingest': {'key': 'properties.enableStreamingIngest', 'type': 'bool'}, - 'enable_purge': {'key': 'properties.enablePurge', 'type': 'bool'}, - 'language_extensions': {'key': 'properties.languageExtensions', 'type': 'LanguageExtensionsList'}, - 'workspace_uid': {'key': 'properties.workspaceUID', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "sku": {"key": "sku", "type": "AzureSku"}, + "state": {"key": "properties.state", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "uri": {"key": "properties.uri", "type": "str"}, + "data_ingestion_uri": {"key": "properties.dataIngestionUri", "type": "str"}, + "state_reason": {"key": "properties.stateReason", "type": "str"}, + "optimized_autoscale": {"key": "properties.optimizedAutoscale", "type": "OptimizedAutoscale"}, + "enable_streaming_ingest": {"key": "properties.enableStreamingIngest", "type": "bool"}, + "enable_purge": {"key": "properties.enablePurge", "type": "bool"}, + "language_extensions": {"key": "properties.languageExtensions", "type": "LanguageExtensionsList"}, + "workspace_uid": {"key": "properties.workspaceUID", "type": "str"}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["AzureSku"] = None, - optimized_autoscale: Optional["OptimizedAutoscale"] = None, - enable_streaming_ingest: Optional[bool] = False, - enable_purge: Optional[bool] = False, + sku: Optional["_models.AzureSku"] = None, + optimized_autoscale: Optional["_models.OptimizedAutoscale"] = None, + enable_streaming_ingest: bool = False, + enable_purge: bool = False, workspace_uid: Optional[str] = None, **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword sku: The SKU of the kusto pool. :paramtype sku: ~azure.mgmt.synapse.models.AzureSku @@ -5737,7 +5482,7 @@ def __init__( :keyword workspace_uid: The workspace unique identifier. :paramtype workspace_uid: str """ - super(KustoPoolUpdate, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.sku = sku self.state = None @@ -5752,34 +5497,30 @@ def __init__( self.workspace_uid = workspace_uid -class LanguageExtension(msrest.serialization.Model): +class LanguageExtension(_serialization.Model): """The language extension object. - :ivar language_extension_name: The language extension name. Possible values include: "PYTHON", - "R". + :ivar language_extension_name: The language extension name. Known values are: "PYTHON" and "R". :vartype language_extension_name: str or ~azure.mgmt.synapse.models.LanguageExtensionName """ _attribute_map = { - 'language_extension_name': {'key': 'languageExtensionName', 'type': 'str'}, + "language_extension_name": {"key": "languageExtensionName", "type": "str"}, } def __init__( - self, - *, - language_extension_name: Optional[Union[str, "LanguageExtensionName"]] = None, - **kwargs + self, *, language_extension_name: Optional[Union[str, "_models.LanguageExtensionName"]] = None, **kwargs ): """ - :keyword language_extension_name: The language extension name. Possible values include: - "PYTHON", "R". + :keyword language_extension_name: The language extension name. Known values are: "PYTHON" and + "R". :paramtype language_extension_name: str or ~azure.mgmt.synapse.models.LanguageExtensionName """ - super(LanguageExtension, self).__init__(**kwargs) + super().__init__(**kwargs) self.language_extension_name = language_extension_name -class LanguageExtensionsList(msrest.serialization.Model): +class LanguageExtensionsList(_serialization.Model): """The list of language extension objects. :ivar value: The list of language extensions. @@ -5787,24 +5528,19 @@ class LanguageExtensionsList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[LanguageExtension]'}, + "value": {"key": "value", "type": "[LanguageExtension]"}, } - def __init__( - self, - *, - value: Optional[List["LanguageExtension"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.LanguageExtension"]] = None, **kwargs): """ :keyword value: The list of language extensions. :paramtype value: list[~azure.mgmt.synapse.models.LanguageExtension] """ - super(LanguageExtensionsList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class LibraryInfo(msrest.serialization.Model): +class LibraryInfo(_serialization.Model): """Library/package information of a Big Data pool powered by Apache Spark. Variables are only populated by the server, and will be ignored when sending a request. @@ -5826,18 +5562,18 @@ class LibraryInfo(msrest.serialization.Model): """ _validation = { - 'provisioning_status': {'readonly': True}, - 'creator_id': {'readonly': True}, + "provisioning_status": {"readonly": True}, + "creator_id": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'path': {'key': 'path', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, - 'uploaded_timestamp': {'key': 'uploadedTimestamp', 'type': 'iso-8601'}, - 'type': {'key': 'type', 'type': 'str'}, - 'provisioning_status': {'key': 'provisioningStatus', 'type': 'str'}, - 'creator_id': {'key': 'creatorId', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "path": {"key": "path", "type": "str"}, + "container_name": {"key": "containerName", "type": "str"}, + "uploaded_timestamp": {"key": "uploadedTimestamp", "type": "iso-8601"}, + "type": {"key": "type", "type": "str"}, + "provisioning_status": {"key": "provisioningStatus", "type": "str"}, + "creator_id": {"key": "creatorId", "type": "str"}, } def __init__( @@ -5862,7 +5598,7 @@ def __init__( :keyword type: Type of the library. :paramtype type: str """ - super(LibraryInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.path = path self.container_name = container_name @@ -5872,45 +5608,39 @@ def __init__( self.creator_id = None -class LibraryListResponse(msrest.serialization.Model): +class LibraryListResponse(_serialization.Model): """A list of Library resources. All required parameters must be populated in order to send to Azure. - :ivar value: Required. List of Library. + :ivar value: List of Library. Required. :vartype value: list[~azure.mgmt.synapse.models.LibraryResource] :ivar next_link: The link to the next page of results, if any remaining results exist. :vartype next_link: str """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[LibraryResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[LibraryResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: List["LibraryResource"], - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: List["_models.LibraryResource"], next_link: Optional[str] = None, **kwargs): """ - :keyword value: Required. List of Library. + :keyword value: List of Library. Required. :paramtype value: list[~azure.mgmt.synapse.models.LibraryResource] :keyword next_link: The link to the next page of results, if any remaining results exist. :paramtype next_link: str """ - super(LibraryListResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class LibraryRequirements(msrest.serialization.Model): +class LibraryRequirements(_serialization.Model): """Library requirements for a Big Data pool powered by Apache Spark. Variables are only populated by the server, and will be ignored when sending a request. @@ -5924,35 +5654,29 @@ class LibraryRequirements(msrest.serialization.Model): """ _validation = { - 'time': {'readonly': True}, + "time": {"readonly": True}, } _attribute_map = { - 'time': {'key': 'time', 'type': 'iso-8601'}, - 'content': {'key': 'content', 'type': 'str'}, - 'filename': {'key': 'filename', 'type': 'str'}, + "time": {"key": "time", "type": "iso-8601"}, + "content": {"key": "content", "type": "str"}, + "filename": {"key": "filename", "type": "str"}, } - def __init__( - self, - *, - content: Optional[str] = None, - filename: Optional[str] = None, - **kwargs - ): + def __init__(self, *, content: Optional[str] = None, filename: Optional[str] = None, **kwargs): """ :keyword content: The library requirements. :paramtype content: str :keyword filename: The filename of the library requirements file. :paramtype filename: str """ - super(LibraryRequirements, self).__init__(**kwargs) + super().__init__(**kwargs) self.time = None self.content = content self.filename = filename -class LibraryResource(SubResource): +class LibraryResource(SubResource): # pylint: disable=too-many-instance-attributes """Library response details. Variables are only populated by the server, and will be ignored when sending a request. @@ -5984,26 +5708,26 @@ class LibraryResource(SubResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'provisioning_status': {'readonly': True}, - 'creator_id': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "provisioning_status": {"readonly": True}, + "creator_id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'name_properties_name': {'key': 'properties.name', 'type': 'str'}, - 'path': {'key': 'properties.path', 'type': 'str'}, - 'container_name': {'key': 'properties.containerName', 'type': 'str'}, - 'uploaded_timestamp': {'key': 'properties.uploadedTimestamp', 'type': 'iso-8601'}, - 'type_properties_type': {'key': 'properties.type', 'type': 'str'}, - 'provisioning_status': {'key': 'properties.provisioningStatus', 'type': 'str'}, - 'creator_id': {'key': 'properties.creatorId', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "name_properties_name": {"key": "properties.name", "type": "str"}, + "path": {"key": "properties.path", "type": "str"}, + "container_name": {"key": "properties.containerName", "type": "str"}, + "uploaded_timestamp": {"key": "properties.uploadedTimestamp", "type": "iso-8601"}, + "type_properties_type": {"key": "properties.type", "type": "str"}, + "provisioning_status": {"key": "properties.provisioningStatus", "type": "str"}, + "creator_id": {"key": "properties.creatorId", "type": "str"}, } def __init__( @@ -6028,7 +5752,7 @@ def __init__( :keyword type_properties_type: Type of the library. :paramtype type_properties_type: str """ - super(LibraryResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_properties_name = name_properties_name self.path = path self.container_name = container_name @@ -6038,7 +5762,7 @@ def __init__( self.creator_id = None -class LinkedIntegrationRuntime(msrest.serialization.Model): +class LinkedIntegrationRuntime(_serialization.Model): """The linked integration runtime information. Variables are only populated by the server, and will be ignored when sending a request. @@ -6058,28 +5782,24 @@ class LinkedIntegrationRuntime(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'subscription_id': {'readonly': True}, - 'data_factory_name': {'readonly': True}, - 'data_factory_location': {'readonly': True}, - 'create_time': {'readonly': True}, + "name": {"readonly": True}, + "subscription_id": {"readonly": True}, + "data_factory_name": {"readonly": True}, + "data_factory_location": {"readonly": True}, + "create_time": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'data_factory_name': {'key': 'dataFactoryName', 'type': 'str'}, - 'data_factory_location': {'key': 'dataFactoryLocation', 'type': 'str'}, - 'create_time': {'key': 'createTime', 'type': 'iso-8601'}, + "name": {"key": "name", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "data_factory_name": {"key": "dataFactoryName", "type": "str"}, + "data_factory_location": {"key": "dataFactoryLocation", "type": "str"}, + "create_time": {"key": "createTime", "type": "iso-8601"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(LinkedIntegrationRuntime, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.subscription_id = None self.data_factory_name = None @@ -6087,38 +5807,36 @@ def __init__( self.create_time = None -class LinkedIntegrationRuntimeType(msrest.serialization.Model): +class LinkedIntegrationRuntimeType(_serialization.Model): """The base definition of a linked integration runtime. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: LinkedIntegrationRuntimeKeyAuthorization, LinkedIntegrationRuntimeRbacAuthorization. + 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. - :ivar authorization_type: Required. The authorization type for integration runtime - sharing.Constant filled by server. + :ivar authorization_type: The authorization type for integration runtime sharing. Required. :vartype authorization_type: str """ _validation = { - 'authorization_type': {'required': True}, + "authorization_type": {"required": True}, } _attribute_map = { - 'authorization_type': {'key': 'authorizationType', 'type': 'str'}, + "authorization_type": {"key": "authorizationType", "type": "str"}, } _subtype_map = { - 'authorization_type': {'Key': 'LinkedIntegrationRuntimeKeyAuthorization', 'RBAC': 'LinkedIntegrationRuntimeRbacAuthorization'} + "authorization_type": { + "Key": "LinkedIntegrationRuntimeKeyAuthorization", + "RBAC": "LinkedIntegrationRuntimeRbacAuthorization", + } } - def __init__( - self, - **kwargs - ): - """ - """ - super(LinkedIntegrationRuntimeType, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.authorization_type = None # type: Optional[str] @@ -6127,35 +5845,29 @@ class LinkedIntegrationRuntimeKeyAuthorization(LinkedIntegrationRuntimeType): All required parameters must be populated in order to send to Azure. - :ivar authorization_type: Required. The authorization type for integration runtime - sharing.Constant filled by server. + :ivar authorization_type: The authorization type for integration runtime sharing. Required. :vartype authorization_type: str - :ivar key: Required. The key used for authorization. + :ivar key: The key used for authorization. Required. :vartype key: ~azure.mgmt.synapse.models.SecureString """ _validation = { - 'authorization_type': {'required': True}, - 'key': {'required': True}, + "authorization_type": {"required": True}, + "key": {"required": True}, } _attribute_map = { - 'authorization_type': {'key': 'authorizationType', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'SecureString'}, + "authorization_type": {"key": "authorizationType", "type": "str"}, + "key": {"key": "key", "type": "SecureString"}, } - def __init__( - self, - *, - key: "SecureString", - **kwargs - ): + def __init__(self, *, key: "_models.SecureString", **kwargs): """ - :keyword key: Required. The key used for authorization. + :keyword key: The key used for authorization. Required. :paramtype key: ~azure.mgmt.synapse.models.SecureString """ - super(LinkedIntegrationRuntimeKeyAuthorization, self).__init__(**kwargs) - self.authorization_type = 'Key' # type: str + super().__init__(**kwargs) + self.authorization_type = "Key" # type: str self.key = key @@ -6164,40 +5876,34 @@ class LinkedIntegrationRuntimeRbacAuthorization(LinkedIntegrationRuntimeType): All required parameters must be populated in order to send to Azure. - :ivar authorization_type: Required. The authorization type for integration runtime - sharing.Constant filled by server. + :ivar authorization_type: The authorization type for integration runtime sharing. Required. :vartype authorization_type: str - :ivar resource_id: Required. The resource identifier of the integration runtime to be shared. + :ivar resource_id: The resource identifier of the integration runtime to be shared. Required. :vartype resource_id: str """ _validation = { - 'authorization_type': {'required': True}, - 'resource_id': {'required': True}, + "authorization_type": {"required": True}, + "resource_id": {"required": True}, } _attribute_map = { - 'authorization_type': {'key': 'authorizationType', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, + "authorization_type": {"key": "authorizationType", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, } - def __init__( - self, - *, - resource_id: str, - **kwargs - ): + def __init__(self, *, resource_id: str, **kwargs): """ - :keyword resource_id: Required. The resource identifier of the integration runtime to be - shared. + :keyword resource_id: The resource identifier of the integration runtime to be shared. + Required. :paramtype resource_id: str """ - super(LinkedIntegrationRuntimeRbacAuthorization, self).__init__(**kwargs) - self.authorization_type = 'RBAC' # type: str + super().__init__(**kwargs) + self.authorization_type = "RBAC" # type: str self.resource_id = resource_id -class ListResourceSkusResult(msrest.serialization.Model): +class ListResourceSkusResult(_serialization.Model): """List of available SKUs for a Kusto Pool. :ivar value: The collection of available SKUs for an existing resource. @@ -6205,24 +5911,19 @@ class ListResourceSkusResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[AzureResourceSku]'}, + "value": {"key": "value", "type": "[AzureResourceSku]"}, } - def __init__( - self, - *, - value: Optional[List["AzureResourceSku"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.AzureResourceSku"]] = None, **kwargs): """ :keyword value: The collection of available SKUs for an existing resource. :paramtype value: list[~azure.mgmt.synapse.models.AzureResourceSku] """ - super(ListResourceSkusResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class ListSqlPoolSecurityAlertPolicies(msrest.serialization.Model): +class ListSqlPoolSecurityAlertPolicies(_serialization.Model): """A list of SQL pool security alert policies. Variables are only populated by the server, and will be ignored when sending a request. @@ -6234,22 +5935,18 @@ class ListSqlPoolSecurityAlertPolicies(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SqlPoolSecurityAlertPolicy]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SqlPoolSecurityAlertPolicy]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListSqlPoolSecurityAlertPolicies, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None @@ -6286,29 +5983,35 @@ class MaintenanceWindowOptions(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'is_enabled': {'key': 'properties.isEnabled', 'type': 'bool'}, - 'maintenance_window_cycles': {'key': 'properties.maintenanceWindowCycles', 'type': '[MaintenanceWindowTimeRange]'}, - 'min_duration_in_minutes': {'key': 'properties.minDurationInMinutes', 'type': 'int'}, - 'default_duration_in_minutes': {'key': 'properties.defaultDurationInMinutes', 'type': 'int'}, - 'min_cycles': {'key': 'properties.minCycles', 'type': 'int'}, - 'time_granularity_in_minutes': {'key': 'properties.timeGranularityInMinutes', 'type': 'int'}, - 'allow_multiple_maintenance_windows_per_cycle': {'key': 'properties.allowMultipleMaintenanceWindowsPerCycle', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "is_enabled": {"key": "properties.isEnabled", "type": "bool"}, + "maintenance_window_cycles": { + "key": "properties.maintenanceWindowCycles", + "type": "[MaintenanceWindowTimeRange]", + }, + "min_duration_in_minutes": {"key": "properties.minDurationInMinutes", "type": "int"}, + "default_duration_in_minutes": {"key": "properties.defaultDurationInMinutes", "type": "int"}, + "min_cycles": {"key": "properties.minCycles", "type": "int"}, + "time_granularity_in_minutes": {"key": "properties.timeGranularityInMinutes", "type": "int"}, + "allow_multiple_maintenance_windows_per_cycle": { + "key": "properties.allowMultipleMaintenanceWindowsPerCycle", + "type": "bool", + }, } def __init__( self, *, is_enabled: Optional[bool] = None, - maintenance_window_cycles: Optional[List["MaintenanceWindowTimeRange"]] = None, + maintenance_window_cycles: Optional[List["_models.MaintenanceWindowTimeRange"]] = None, min_duration_in_minutes: Optional[int] = None, default_duration_in_minutes: Optional[int] = None, min_cycles: Optional[int] = None, @@ -6335,7 +6038,7 @@ def __init__( windows per cycle. :paramtype allow_multiple_maintenance_windows_per_cycle: bool """ - super(MaintenanceWindowOptions, self).__init__(**kwargs) + super().__init__(**kwargs) self.is_enabled = is_enabled self.maintenance_window_cycles = maintenance_window_cycles self.min_duration_in_minutes = min_duration_in_minutes @@ -6363,37 +6066,32 @@ class MaintenanceWindows(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'time_ranges': {'key': 'properties.timeRanges', 'type': '[MaintenanceWindowTimeRange]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "time_ranges": {"key": "properties.timeRanges", "type": "[MaintenanceWindowTimeRange]"}, } - def __init__( - self, - *, - time_ranges: Optional[List["MaintenanceWindowTimeRange"]] = None, - **kwargs - ): + def __init__(self, *, time_ranges: Optional[List["_models.MaintenanceWindowTimeRange"]] = None, **kwargs): """ :keyword time_ranges: :paramtype time_ranges: list[~azure.mgmt.synapse.models.MaintenanceWindowTimeRange] """ - super(MaintenanceWindows, self).__init__(**kwargs) + super().__init__(**kwargs) self.time_ranges = time_ranges -class MaintenanceWindowTimeRange(msrest.serialization.Model): +class MaintenanceWindowTimeRange(_serialization.Model): """Maintenance window time range. - :ivar day_of_week: Day of maintenance window. Possible values include: "Sunday", "Monday", - "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday". + :ivar day_of_week: Day of maintenance window. Known values are: "Sunday", "Monday", "Tuesday", + "Wednesday", "Thursday", "Friday", and "Saturday". :vartype day_of_week: str or ~azure.mgmt.synapse.models.DayOfWeek :ivar start_time: Start time minutes offset from 12am. :vartype start_time: str @@ -6402,35 +6100,35 @@ class MaintenanceWindowTimeRange(msrest.serialization.Model): """ _attribute_map = { - 'day_of_week': {'key': 'dayOfWeek', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'str'}, - 'duration': {'key': 'duration', 'type': 'str'}, + "day_of_week": {"key": "dayOfWeek", "type": "str"}, + "start_time": {"key": "startTime", "type": "str"}, + "duration": {"key": "duration", "type": "str"}, } def __init__( self, *, - day_of_week: Optional[Union[str, "DayOfWeek"]] = None, + day_of_week: Optional[Union[str, "_models.DayOfWeek"]] = None, start_time: Optional[str] = None, duration: Optional[str] = None, **kwargs ): """ - :keyword day_of_week: Day of maintenance window. Possible values include: "Sunday", "Monday", - "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday". + :keyword day_of_week: Day of maintenance window. Known values are: "Sunday", "Monday", + "Tuesday", "Wednesday", "Thursday", "Friday", and "Saturday". :paramtype day_of_week: str or ~azure.mgmt.synapse.models.DayOfWeek :keyword start_time: Start time minutes offset from 12am. :paramtype start_time: str :keyword duration: Duration of maintenance window in minutes. :paramtype duration: str """ - super(MaintenanceWindowTimeRange, self).__init__(**kwargs) + super().__init__(**kwargs) self.day_of_week = day_of_week self.start_time = start_time self.duration = duration -class ManagedIdentity(msrest.serialization.Model): +class ManagedIdentity(_serialization.Model): """The workspace managed identity. Variables are only populated by the server, and will be ignored when sending a request. @@ -6439,8 +6137,8 @@ class ManagedIdentity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of the workspace managed identity. :vartype tenant_id: str - :ivar type: The type of managed identity for the workspace. Possible values include: "None", - "SystemAssigned", "SystemAssigned,UserAssigned". + :ivar type: The type of managed identity for the workspace. Known values are: "None", + "SystemAssigned", and "SystemAssigned,UserAssigned". :vartype type: str or ~azure.mgmt.synapse.models.ResourceIdentityType :ivar user_assigned_identities: The user assigned managed identities. :vartype user_assigned_identities: dict[str, @@ -6448,33 +6146,33 @@ class ManagedIdentity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserAssignedManagedIdentity}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedManagedIdentity}"}, } def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "UserAssignedManagedIdentity"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedManagedIdentity"]] = None, **kwargs ): """ - :keyword type: The type of managed identity for the workspace. Possible values include: "None", - "SystemAssigned", "SystemAssigned,UserAssigned". + :keyword type: The type of managed identity for the workspace. Known values are: "None", + "SystemAssigned", and "SystemAssigned,UserAssigned". :paramtype type: str or ~azure.mgmt.synapse.models.ResourceIdentityType :keyword user_assigned_identities: The user assigned managed identities. :paramtype user_assigned_identities: dict[str, ~azure.mgmt.synapse.models.UserAssignedManagedIdentity] """ - super(ManagedIdentity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type @@ -6500,22 +6198,27 @@ class ManagedIdentitySqlControlSettingsModel(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'grant_sql_control_to_managed_identity': {'key': 'properties.grantSqlControlToManagedIdentity', 'type': 'ManagedIdentitySqlControlSettingsModelPropertiesGrantSqlControlToManagedIdentity'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "grant_sql_control_to_managed_identity": { + "key": "properties.grantSqlControlToManagedIdentity", + "type": "ManagedIdentitySqlControlSettingsModelPropertiesGrantSqlControlToManagedIdentity", + }, } def __init__( self, *, - grant_sql_control_to_managed_identity: Optional["ManagedIdentitySqlControlSettingsModelPropertiesGrantSqlControlToManagedIdentity"] = None, + grant_sql_control_to_managed_identity: Optional[ + "_models.ManagedIdentitySqlControlSettingsModelPropertiesGrantSqlControlToManagedIdentity" + ] = None, **kwargs ): """ @@ -6523,45 +6226,37 @@ def __init__( :paramtype grant_sql_control_to_managed_identity: ~azure.mgmt.synapse.models.ManagedIdentitySqlControlSettingsModelPropertiesGrantSqlControlToManagedIdentity """ - super(ManagedIdentitySqlControlSettingsModel, self).__init__(**kwargs) + super().__init__(**kwargs) self.grant_sql_control_to_managed_identity = grant_sql_control_to_managed_identity -class ManagedIdentitySqlControlSettingsModelPropertiesGrantSqlControlToManagedIdentity(msrest.serialization.Model): +class ManagedIdentitySqlControlSettingsModelPropertiesGrantSqlControlToManagedIdentity(_serialization.Model): """Grant sql control to managed identity. Variables are only populated by the server, and will be ignored when sending a request. - :ivar desired_state: Desired state. Possible values include: "Enabled", "Disabled". - :vartype desired_state: str or - ~azure.mgmt.synapse.models.ManagedIdentitySqlControlSettingsModelPropertiesGrantSqlControlToManagedIdentityDesiredState - :ivar actual_state: Actual state. Possible values include: "Enabling", "Enabled", "Disabling", - "Disabled", "Unknown". - :vartype actual_state: str or - ~azure.mgmt.synapse.models.ManagedIdentitySqlControlSettingsModelPropertiesGrantSqlControlToManagedIdentityActualState + :ivar desired_state: Desired state. Known values are: "Enabled" and "Disabled". + :vartype desired_state: str or ~azure.mgmt.synapse.models.DesiredState + :ivar actual_state: Actual state. Known values are: "Enabling", "Enabled", "Disabling", + "Disabled", and "Unknown". + :vartype actual_state: str or ~azure.mgmt.synapse.models.ActualState """ _validation = { - 'actual_state': {'readonly': True}, + "actual_state": {"readonly": True}, } _attribute_map = { - 'desired_state': {'key': 'desiredState', 'type': 'str'}, - 'actual_state': {'key': 'actualState', 'type': 'str'}, + "desired_state": {"key": "desiredState", "type": "str"}, + "actual_state": {"key": "actualState", "type": "str"}, } - def __init__( - self, - *, - desired_state: Optional[Union[str, "ManagedIdentitySqlControlSettingsModelPropertiesGrantSqlControlToManagedIdentityDesiredState"]] = None, - **kwargs - ): + def __init__(self, *, desired_state: Optional[Union[str, "_models.DesiredState"]] = None, **kwargs): """ - :keyword desired_state: Desired state. Possible values include: "Enabled", "Disabled". - :paramtype desired_state: str or - ~azure.mgmt.synapse.models.ManagedIdentitySqlControlSettingsModelPropertiesGrantSqlControlToManagedIdentityDesiredState + :keyword desired_state: Desired state. Known values are: "Enabled" and "Disabled". + :paramtype desired_state: str or ~azure.mgmt.synapse.models.DesiredState """ - super(ManagedIdentitySqlControlSettingsModelPropertiesGrantSqlControlToManagedIdentity, self).__init__(**kwargs) + super().__init__(**kwargs) self.desired_state = desired_state self.actual_state = None @@ -6575,15 +6270,15 @@ class ManagedIntegrationRuntime(IntegrationRuntime): :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :vartype additional_properties: dict[str, any] - :ivar type: Required. Type of integration runtime.Constant filled by server. Possible values - include: "Managed", "SelfHosted". + :vartype additional_properties: dict[str, JSON] + :ivar type: Type of integration runtime. Required. Known values are: "Managed" and + "SelfHosted". :vartype type: str or ~azure.mgmt.synapse.models.IntegrationRuntimeType :ivar description: Integration runtime description. :vartype description: str :ivar state: Integration runtime state, only valid for managed dedicated integration runtime. - Possible values include: "Initial", "Stopped", "Started", "Starting", "Stopping", - "NeedRegistration", "Online", "Limited", "Offline", "AccessDenied". + Known values are: "Initial", "Stopped", "Started", "Starting", "Stopping", "NeedRegistration", + "Online", "Limited", "Offline", and "AccessDenied". :vartype state: str or ~azure.mgmt.synapse.models.IntegrationRuntimeState :ivar reference_name: The reference name of the managed virtual network. :vartype reference_name: str @@ -6598,38 +6293,41 @@ class ManagedIntegrationRuntime(IntegrationRuntime): """ _validation = { - 'type': {'required': True}, - 'state': {'readonly': True}, + "type": {"required": True}, + "state": {"readonly": True}, } _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'type': {'key': 'type', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'reference_name': {'key': 'managedVirtualNetwork.referenceName', 'type': 'str'}, - 'type_managed_virtual_network_type': {'key': 'managedVirtualNetwork.type', 'type': 'str'}, - 'id': {'key': 'managedVirtualNetwork.id', 'type': 'str'}, - 'compute_properties': {'key': 'typeProperties.computeProperties', 'type': 'IntegrationRuntimeComputeProperties'}, - 'ssis_properties': {'key': 'typeProperties.ssisProperties', 'type': 'IntegrationRuntimeSsisProperties'}, + "additional_properties": {"key": "", "type": "{object}"}, + "type": {"key": "type", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "reference_name": {"key": "managedVirtualNetwork.referenceName", "type": "str"}, + "type_managed_virtual_network_type": {"key": "managedVirtualNetwork.type", "type": "str"}, + "id": {"key": "managedVirtualNetwork.id", "type": "str"}, + "compute_properties": { + "key": "typeProperties.computeProperties", + "type": "IntegrationRuntimeComputeProperties", + }, + "ssis_properties": {"key": "typeProperties.ssisProperties", "type": "IntegrationRuntimeSsisProperties"}, } def __init__( self, *, - additional_properties: Optional[Dict[str, Any]] = None, + additional_properties: Optional[Dict[str, JSON]] = None, description: Optional[str] = None, reference_name: Optional[str] = None, type_managed_virtual_network_type: Optional[str] = None, - id: Optional[str] = None, - compute_properties: Optional["IntegrationRuntimeComputeProperties"] = None, - ssis_properties: Optional["IntegrationRuntimeSsisProperties"] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + compute_properties: Optional["_models.IntegrationRuntimeComputeProperties"] = None, + ssis_properties: Optional["_models.IntegrationRuntimeSsisProperties"] = None, **kwargs ): """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. - :paramtype additional_properties: dict[str, any] + :paramtype additional_properties: dict[str, JSON] :keyword description: Integration runtime description. :paramtype description: str :keyword reference_name: The reference name of the managed virtual network. @@ -6643,8 +6341,8 @@ def __init__( :keyword ssis_properties: SSIS properties for managed integration runtime. :paramtype ssis_properties: ~azure.mgmt.synapse.models.IntegrationRuntimeSsisProperties """ - super(ManagedIntegrationRuntime, self).__init__(additional_properties=additional_properties, description=description, **kwargs) - self.type = 'Managed' # type: str + super().__init__(additional_properties=additional_properties, description=description, **kwargs) + self.type = "Managed" # type: str self.state = None self.reference_name = reference_name self.type_managed_virtual_network_type = type_managed_virtual_network_type @@ -6653,14 +6351,14 @@ def __init__( self.ssis_properties = ssis_properties -class ManagedIntegrationRuntimeError(msrest.serialization.Model): +class ManagedIntegrationRuntimeError(_serialization.Model): """Error definition for managed integration runtime. Variables are only populated by the server, and will be ignored when sending a request. :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :vartype additional_properties: dict[str, any] + :vartype additional_properties: dict[str, JSON] :ivar time: The time when the error occurred. :vartype time: ~datetime.datetime :ivar code: Error code. @@ -6672,32 +6370,27 @@ class ManagedIntegrationRuntimeError(msrest.serialization.Model): """ _validation = { - 'time': {'readonly': True}, - 'code': {'readonly': True}, - 'parameters': {'readonly': True}, - 'message': {'readonly': True}, + "time": {"readonly": True}, + "code": {"readonly": True}, + "parameters": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'time': {'key': 'time', 'type': 'iso-8601'}, - 'code': {'key': 'code', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': '[str]'}, - 'message': {'key': 'message', 'type': 'str'}, + "additional_properties": {"key": "", "type": "{object}"}, + "time": {"key": "time", "type": "iso-8601"}, + "code": {"key": "code", "type": "str"}, + "parameters": {"key": "parameters", "type": "[str]"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - additional_properties: Optional[Dict[str, Any]] = None, - **kwargs - ): + def __init__(self, *, additional_properties: Optional[Dict[str, JSON]] = None, **kwargs): """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. - :paramtype additional_properties: dict[str, any] + :paramtype additional_properties: dict[str, JSON] """ - super(ManagedIntegrationRuntimeError, self).__init__(**kwargs) + super().__init__(**kwargs) self.additional_properties = additional_properties self.time = None self.code = None @@ -6705,64 +6398,64 @@ def __init__( self.message = None -class ManagedIntegrationRuntimeNode(msrest.serialization.Model): +class ManagedIntegrationRuntimeNode(_serialization.Model): """Properties of integration runtime node. Variables are only populated by the server, and will be ignored when sending a request. :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :vartype additional_properties: dict[str, any] + :vartype additional_properties: dict[str, JSON] :ivar node_id: The managed integration runtime node id. :vartype node_id: str - :ivar status: The managed integration runtime node status. Possible values include: "Starting", - "Available", "Recycling", "Unavailable". + :ivar status: The managed integration runtime node status. Known values are: "Starting", + "Available", "Recycling", and "Unavailable". :vartype status: str or ~azure.mgmt.synapse.models.ManagedIntegrationRuntimeNodeStatus :ivar errors: The errors that occurred on this integration runtime node. :vartype errors: list[~azure.mgmt.synapse.models.ManagedIntegrationRuntimeError] """ _validation = { - 'node_id': {'readonly': True}, - 'status': {'readonly': True}, + "node_id": {"readonly": True}, + "status": {"readonly": True}, } _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'node_id': {'key': 'nodeId', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'errors': {'key': 'errors', 'type': '[ManagedIntegrationRuntimeError]'}, + "additional_properties": {"key": "", "type": "{object}"}, + "node_id": {"key": "nodeId", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "errors": {"key": "errors", "type": "[ManagedIntegrationRuntimeError]"}, } def __init__( self, *, - additional_properties: Optional[Dict[str, Any]] = None, - errors: Optional[List["ManagedIntegrationRuntimeError"]] = None, + additional_properties: Optional[Dict[str, JSON]] = None, + errors: Optional[List["_models.ManagedIntegrationRuntimeError"]] = None, **kwargs ): """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. - :paramtype additional_properties: dict[str, any] + :paramtype additional_properties: dict[str, JSON] :keyword errors: The errors that occurred on this integration runtime node. :paramtype errors: list[~azure.mgmt.synapse.models.ManagedIntegrationRuntimeError] """ - super(ManagedIntegrationRuntimeNode, self).__init__(**kwargs) + super().__init__(**kwargs) self.additional_properties = additional_properties self.node_id = None self.status = None self.errors = errors -class ManagedIntegrationRuntimeOperationResult(msrest.serialization.Model): +class ManagedIntegrationRuntimeOperationResult(_serialization.Model): """Properties of managed integration runtime operation result. Variables are only populated by the server, and will be ignored when sending a request. :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :vartype additional_properties: dict[str, any] + :vartype additional_properties: dict[str, JSON] :ivar type: The operation type. Could be start or stop. :vartype type: str :ivar start_time: The start time of the operation. @@ -6778,36 +6471,31 @@ class ManagedIntegrationRuntimeOperationResult(msrest.serialization.Model): """ _validation = { - 'type': {'readonly': True}, - 'start_time': {'readonly': True}, - 'result': {'readonly': True}, - 'error_code': {'readonly': True}, - 'parameters': {'readonly': True}, - 'activity_id': {'readonly': True}, + "type": {"readonly": True}, + "start_time": {"readonly": True}, + "result": {"readonly": True}, + "error_code": {"readonly": True}, + "parameters": {"readonly": True}, + "activity_id": {"readonly": True}, } _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'type': {'key': 'type', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'result': {'key': 'result', 'type': 'str'}, - 'error_code': {'key': 'errorCode', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': '[str]'}, - 'activity_id': {'key': 'activityId', 'type': 'str'}, + "additional_properties": {"key": "", "type": "{object}"}, + "type": {"key": "type", "type": "str"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "result": {"key": "result", "type": "str"}, + "error_code": {"key": "errorCode", "type": "str"}, + "parameters": {"key": "parameters", "type": "[str]"}, + "activity_id": {"key": "activityId", "type": "str"}, } - def __init__( - self, - *, - additional_properties: Optional[Dict[str, Any]] = None, - **kwargs - ): + def __init__(self, *, additional_properties: Optional[Dict[str, JSON]] = None, **kwargs): """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. - :paramtype additional_properties: dict[str, any] + :paramtype additional_properties: dict[str, JSON] """ - super(ManagedIntegrationRuntimeOperationResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.additional_properties = additional_properties self.type = None self.start_time = None @@ -6826,14 +6514,14 @@ class ManagedIntegrationRuntimeStatus(IntegrationRuntimeStatus): :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :vartype additional_properties: dict[str, any] - :ivar type: Required. Type of integration runtime.Constant filled by server. Possible values - include: "Managed", "SelfHosted". + :vartype additional_properties: dict[str, JSON] + :ivar type: Type of integration runtime. Required. Known values are: "Managed" and + "SelfHosted". :vartype type: str or ~azure.mgmt.synapse.models.IntegrationRuntimeType :ivar data_factory_name: The workspace name which the integration runtime belong to. :vartype data_factory_name: str - :ivar state: The state of integration runtime. Possible values include: "Initial", "Stopped", - "Started", "Starting", "Stopping", "NeedRegistration", "Online", "Limited", "Offline", + :ivar state: The state of integration runtime. Known values are: "Initial", "Stopped", + "Started", "Starting", "Stopping", "NeedRegistration", "Online", "Limited", "Offline", and "AccessDenied". :vartype state: str or ~azure.mgmt.synapse.models.IntegrationRuntimeState :ivar create_time: The time at which the integration runtime was created, in ISO8601 format. @@ -6847,46 +6535,41 @@ class ManagedIntegrationRuntimeStatus(IntegrationRuntimeStatus): """ _validation = { - 'type': {'required': True}, - 'data_factory_name': {'readonly': True}, - 'state': {'readonly': True}, - 'create_time': {'readonly': True}, - 'nodes': {'readonly': True}, - 'other_errors': {'readonly': True}, - 'last_operation': {'readonly': True}, + "type": {"required": True}, + "data_factory_name": {"readonly": True}, + "state": {"readonly": True}, + "create_time": {"readonly": True}, + "nodes": {"readonly": True}, + "other_errors": {"readonly": True}, + "last_operation": {"readonly": True}, } _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'type': {'key': 'type', 'type': 'str'}, - 'data_factory_name': {'key': 'dataFactoryName', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'create_time': {'key': 'typeProperties.createTime', 'type': 'iso-8601'}, - 'nodes': {'key': 'typeProperties.nodes', 'type': '[ManagedIntegrationRuntimeNode]'}, - 'other_errors': {'key': 'typeProperties.otherErrors', 'type': '[ManagedIntegrationRuntimeError]'}, - 'last_operation': {'key': 'typeProperties.lastOperation', 'type': 'ManagedIntegrationRuntimeOperationResult'}, + "additional_properties": {"key": "", "type": "{object}"}, + "type": {"key": "type", "type": "str"}, + "data_factory_name": {"key": "dataFactoryName", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "create_time": {"key": "typeProperties.createTime", "type": "iso-8601"}, + "nodes": {"key": "typeProperties.nodes", "type": "[ManagedIntegrationRuntimeNode]"}, + "other_errors": {"key": "typeProperties.otherErrors", "type": "[ManagedIntegrationRuntimeError]"}, + "last_operation": {"key": "typeProperties.lastOperation", "type": "ManagedIntegrationRuntimeOperationResult"}, } - def __init__( - self, - *, - additional_properties: Optional[Dict[str, Any]] = None, - **kwargs - ): + def __init__(self, *, additional_properties: Optional[Dict[str, JSON]] = None, **kwargs): """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. - :paramtype additional_properties: dict[str, any] + :paramtype additional_properties: dict[str, JSON] """ - super(ManagedIntegrationRuntimeStatus, self).__init__(additional_properties=additional_properties, **kwargs) - self.type = 'Managed' # type: str + super().__init__(additional_properties=additional_properties, **kwargs) + self.type = "Managed" # type: str self.create_time = None self.nodes = None self.other_errors = None self.last_operation = None -class ManagedVirtualNetworkSettings(msrest.serialization.Model): +class ManagedVirtualNetworkSettings(_serialization.Model): """Managed Virtual Network Settings. :ivar prevent_data_exfiltration: Prevent Data Exfiltration. @@ -6898,9 +6581,9 @@ class ManagedVirtualNetworkSettings(msrest.serialization.Model): """ _attribute_map = { - 'prevent_data_exfiltration': {'key': 'preventDataExfiltration', 'type': 'bool'}, - 'linked_access_check_on_target_resource': {'key': 'linkedAccessCheckOnTargetResource', 'type': 'bool'}, - 'allowed_aad_tenant_ids_for_linking': {'key': 'allowedAadTenantIdsForLinking', 'type': '[str]'}, + "prevent_data_exfiltration": {"key": "preventDataExfiltration", "type": "bool"}, + "linked_access_check_on_target_resource": {"key": "linkedAccessCheckOnTargetResource", "type": "bool"}, + "allowed_aad_tenant_ids_for_linking": {"key": "allowedAadTenantIdsForLinking", "type": "[str]"}, } def __init__( @@ -6919,7 +6602,7 @@ def __init__( :keyword allowed_aad_tenant_ids_for_linking: Allowed Aad Tenant Ids For Linking. :paramtype allowed_aad_tenant_ids_for_linking: list[str] """ - super(ManagedVirtualNetworkSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.prevent_data_exfiltration = prevent_data_exfiltration self.linked_access_check_on_target_resource = linked_access_check_on_target_resource self.allowed_aad_tenant_ids_for_linking = allowed_aad_tenant_ids_for_linking @@ -6945,38 +6628,32 @@ class MetadataSyncConfig(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'sync_interval_in_minutes': {'key': 'properties.syncIntervalInMinutes', 'type': 'int'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, + "sync_interval_in_minutes": {"key": "properties.syncIntervalInMinutes", "type": "int"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - sync_interval_in_minutes: Optional[int] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, sync_interval_in_minutes: Optional[int] = None, **kwargs): """ :keyword enabled: Indicates whether the metadata sync is enabled or disabled. :paramtype enabled: bool :keyword sync_interval_in_minutes: The Sync Interval in minutes. :paramtype sync_interval_in_minutes: int """ - super(MetadataSyncConfig, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.sync_interval_in_minutes = sync_interval_in_minutes -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """A REST API operation. :ivar name: This is of the format {provider}/{resource}/{operation}. @@ -6985,24 +6662,24 @@ class Operation(msrest.serialization.Model): :vartype display: ~azure.mgmt.synapse.models.OperationDisplay :ivar origin: The intended executor of the operation. :vartype origin: str - :ivar properties: Any object. - :vartype properties: any + :ivar properties: Properties of the operation. + :vartype properties: JSON """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'object'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "properties": {"key": "properties", "type": "object"}, } def __init__( self, *, name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, - properties: Optional[Any] = None, + properties: Optional[JSON] = None, **kwargs ): """ @@ -7012,17 +6689,17 @@ def __init__( :paramtype display: ~azure.mgmt.synapse.models.OperationDisplay :keyword origin: The intended executor of the operation. :paramtype origin: str - :keyword properties: Any object. - :paramtype properties: any + :keyword properties: Properties of the operation. + :paramtype properties: JSON """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display self.origin = origin self.properties = properties -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that describes the operation. :ivar provider: Friendly name of the resource provider. @@ -7036,10 +6713,10 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -7061,14 +6738,14 @@ def __init__( :keyword description: The friendly name of the operation. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.operation = operation self.resource = resource self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list REST API operations. It contains a list of operations and a URL nextLink to get the next set of results. Variables are only populated by the server, and will be ignored when sending a request. @@ -7080,30 +6757,25 @@ class OperationListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Operation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, **kwargs): """ :keyword value: The list of operations supported by the resource provider. :paramtype value: list[~azure.mgmt.synapse.models.Operation] """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class OperationMetaLogSpecification(msrest.serialization.Model): +class OperationMetaLogSpecification(_serialization.Model): """What is this?. :ivar display_name: Log display name. @@ -7115,9 +6787,9 @@ class OperationMetaLogSpecification(msrest.serialization.Model): """ _attribute_map = { - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'blob_duration': {'key': 'blobDuration', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "display_name": {"key": "displayName", "type": "str"}, + "blob_duration": {"key": "blobDuration", "type": "str"}, + "name": {"key": "name", "type": "str"}, } def __init__( @@ -7136,13 +6808,13 @@ def __init__( :keyword name: Log unique name. :paramtype name: str """ - super(OperationMetaLogSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.display_name = display_name self.blob_duration = blob_duration self.name = name -class OperationMetaMetricDimensionSpecification(msrest.serialization.Model): +class OperationMetaMetricDimensionSpecification(_serialization.Model): """What is this?. :ivar display_name: Dimension display name. @@ -7154,9 +6826,9 @@ class OperationMetaMetricDimensionSpecification(msrest.serialization.Model): """ _attribute_map = { - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'to_be_exported_for_shoebox': {'key': 'toBeExportedForShoebox', 'type': 'bool'}, + "display_name": {"key": "displayName", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "to_be_exported_for_shoebox": {"key": "toBeExportedForShoebox", "type": "bool"}, } def __init__( @@ -7175,13 +6847,13 @@ def __init__( :keyword to_be_exported_for_shoebox: Whether this metric should be exported for Shoebox. :paramtype to_be_exported_for_shoebox: bool """ - super(OperationMetaMetricDimensionSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.display_name = display_name self.name = name self.to_be_exported_for_shoebox = to_be_exported_for_shoebox -class OperationMetaMetricSpecification(msrest.serialization.Model): +class OperationMetaMetricSpecification(_serialization.Model): # pylint: disable=too-many-instance-attributes """What is this?. :ivar source_mdm_namespace: The source MDM namespace. @@ -7210,17 +6882,17 @@ class OperationMetaMetricSpecification(msrest.serialization.Model): """ _attribute_map = { - 'source_mdm_namespace': {'key': 'sourceMdmNamespace', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'source_mdm_account': {'key': 'sourceMdmAccount', 'type': 'str'}, - 'enable_regional_mdm_account': {'key': 'enableRegionalMdmAccount', 'type': 'bool'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[OperationMetaMetricDimensionSpecification]'}, - 'supports_instance_level_aggregation': {'key': 'supportsInstanceLevelAggregation', 'type': 'bool'}, - 'metric_filter_pattern': {'key': 'metricFilterPattern', 'type': 'str'}, + "source_mdm_namespace": {"key": "sourceMdmNamespace", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "source_mdm_account": {"key": "sourceMdmAccount", "type": "str"}, + "enable_regional_mdm_account": {"key": "enableRegionalMdmAccount", "type": "bool"}, + "unit": {"key": "unit", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[OperationMetaMetricDimensionSpecification]"}, + "supports_instance_level_aggregation": {"key": "supportsInstanceLevelAggregation", "type": "bool"}, + "metric_filter_pattern": {"key": "metricFilterPattern", "type": "str"}, } def __init__( @@ -7234,7 +6906,7 @@ def __init__( source_mdm_account: Optional[str] = None, enable_regional_mdm_account: Optional[bool] = None, unit: Optional[str] = None, - dimensions: Optional[List["OperationMetaMetricDimensionSpecification"]] = None, + dimensions: Optional[List["_models.OperationMetaMetricDimensionSpecification"]] = None, supports_instance_level_aggregation: Optional[bool] = None, metric_filter_pattern: Optional[str] = None, **kwargs @@ -7265,7 +6937,7 @@ def __init__( :keyword metric_filter_pattern: Metric filter. :paramtype metric_filter_pattern: str """ - super(OperationMetaMetricSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.source_mdm_namespace = source_mdm_namespace self.display_name = display_name self.name = name @@ -7279,7 +6951,7 @@ def __init__( self.metric_filter_pattern = metric_filter_pattern -class OperationMetaServiceSpecification(msrest.serialization.Model): +class OperationMetaServiceSpecification(_serialization.Model): """What is this?. :ivar metric_specifications: Service metric specifications. @@ -7290,15 +6962,15 @@ class OperationMetaServiceSpecification(msrest.serialization.Model): """ _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[OperationMetaMetricSpecification]'}, - 'log_specifications': {'key': 'logSpecifications', 'type': '[OperationMetaLogSpecification]'}, + "metric_specifications": {"key": "metricSpecifications", "type": "[OperationMetaMetricSpecification]"}, + "log_specifications": {"key": "logSpecifications", "type": "[OperationMetaLogSpecification]"}, } def __init__( self, *, - metric_specifications: Optional[List["OperationMetaMetricSpecification"]] = None, - log_specifications: Optional[List["OperationMetaLogSpecification"]] = None, + metric_specifications: Optional[List["_models.OperationMetaMetricSpecification"]] = None, + log_specifications: Optional[List["_models.OperationMetaLogSpecification"]] = None, **kwargs ): """ @@ -7308,23 +6980,23 @@ def __init__( :keyword log_specifications: Service log specifications. :paramtype log_specifications: list[~azure.mgmt.synapse.models.OperationMetaLogSpecification] """ - super(OperationMetaServiceSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.metric_specifications = metric_specifications self.log_specifications = log_specifications -class OperationResource(msrest.serialization.Model): +class OperationResource(_serialization.Model): """An operation. :ivar id: Operation ID. :vartype id: str :ivar name: Operation name. :vartype name: str - :ivar status: Operation status. Possible values include: "InProgress", "Succeeded", "Failed", + :ivar status: Operation status. Known values are: "InProgress", "Succeeded", "Failed", and "Canceled". :vartype status: str or ~azure.mgmt.synapse.models.OperationStatus :ivar properties: Operation properties. - :vartype properties: any + :vartype properties: JSON :ivar error: Errors from the operation. :vartype error: ~azure.mgmt.synapse.models.ErrorDetail :ivar start_time: Operation start time. @@ -7336,24 +7008,24 @@ class OperationResource(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'object'}, - 'error': {'key': 'error', 'type': 'ErrorDetail'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'percent_complete': {'key': 'percentComplete', 'type': 'float'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "properties": {"key": "properties", "type": "object"}, + "error": {"key": "error", "type": "ErrorDetail"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "percent_complete": {"key": "percentComplete", "type": "float"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, - status: Optional[Union[str, "OperationStatus"]] = None, - properties: Optional[Any] = None, - error: Optional["ErrorDetail"] = None, + status: Optional[Union[str, "_models.OperationStatus"]] = None, + properties: Optional[JSON] = None, + error: Optional["_models.ErrorDetail"] = None, start_time: Optional[datetime.datetime] = None, end_time: Optional[datetime.datetime] = None, percent_complete: Optional[float] = None, @@ -7364,11 +7036,11 @@ def __init__( :paramtype id: str :keyword name: Operation name. :paramtype name: str - :keyword status: Operation status. Possible values include: "InProgress", "Succeeded", - "Failed", "Canceled". + :keyword status: Operation status. Known values are: "InProgress", "Succeeded", "Failed", and + "Canceled". :paramtype status: str or ~azure.mgmt.synapse.models.OperationStatus :keyword properties: Operation properties. - :paramtype properties: any + :paramtype properties: JSON :keyword error: Errors from the operation. :paramtype error: ~azure.mgmt.synapse.models.ErrorDetail :keyword start_time: Operation start time. @@ -7378,7 +7050,7 @@ def __init__( :keyword percent_complete: Completion percentage of the operation. :paramtype percent_complete: float """ - super(OperationResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.name = name self.status = status @@ -7389,64 +7061,56 @@ def __init__( self.percent_complete = percent_complete -class OptimizedAutoscale(msrest.serialization.Model): +class OptimizedAutoscale(_serialization.Model): """A class that contains the optimized auto scale definition. All required parameters must be populated in order to send to Azure. - :ivar version: Required. The version of the template defined, for instance 1. + :ivar version: The version of the template defined, for instance 1. Required. :vartype version: int - :ivar is_enabled: Required. A boolean value that indicate if the optimized autoscale feature is - enabled or not. + :ivar is_enabled: A boolean value that indicate if the optimized autoscale feature is enabled + or not. Required. :vartype is_enabled: bool - :ivar minimum: Required. Minimum allowed instances count. + :ivar minimum: Minimum allowed instances count. Required. :vartype minimum: int - :ivar maximum: Required. Maximum allowed instances count. + :ivar maximum: Maximum allowed instances count. Required. :vartype maximum: int """ _validation = { - 'version': {'required': True}, - 'is_enabled': {'required': True}, - 'minimum': {'required': True}, - 'maximum': {'required': True}, + "version": {"required": True}, + "is_enabled": {"required": True}, + "minimum": {"required": True}, + "maximum": {"required": True}, } _attribute_map = { - 'version': {'key': 'version', 'type': 'int'}, - 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, - 'minimum': {'key': 'minimum', 'type': 'int'}, - 'maximum': {'key': 'maximum', 'type': 'int'}, + "version": {"key": "version", "type": "int"}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + "minimum": {"key": "minimum", "type": "int"}, + "maximum": {"key": "maximum", "type": "int"}, } - def __init__( - self, - *, - version: int, - is_enabled: bool, - minimum: int, - maximum: int, - **kwargs - ): + def __init__(self, *, version: int, is_enabled: bool, minimum: int, maximum: int, **kwargs): """ - :keyword version: Required. The version of the template defined, for instance 1. + :keyword version: The version of the template defined, for instance 1. Required. :paramtype version: int - :keyword is_enabled: Required. A boolean value that indicate if the optimized autoscale feature - is enabled or not. + :keyword is_enabled: A boolean value that indicate if the optimized autoscale feature is + enabled or not. Required. :paramtype is_enabled: bool - :keyword minimum: Required. Minimum allowed instances count. + :keyword minimum: Minimum allowed instances count. Required. :paramtype minimum: int - :keyword maximum: Required. Maximum allowed instances count. + :keyword maximum: Maximum allowed instances count. Required. :paramtype maximum: int """ - super(OptimizedAutoscale, self).__init__(**kwargs) + super().__init__(**kwargs) self.version = version self.is_enabled = is_enabled self.minimum = minimum self.maximum = maximum -class PrivateEndpoint(msrest.serialization.Model): +class PrivateEndpoint(_serialization.Model): """Private endpoint details. Variables are only populated by the server, and will be ignored when sending a request. @@ -7456,20 +7120,16 @@ class PrivateEndpoint(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PrivateEndpoint, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None @@ -7497,26 +7157,29 @@ class PrivateEndpointConnection(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'private_endpoint': {'key': 'properties.privateEndpoint', 'type': 'PrivateEndpoint'}, - 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionState'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, + "private_link_service_connection_state": { + "key": "properties.privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionState", + }, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( self, *, - private_endpoint: Optional["PrivateEndpoint"] = None, - private_link_service_connection_state: Optional["PrivateLinkServiceConnectionState"] = None, + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, **kwargs ): """ @@ -7527,13 +7190,13 @@ def __init__( :paramtype private_link_service_connection_state: ~azure.mgmt.synapse.models.PrivateLinkServiceConnectionState """ - super(PrivateEndpointConnection, self).__init__(**kwargs) + super().__init__(**kwargs) self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state self.provisioning_state = None -class PrivateEndpointConnectionForPrivateLinkHubBasicAutoGenerated(msrest.serialization.Model): +class PrivateEndpointConnectionForPrivateLinkHubBasicAutoGenerated(_serialization.Model): """PrivateEndpointConnectionForPrivateLinkHubBasicAutoGenerated. :ivar id: @@ -7543,15 +7206,15 @@ class PrivateEndpointConnectionForPrivateLinkHubBasicAutoGenerated(msrest.serial """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'PrivateEndpointConnectionProperties'}, + "id": {"key": "id", "type": "str"}, + "properties": {"key": "properties", "type": "PrivateEndpointConnectionProperties"}, } def __init__( self, *, - id: Optional[str] = None, - properties: Optional["PrivateEndpointConnectionProperties"] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + properties: Optional["_models.PrivateEndpointConnectionProperties"] = None, **kwargs ): """ @@ -7560,7 +7223,7 @@ def __init__( :keyword properties: Properties of a private endpoint connection. :paramtype properties: ~azure.mgmt.synapse.models.PrivateEndpointConnectionProperties """ - super(PrivateEndpointConnectionForPrivateLinkHubBasicAutoGenerated, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.properties = properties @@ -7579,17 +7242,17 @@ class PrivateEndpointConnectionForPrivateLinkHub(PrivateEndpointConnectionForPri """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'PrivateEndpointConnectionProperties'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "properties": {"key": "properties", "type": "PrivateEndpointConnectionProperties"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, - properties: Optional["PrivateEndpointConnectionProperties"] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + properties: Optional["_models.PrivateEndpointConnectionProperties"] = None, name: Optional[str] = None, type: Optional[str] = None, **kwargs @@ -7604,12 +7267,12 @@ def __init__( :keyword type: :paramtype type: str """ - super(PrivateEndpointConnectionForPrivateLinkHub, self).__init__(id=id, properties=properties, **kwargs) + super().__init__(id=id, properties=properties, **kwargs) self.name = name self.type = type -class PrivateEndpointConnectionForPrivateLinkHubBasic(msrest.serialization.Model): +class PrivateEndpointConnectionForPrivateLinkHubBasic(_serialization.Model): """Private Endpoint Connection For Private Link Hub - Basic. Variables are only populated by the server, and will be ignored when sending a request. @@ -7627,22 +7290,25 @@ class PrivateEndpointConnectionForPrivateLinkHubBasic(msrest.serialization.Model """ _validation = { - 'id': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'private_endpoint': {'key': 'properties.privateEndpoint', 'type': 'PrivateEndpoint'}, - 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionState'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, + "private_link_service_connection_state": { + "key": "properties.privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionState", + }, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( self, *, - private_endpoint: Optional["PrivateEndpoint"] = None, - private_link_service_connection_state: Optional["PrivateLinkServiceConnectionState"] = None, + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, **kwargs ): """ @@ -7653,14 +7319,14 @@ def __init__( :paramtype private_link_service_connection_state: ~azure.mgmt.synapse.models.PrivateLinkServiceConnectionState """ - super(PrivateEndpointConnectionForPrivateLinkHubBasic, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state self.provisioning_state = None -class PrivateEndpointConnectionForPrivateLinkHubResourceCollectionResponse(msrest.serialization.Model): +class PrivateEndpointConnectionForPrivateLinkHubResourceCollectionResponse(_serialization.Model): """PrivateEndpointConnectionForPrivateLinkHubResourceCollectionResponse. :ivar value: @@ -7670,14 +7336,14 @@ class PrivateEndpointConnectionForPrivateLinkHubResourceCollectionResponse(msres """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnectionForPrivateLinkHub]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateEndpointConnectionForPrivateLinkHub]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["PrivateEndpointConnectionForPrivateLinkHub"]] = None, + value: Optional[List["_models.PrivateEndpointConnectionForPrivateLinkHub"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -7687,12 +7353,12 @@ def __init__( :keyword next_link: :paramtype next_link: str """ - super(PrivateEndpointConnectionForPrivateLinkHubResourceCollectionResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PrivateEndpointConnectionList(msrest.serialization.Model): +class PrivateEndpointConnectionList(_serialization.Model): """A list of private endpoint connections. Variables are only populated by the server, and will be ignored when sending a request. @@ -7704,27 +7370,23 @@ class PrivateEndpointConnectionList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PrivateEndpointConnectionList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class PrivateEndpointConnectionProperties(msrest.serialization.Model): +class PrivateEndpointConnectionProperties(_serialization.Model): """Properties of a private endpoint connection. Variables are only populated by the server, and will be ignored when sending a request. @@ -7740,20 +7402,23 @@ class PrivateEndpointConnectionProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'private_endpoint': {'key': 'privateEndpoint', 'type': 'PrivateEndpoint'}, - 'private_link_service_connection_state': {'key': 'privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionState'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "private_endpoint": {"key": "privateEndpoint", "type": "PrivateEndpoint"}, + "private_link_service_connection_state": { + "key": "privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionState", + }, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } def __init__( self, *, - private_endpoint: Optional["PrivateEndpoint"] = None, - private_link_service_connection_state: Optional["PrivateLinkServiceConnectionState"] = None, + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, **kwargs ): """ @@ -7764,7 +7429,7 @@ def __init__( :paramtype private_link_service_connection_state: ~azure.mgmt.synapse.models.PrivateLinkServiceConnectionState """ - super(PrivateEndpointConnectionProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state self.provisioning_state = None @@ -7785,9 +7450,9 @@ class PrivateLinkHub(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar provisioning_state: PrivateLinkHub provisioning state. :vartype provisioning_state: str @@ -7797,21 +7462,24 @@ class PrivateLinkHub(TrackedResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'private_endpoint_connections': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "private_endpoint_connections": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnectionForPrivateLinkHubBasic]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnectionForPrivateLinkHubBasic]", + }, } def __init__( @@ -7823,19 +7491,19 @@ def __init__( **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str :keyword provisioning_state: PrivateLinkHub provisioning state. :paramtype provisioning_state: str """ - super(PrivateLinkHub, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.provisioning_state = provisioning_state self.private_endpoint_connections = None -class PrivateLinkHubInfoListResult(msrest.serialization.Model): +class PrivateLinkHubInfoListResult(_serialization.Model): """List of privateLinkHubs. :ivar next_link: Link to the next page of results. @@ -7845,16 +7513,12 @@ class PrivateLinkHubInfoListResult(msrest.serialization.Model): """ _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[PrivateLinkHub]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[PrivateLinkHub]"}, } def __init__( - self, - *, - next_link: Optional[str] = None, - value: Optional[List["PrivateLinkHub"]] = None, - **kwargs + self, *, next_link: Optional[str] = None, value: Optional[List["_models.PrivateLinkHub"]] = None, **kwargs ): """ :keyword next_link: Link to the next page of results. @@ -7862,33 +7526,28 @@ def __init__( :keyword value: List of privateLinkHubs. :paramtype value: list[~azure.mgmt.synapse.models.PrivateLinkHub] """ - super(PrivateLinkHubInfoListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.next_link = next_link self.value = value -class PrivateLinkHubPatchInfo(msrest.serialization.Model): +class PrivateLinkHubPatchInfo(_serialization.Model): """PrivateLinkHub patch details. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(PrivateLinkHubPatchInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags @@ -7910,30 +7569,26 @@ class PrivateLinkResource(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'properties': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "properties": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'PrivateLinkResourceProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "PrivateLinkResourceProperties"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PrivateLinkResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.properties = None -class PrivateLinkResourceListResult(msrest.serialization.Model): +class PrivateLinkResourceListResult(_serialization.Model): """A list of private link resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -7945,27 +7600,23 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateLinkResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PrivateLinkResourceListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class PrivateLinkResourceProperties(msrest.serialization.Model): +class PrivateLinkResourceProperties(_serialization.Model): """Properties of a private link resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -7979,30 +7630,26 @@ class PrivateLinkResourceProperties(msrest.serialization.Model): """ _validation = { - 'group_id': {'readonly': True}, - 'required_members': {'readonly': True}, - 'required_zone_names': {'readonly': True}, + "group_id": {"readonly": True}, + "required_members": {"readonly": True}, + "required_zone_names": {"readonly": True}, } _attribute_map = { - 'group_id': {'key': 'groupId', 'type': 'str'}, - 'required_members': {'key': 'requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'requiredZoneNames', 'type': '[str]'}, + "group_id": {"key": "groupId", "type": "str"}, + "required_members": {"key": "requiredMembers", "type": "[str]"}, + "required_zone_names": {"key": "requiredZoneNames", "type": "[str]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PrivateLinkResourceProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.group_id = None self.required_members = None self.required_zone_names = None -class PrivateLinkServiceConnectionState(msrest.serialization.Model): +class PrivateLinkServiceConnectionState(_serialization.Model): """Connection state details of the private endpoint. Variables are only populated by the server, and will be ignored when sending a request. @@ -8016,35 +7663,29 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): """ _validation = { - 'actions_required': {'readonly': True}, + "actions_required": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'actions_required': {'key': 'actionsRequired', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "actions_required": {"key": "actionsRequired", "type": "str"}, } - def __init__( - self, - *, - status: Optional[str] = None, - description: Optional[str] = None, - **kwargs - ): + def __init__(self, *, status: Optional[str] = None, description: Optional[str] = None, **kwargs): """ :keyword status: The private link service connection status. :paramtype status: str :keyword description: The private link service connection description. :paramtype description: str """ - super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.description = description self.actions_required = None -class PurviewConfiguration(msrest.serialization.Model): +class PurviewConfiguration(_serialization.Model): """Purview Configuration. :ivar purview_resource_id: Purview Resource ID. @@ -8052,24 +7693,19 @@ class PurviewConfiguration(msrest.serialization.Model): """ _attribute_map = { - 'purview_resource_id': {'key': 'purviewResourceId', 'type': 'str'}, + "purview_resource_id": {"key": "purviewResourceId", "type": "str"}, } - def __init__( - self, - *, - purview_resource_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, purview_resource_id: Optional[str] = None, **kwargs): """ :keyword purview_resource_id: Purview Resource ID. :paramtype purview_resource_id: str """ - super(PurviewConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.purview_resource_id = purview_resource_id -class QueryInterval(msrest.serialization.Model): +class QueryInterval(_serialization.Model): """A database query. Variables are only populated by the server, and will be ignored when sending a request. @@ -8083,30 +7719,26 @@ class QueryInterval(msrest.serialization.Model): """ _validation = { - 'interval_start_time': {'readonly': True}, - 'execution_count': {'readonly': True}, - 'metrics': {'readonly': True}, + "interval_start_time": {"readonly": True}, + "execution_count": {"readonly": True}, + "metrics": {"readonly": True}, } _attribute_map = { - 'interval_start_time': {'key': 'intervalStartTime', 'type': 'iso-8601'}, - 'execution_count': {'key': 'executionCount', 'type': 'int'}, - 'metrics': {'key': 'metrics', 'type': '[QueryMetric]'}, + "interval_start_time": {"key": "intervalStartTime", "type": "iso-8601"}, + "execution_count": {"key": "executionCount", "type": "int"}, + "metrics": {"key": "metrics", "type": "[QueryMetric]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(QueryInterval, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.interval_start_time = None self.execution_count = None self.metrics = None -class QueryMetric(msrest.serialization.Model): +class QueryMetric(_serialization.Model): """A database query. Variables are only populated by the server, and will be ignored when sending a request. @@ -8115,41 +7747,36 @@ class QueryMetric(msrest.serialization.Model): :vartype name: str :ivar display_name: The name of the metric for display in user interface. :vartype display_name: str - :ivar unit: The unit of measurement. Possible values include: "percentage", "KB", - "microseconds". + :ivar unit: The unit of measurement. Known values are: "percentage", "KB", and "microseconds". :vartype unit: str or ~azure.mgmt.synapse.models.QueryMetricUnit :ivar value: The measured value. :vartype value: float """ _validation = { - 'name': {'readonly': True}, - 'display_name': {'readonly': True}, - 'unit': {'readonly': True}, - 'value': {'readonly': True}, + "name": {"readonly": True}, + "display_name": {"readonly": True}, + "unit": {"readonly": True}, + "value": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'float'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "value": {"key": "value", "type": "float"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(QueryMetric, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.display_name = None self.unit = None self.value = None -class QueryStatistic(msrest.serialization.Model): +class QueryStatistic(_serialization.Model): """A database query. Variables are only populated by the server, and will be ignored when sending a request. @@ -8161,27 +7788,23 @@ class QueryStatistic(msrest.serialization.Model): """ _validation = { - 'query_id': {'readonly': True}, - 'intervals': {'readonly': True}, + "query_id": {"readonly": True}, + "intervals": {"readonly": True}, } _attribute_map = { - 'query_id': {'key': 'queryId', 'type': 'str'}, - 'intervals': {'key': 'intervals', 'type': '[QueryInterval]'}, + "query_id": {"key": "queryId", "type": "str"}, + "intervals": {"key": "intervals", "type": "[QueryInterval]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(QueryStatistic, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.query_id = None self.intervals = None -class ReadOnlyFollowingDatabase(Database): +class ReadOnlyFollowingDatabase(Database): # pylint: disable=too-many-instance-attributes """Class representing a read only following database. Variables are only populated by the server, and will be ignored when sending a request. @@ -8198,14 +7821,14 @@ class ReadOnlyFollowingDatabase(Database): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar kind: Required. Kind of the database.Constant filled by server. Possible values include: - "ReadWrite", "ReadOnlyFollowing". + :ivar kind: Kind of the database. Required. Known values are: "ReadWrite" and + "ReadOnlyFollowing". :vartype kind: str or ~azure.mgmt.synapse.models.Kind :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.synapse.models.SystemData - :ivar provisioning_state: The provisioned state of the resource. Possible values include: - "Running", "Creating", "Deleting", "Succeeded", "Failed", "Moving", "Canceled". + :ivar provisioning_state: The provisioned state of the resource. Known values are: "Running", + "Creating", "Deleting", "Succeeded", "Failed", "Moving", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.synapse.models.ResourceProvisioningState :ivar soft_delete_period: The time the data should be kept before it stops being accessible to queries in TimeSpan. @@ -8219,48 +7842,44 @@ class ReadOnlyFollowingDatabase(Database): :ivar attached_database_configuration_name: The name of the attached database configuration cluster. :vartype attached_database_configuration_name: str - :ivar principals_modification_kind: The principals modification kind of the database. Possible - values include: "Union", "Replace", "None". + :ivar principals_modification_kind: The principals modification kind of the database. Known + values are: "Union", "Replace", and "None". :vartype principals_modification_kind: str or ~azure.mgmt.synapse.models.PrincipalsModificationKind """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'soft_delete_period': {'readonly': True}, - 'statistics': {'readonly': True}, - 'leader_cluster_resource_id': {'readonly': True}, - 'attached_database_configuration_name': {'readonly': True}, - 'principals_modification_kind': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "soft_delete_period": {"readonly": True}, + "statistics": {"readonly": True}, + "leader_cluster_resource_id": {"readonly": True}, + "attached_database_configuration_name": {"readonly": True}, + "principals_modification_kind": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'soft_delete_period': {'key': 'properties.softDeletePeriod', 'type': 'duration'}, - 'hot_cache_period': {'key': 'properties.hotCachePeriod', 'type': 'duration'}, - 'statistics': {'key': 'properties.statistics', 'type': 'DatabaseStatistics'}, - 'leader_cluster_resource_id': {'key': 'properties.leaderClusterResourceId', 'type': 'str'}, - 'attached_database_configuration_name': {'key': 'properties.attachedDatabaseConfigurationName', 'type': 'str'}, - 'principals_modification_kind': {'key': 'properties.principalsModificationKind', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "soft_delete_period": {"key": "properties.softDeletePeriod", "type": "duration"}, + "hot_cache_period": {"key": "properties.hotCachePeriod", "type": "duration"}, + "statistics": {"key": "properties.statistics", "type": "DatabaseStatistics"}, + "leader_cluster_resource_id": {"key": "properties.leaderClusterResourceId", "type": "str"}, + "attached_database_configuration_name": {"key": "properties.attachedDatabaseConfigurationName", "type": "str"}, + "principals_modification_kind": {"key": "properties.principalsModificationKind", "type": "str"}, } def __init__( - self, - *, - location: Optional[str] = None, - hot_cache_period: Optional[datetime.timedelta] = None, - **kwargs + self, *, location: Optional[str] = None, hot_cache_period: Optional[datetime.timedelta] = None, **kwargs ): """ :keyword location: Resource location. @@ -8269,8 +7888,8 @@ def __init__( TimeSpan. :paramtype hot_cache_period: ~datetime.timedelta """ - super(ReadOnlyFollowingDatabase, self).__init__(location=location, **kwargs) - self.kind = 'ReadOnlyFollowing' # type: str + super().__init__(location=location, **kwargs) + self.kind = "ReadOnlyFollowing" # type: str self.provisioning_state = None self.soft_delete_period = None self.hot_cache_period = hot_cache_period @@ -8280,7 +7899,7 @@ def __init__( self.principals_modification_kind = None -class ReadWriteDatabase(Database): +class ReadWriteDatabase(Database): # pylint: disable=too-many-instance-attributes """Class representing a read write database. Variables are only populated by the server, and will be ignored when sending a request. @@ -8297,14 +7916,14 @@ class ReadWriteDatabase(Database): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar kind: Required. Kind of the database.Constant filled by server. Possible values include: - "ReadWrite", "ReadOnlyFollowing". + :ivar kind: Kind of the database. Required. Known values are: "ReadWrite" and + "ReadOnlyFollowing". :vartype kind: str or ~azure.mgmt.synapse.models.Kind :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.synapse.models.SystemData - :ivar provisioning_state: The provisioned state of the resource. Possible values include: - "Running", "Creating", "Deleting", "Succeeded", "Failed", "Moving", "Canceled". + :ivar provisioning_state: The provisioned state of the resource. Known values are: "Running", + "Creating", "Deleting", "Succeeded", "Failed", "Moving", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.synapse.models.ResourceProvisioningState :ivar soft_delete_period: The time the data should be kept before it stops being accessible to queries in TimeSpan. @@ -8318,28 +7937,28 @@ class ReadWriteDatabase(Database): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'statistics': {'readonly': True}, - 'is_followed': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "statistics": {"readonly": True}, + "is_followed": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'soft_delete_period': {'key': 'properties.softDeletePeriod', 'type': 'duration'}, - 'hot_cache_period': {'key': 'properties.hotCachePeriod', 'type': 'duration'}, - 'statistics': {'key': 'properties.statistics', 'type': 'DatabaseStatistics'}, - 'is_followed': {'key': 'properties.isFollowed', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "soft_delete_period": {"key": "properties.softDeletePeriod", "type": "duration"}, + "hot_cache_period": {"key": "properties.hotCachePeriod", "type": "duration"}, + "statistics": {"key": "properties.statistics", "type": "DatabaseStatistics"}, + "is_followed": {"key": "properties.isFollowed", "type": "bool"}, } def __init__( @@ -8360,8 +7979,8 @@ def __init__( TimeSpan. :paramtype hot_cache_period: ~datetime.timedelta """ - super(ReadWriteDatabase, self).__init__(location=location, **kwargs) - self.kind = 'ReadWrite' # type: str + super().__init__(location=location, **kwargs) + self.kind = "ReadWrite" # type: str self.provisioning_state = None self.soft_delete_period = soft_delete_period self.hot_cache_period = hot_cache_period @@ -8382,7 +8001,7 @@ class RecommendedSensitivityLabelUpdate(ProxyResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar op: Possible values include: "enable", "disable". + :ivar op: Known values are: "enable" and "disable". :vartype op: str or ~azure.mgmt.synapse.models.RecommendedSensitivityLabelUpdateKind :ivar schema: Schema name of the column to update. :vartype schema: str @@ -8393,32 +8012,32 @@ class RecommendedSensitivityLabelUpdate(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'op': {'key': 'properties.op', 'type': 'str'}, - 'schema': {'key': 'properties.schema', 'type': 'str'}, - 'table': {'key': 'properties.table', 'type': 'str'}, - 'column': {'key': 'properties.column', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "op": {"key": "properties.op", "type": "str"}, + "schema": {"key": "properties.schema", "type": "str"}, + "table": {"key": "properties.table", "type": "str"}, + "column": {"key": "properties.column", "type": "str"}, } def __init__( self, *, - op: Optional[Union[str, "RecommendedSensitivityLabelUpdateKind"]] = None, + op: Optional[Union[str, "_models.RecommendedSensitivityLabelUpdateKind"]] = None, schema: Optional[str] = None, table: Optional[str] = None, column: Optional[str] = None, **kwargs ): """ - :keyword op: Possible values include: "enable", "disable". + :keyword op: Known values are: "enable" and "disable". :paramtype op: str or ~azure.mgmt.synapse.models.RecommendedSensitivityLabelUpdateKind :keyword schema: Schema name of the column to update. :paramtype schema: str @@ -8427,14 +8046,14 @@ def __init__( :keyword column: Column name to update. :paramtype column: str """ - super(RecommendedSensitivityLabelUpdate, self).__init__(**kwargs) + super().__init__(**kwargs) self.op = op self.schema = schema self.table = table self.column = column -class RecommendedSensitivityLabelUpdateList(msrest.serialization.Model): +class RecommendedSensitivityLabelUpdateList(_serialization.Model): """A list of recommended sensitivity label update operations. :ivar operations: @@ -8442,20 +8061,15 @@ class RecommendedSensitivityLabelUpdateList(msrest.serialization.Model): """ _attribute_map = { - 'operations': {'key': 'operations', 'type': '[RecommendedSensitivityLabelUpdate]'}, + "operations": {"key": "operations", "type": "[RecommendedSensitivityLabelUpdate]"}, } - def __init__( - self, - *, - operations: Optional[List["RecommendedSensitivityLabelUpdate"]] = None, - **kwargs - ): + def __init__(self, *, operations: Optional[List["_models.RecommendedSensitivityLabelUpdate"]] = None, **kwargs): """ :keyword operations: :paramtype operations: list[~azure.mgmt.synapse.models.RecommendedSensitivityLabelUpdate] """ - super(RecommendedSensitivityLabelUpdateList, self).__init__(**kwargs) + super().__init__(**kwargs) self.operations = operations @@ -8484,39 +8098,35 @@ class RecoverableSqlPool(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'edition': {'readonly': True}, - 'service_level_objective': {'readonly': True}, - 'elastic_pool_name': {'readonly': True}, - 'last_available_backup_date': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "edition": {"readonly": True}, + "service_level_objective": {"readonly": True}, + "elastic_pool_name": {"readonly": True}, + "last_available_backup_date": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'edition': {'key': 'properties.edition', 'type': 'str'}, - 'service_level_objective': {'key': 'properties.serviceLevelObjective', 'type': 'str'}, - 'elastic_pool_name': {'key': 'properties.elasticPoolName', 'type': 'str'}, - 'last_available_backup_date': {'key': 'properties.lastAvailableBackupDate', 'type': 'iso-8601'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "edition": {"key": "properties.edition", "type": "str"}, + "service_level_objective": {"key": "properties.serviceLevelObjective", "type": "str"}, + "elastic_pool_name": {"key": "properties.elasticPoolName", "type": "str"}, + "last_available_backup_date": {"key": "properties.lastAvailableBackupDate", "type": "iso-8601"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RecoverableSqlPool, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.edition = None self.service_level_objective = None self.elastic_pool_name = None self.last_available_backup_date = None -class RecoverableSqlPoolListResult(msrest.serialization.Model): +class RecoverableSqlPoolListResult(_serialization.Model): """The response to a list recoverable sql pools request. Variables are only populated by the server, and will be ignored when sending a request. @@ -8528,27 +8138,23 @@ class RecoverableSqlPoolListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[RecoverableSqlPool]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[RecoverableSqlPool]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RecoverableSqlPoolListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ReplaceAllFirewallRulesOperationResponse(msrest.serialization.Model): +class ReplaceAllFirewallRulesOperationResponse(_serialization.Model): """An existing operation for replacing the firewall rules. :ivar operation_id: The operation ID. @@ -8556,24 +8162,19 @@ class ReplaceAllFirewallRulesOperationResponse(msrest.serialization.Model): """ _attribute_map = { - 'operation_id': {'key': 'operationId', 'type': 'str'}, + "operation_id": {"key": "operationId", "type": "str"}, } - def __init__( - self, - *, - operation_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, operation_id: Optional[str] = None, **kwargs): """ :keyword operation_id: The operation ID. :paramtype operation_id: str """ - super(ReplaceAllFirewallRulesOperationResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.operation_id = operation_id -class ReplaceAllIpFirewallRulesRequest(msrest.serialization.Model): +class ReplaceAllIpFirewallRulesRequest(_serialization.Model): """Replace all IP firewall rules request. :ivar ip_firewall_rules: IP firewall rule properties. @@ -8581,24 +8182,19 @@ class ReplaceAllIpFirewallRulesRequest(msrest.serialization.Model): """ _attribute_map = { - 'ip_firewall_rules': {'key': 'ipFirewallRules', 'type': '{IpFirewallRuleProperties}'}, + "ip_firewall_rules": {"key": "ipFirewallRules", "type": "{IpFirewallRuleProperties}"}, } - def __init__( - self, - *, - ip_firewall_rules: Optional[Dict[str, "IpFirewallRuleProperties"]] = None, - **kwargs - ): + def __init__(self, *, ip_firewall_rules: Optional[Dict[str, "_models.IpFirewallRuleProperties"]] = None, **kwargs): """ :keyword ip_firewall_rules: IP firewall rule properties. :paramtype ip_firewall_rules: dict[str, ~azure.mgmt.synapse.models.IpFirewallRuleProperties] """ - super(ReplaceAllIpFirewallRulesRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.ip_firewall_rules = ip_firewall_rules -class ReplicationLink(ProxyResource): +class ReplicationLink(ProxyResource): # pylint: disable=too-many-instance-attributes """Represents a Sql pool replication link. Variables are only populated by the server, and will be ignored when sending a request. @@ -8624,62 +8220,58 @@ class ReplicationLink(ProxyResource): :vartype partner_database: str :ivar partner_location: The Azure Region of the partner Sql pool. :vartype partner_location: str - :ivar role: The role of the Sql pool in the replication link. Possible values include: - "Primary", "Secondary", "NonReadableSecondary", "Source", "Copy". + :ivar role: The role of the Sql pool in the replication link. Known values are: "Primary", + "Secondary", "NonReadableSecondary", "Source", and "Copy". :vartype role: str or ~azure.mgmt.synapse.models.ReplicationRole - :ivar partner_role: The role of the partner Sql pool in the replication link. Possible values - include: "Primary", "Secondary", "NonReadableSecondary", "Source", "Copy". + :ivar partner_role: The role of the partner Sql pool in the replication link. Known values are: + "Primary", "Secondary", "NonReadableSecondary", "Source", and "Copy". :vartype partner_role: str or ~azure.mgmt.synapse.models.ReplicationRole :ivar start_time: The start time for the replication link. :vartype start_time: ~datetime.datetime :ivar percent_complete: The percentage of seeding complete for the replication link. :vartype percent_complete: int - :ivar replication_state: The replication state for the replication link. Possible values - include: "PENDING", "SEEDING", "CATCH_UP", "SUSPENDED". + :ivar replication_state: The replication state for the replication link. Known values are: + "PENDING", "SEEDING", "CATCH_UP", and "SUSPENDED". :vartype replication_state: str or ~azure.mgmt.synapse.models.ReplicationState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'is_termination_allowed': {'readonly': True}, - 'replication_mode': {'readonly': True}, - 'partner_server': {'readonly': True}, - 'partner_database': {'readonly': True}, - 'partner_location': {'readonly': True}, - 'role': {'readonly': True}, - 'partner_role': {'readonly': True}, - 'start_time': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'replication_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'is_termination_allowed': {'key': 'properties.isTerminationAllowed', 'type': 'bool'}, - 'replication_mode': {'key': 'properties.replicationMode', 'type': 'str'}, - 'partner_server': {'key': 'properties.partnerServer', 'type': 'str'}, - 'partner_database': {'key': 'properties.partnerDatabase', 'type': 'str'}, - 'partner_location': {'key': 'properties.partnerLocation', 'type': 'str'}, - 'role': {'key': 'properties.role', 'type': 'str'}, - 'partner_role': {'key': 'properties.partnerRole', 'type': 'str'}, - 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, - 'percent_complete': {'key': 'properties.percentComplete', 'type': 'int'}, - 'replication_state': {'key': 'properties.replicationState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(ReplicationLink, self).__init__(**kwargs) + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": True}, + "is_termination_allowed": {"readonly": True}, + "replication_mode": {"readonly": True}, + "partner_server": {"readonly": True}, + "partner_database": {"readonly": True}, + "partner_location": {"readonly": True}, + "role": {"readonly": True}, + "partner_role": {"readonly": True}, + "start_time": {"readonly": True}, + "percent_complete": {"readonly": True}, + "replication_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "is_termination_allowed": {"key": "properties.isTerminationAllowed", "type": "bool"}, + "replication_mode": {"key": "properties.replicationMode", "type": "str"}, + "partner_server": {"key": "properties.partnerServer", "type": "str"}, + "partner_database": {"key": "properties.partnerDatabase", "type": "str"}, + "partner_location": {"key": "properties.partnerLocation", "type": "str"}, + "role": {"key": "properties.role", "type": "str"}, + "partner_role": {"key": "properties.partnerRole", "type": "str"}, + "start_time": {"key": "properties.startTime", "type": "iso-8601"}, + "percent_complete": {"key": "properties.percentComplete", "type": "int"}, + "replication_state": {"key": "properties.replicationState", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.location = None self.is_termination_allowed = None self.replication_mode = None @@ -8693,7 +8285,7 @@ def __init__( self.replication_state = None -class ReplicationLinkListResult(msrest.serialization.Model): +class ReplicationLinkListResult(_serialization.Model): """Represents the response to a List Sql pool replication link request. Variables are only populated by the server, and will be ignored when sending a request. @@ -8705,61 +8297,51 @@ class ReplicationLinkListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ReplicationLink]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ReplicationLink]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["ReplicationLink"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ReplicationLink"]] = None, **kwargs): """ :keyword value: The list of Sql pool replication links housed in the Sql pool. :paramtype value: list[~azure.mgmt.synapse.models.ReplicationLink] """ - super(ReplicationLinkListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ResourceMoveDefinition(msrest.serialization.Model): +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: Required. The target ID for the resource. + :ivar id: The target ID for the resource. Required. :vartype id: str """ _validation = { - 'id': {'required': True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin """ - :keyword id: Required. The target ID for the resource. + :keyword id: The target ID for the resource. Required. :paramtype id: str """ - super(ResourceMoveDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class RestorableDroppedSqlPool(ProxyResource): +class RestorableDroppedSqlPool(ProxyResource): # pylint: disable=too-many-instance-attributes """A restorable dropped Sql pool. Variables are only populated by the server, and will be ignored when sending a request. @@ -8793,42 +8375,38 @@ class RestorableDroppedSqlPool(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'database_name': {'readonly': True}, - 'edition': {'readonly': True}, - 'max_size_bytes': {'readonly': True}, - 'service_level_objective': {'readonly': True}, - 'elastic_pool_name': {'readonly': True}, - 'creation_date': {'readonly': True}, - 'deletion_date': {'readonly': True}, - 'earliest_restore_date': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": True}, + "database_name": {"readonly": True}, + "edition": {"readonly": True}, + "max_size_bytes": {"readonly": True}, + "service_level_objective": {"readonly": True}, + "elastic_pool_name": {"readonly": True}, + "creation_date": {"readonly": True}, + "deletion_date": {"readonly": True}, + "earliest_restore_date": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'database_name': {'key': 'properties.databaseName', 'type': 'str'}, - 'edition': {'key': 'properties.edition', 'type': 'str'}, - 'max_size_bytes': {'key': 'properties.maxSizeBytes', 'type': 'str'}, - 'service_level_objective': {'key': 'properties.serviceLevelObjective', 'type': 'str'}, - 'elastic_pool_name': {'key': 'properties.elasticPoolName', 'type': 'str'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'deletion_date': {'key': 'properties.deletionDate', 'type': 'iso-8601'}, - 'earliest_restore_date': {'key': 'properties.earliestRestoreDate', 'type': 'iso-8601'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "database_name": {"key": "properties.databaseName", "type": "str"}, + "edition": {"key": "properties.edition", "type": "str"}, + "max_size_bytes": {"key": "properties.maxSizeBytes", "type": "str"}, + "service_level_objective": {"key": "properties.serviceLevelObjective", "type": "str"}, + "elastic_pool_name": {"key": "properties.elasticPoolName", "type": "str"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "deletion_date": {"key": "properties.deletionDate", "type": "iso-8601"}, + "earliest_restore_date": {"key": "properties.earliestRestoreDate", "type": "iso-8601"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RestorableDroppedSqlPool, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.location = None self.database_name = None self.edition = None @@ -8840,34 +8418,29 @@ def __init__( self.earliest_restore_date = None -class RestorableDroppedSqlPoolListResult(msrest.serialization.Model): +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. - :ivar value: Required. A list of restorable dropped Sql pools. + :ivar value: A list of restorable dropped Sql pools. Required. :vartype value: list[~azure.mgmt.synapse.models.RestorableDroppedSqlPool] """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[RestorableDroppedSqlPool]'}, + "value": {"key": "value", "type": "[RestorableDroppedSqlPool]"}, } - def __init__( - self, - *, - value: List["RestorableDroppedSqlPool"], - **kwargs - ): + def __init__(self, *, value: List["_models.RestorableDroppedSqlPool"], **kwargs): """ - :keyword value: Required. A list of restorable dropped Sql pools. + :keyword value: A list of restorable dropped Sql pools. Required. :paramtype value: list[~azure.mgmt.synapse.models.RestorableDroppedSqlPool] """ - super(RestorableDroppedSqlPoolListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value @@ -8886,7 +8459,7 @@ class RestorePoint(ProxyResource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar restore_point_type: The type of restore point. Possible values include: "CONTINUOUS", + :ivar restore_point_type: The type of restore point. Known values are: "CONTINUOUS" and "DISCRETE". :vartype restore_point_type: str or ~azure.mgmt.synapse.models.RestorePointType :ivar earliest_restore_date: The earliest time to which this database can be restored. @@ -8898,34 +8471,30 @@ class RestorePoint(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'restore_point_type': {'readonly': True}, - 'earliest_restore_date': {'readonly': True}, - 'restore_point_creation_date': {'readonly': True}, - 'restore_point_label': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": True}, + "restore_point_type": {"readonly": True}, + "earliest_restore_date": {"readonly": True}, + "restore_point_creation_date": {"readonly": True}, + "restore_point_label": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'restore_point_type': {'key': 'properties.restorePointType', 'type': 'str'}, - 'earliest_restore_date': {'key': 'properties.earliestRestoreDate', 'type': 'iso-8601'}, - 'restore_point_creation_date': {'key': 'properties.restorePointCreationDate', 'type': 'iso-8601'}, - 'restore_point_label': {'key': 'properties.restorePointLabel', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "restore_point_type": {"key": "properties.restorePointType", "type": "str"}, + "earliest_restore_date": {"key": "properties.earliestRestoreDate", "type": "iso-8601"}, + "restore_point_creation_date": {"key": "properties.restorePointCreationDate", "type": "iso-8601"}, + "restore_point_label": {"key": "properties.restorePointLabel", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RestorePoint, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.location = None self.restore_point_type = None self.earliest_restore_date = None @@ -8933,7 +8502,7 @@ def __init__( self.restore_point_label = None -class RestorePointListResult(msrest.serialization.Model): +class RestorePointListResult(_serialization.Model): """A list of long term retention backups. Variables are only populated by the server, and will be ignored when sending a request. @@ -8945,57 +8514,47 @@ class RestorePointListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[RestorePoint]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[RestorePoint]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(RestorePointListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class SecretBase(msrest.serialization.Model): +class SecretBase(_serialization.Model): """The base definition of a secret type. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: SecureString. + 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. - :ivar type: Required. Type of the secret.Constant filled by server. + :ivar type: Type of the secret. Required. :vartype type: str """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, } - _subtype_map = { - 'type': {'SecureString': 'SecureString'} - } + _subtype_map = {"type": {"SecureString": "SecureString"}} - def __init__( - self, - **kwargs - ): - """ - """ - super(SecretBase, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None # type: Optional[str] @@ -9004,34 +8563,29 @@ class SecureString(SecretBase): All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of the secret.Constant filled by server. + :ivar type: Type of the secret. Required. :vartype type: str - :ivar value: Required. Value of secure string. + :ivar value: Value of secure string. Required. :vartype value: str """ _validation = { - 'type': {'required': True}, - 'value': {'required': True}, + "type": {"required": True}, + "value": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - *, - value: str, - **kwargs - ): + def __init__(self, *, value: str, **kwargs): """ - :keyword value: Required. Value of secure string. + :keyword value: Value of secure string. Required. :paramtype value: str """ - super(SecureString, self).__init__(**kwargs) - self.type = 'SecureString' # type: str + super().__init__(**kwargs) + self.type = "SecureString" # type: str self.value = value @@ -9042,9 +8596,9 @@ class SelfHostedIntegrationRuntime(IntegrationRuntime): :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :vartype additional_properties: dict[str, any] - :ivar type: Required. Type of integration runtime.Constant filled by server. Possible values - include: "Managed", "SelfHosted". + :vartype additional_properties: dict[str, JSON] + :ivar type: Type of integration runtime. Required. Known values are: "Managed" and + "SelfHosted". :vartype type: str or ~azure.mgmt.synapse.models.IntegrationRuntimeType :ivar description: Integration runtime description. :vartype description: str @@ -9053,55 +8607,54 @@ class SelfHostedIntegrationRuntime(IntegrationRuntime): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'type': {'key': 'type', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'linked_info': {'key': 'typeProperties.linkedInfo', 'type': 'LinkedIntegrationRuntimeType'}, + "additional_properties": {"key": "", "type": "{object}"}, + "type": {"key": "type", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "linked_info": {"key": "typeProperties.linkedInfo", "type": "LinkedIntegrationRuntimeType"}, } def __init__( self, *, - additional_properties: Optional[Dict[str, Any]] = None, + additional_properties: Optional[Dict[str, JSON]] = None, description: Optional[str] = None, - linked_info: Optional["LinkedIntegrationRuntimeType"] = None, + linked_info: Optional["_models.LinkedIntegrationRuntimeType"] = None, **kwargs ): """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. - :paramtype additional_properties: dict[str, any] + :paramtype additional_properties: dict[str, JSON] :keyword description: Integration runtime description. :paramtype description: str :keyword linked_info: Linked integration runtime type from data factory. :paramtype linked_info: ~azure.mgmt.synapse.models.LinkedIntegrationRuntimeType """ - super(SelfHostedIntegrationRuntime, self).__init__(additional_properties=additional_properties, description=description, **kwargs) - self.type = 'SelfHosted' # type: str + super().__init__(additional_properties=additional_properties, description=description, **kwargs) + self.type = "SelfHosted" # type: str self.linked_info = linked_info -class SelfHostedIntegrationRuntimeNode(msrest.serialization.Model): +class SelfHostedIntegrationRuntimeNode(_serialization.Model): # pylint: disable=too-many-instance-attributes """Properties of Self-hosted integration runtime node. Variables are only populated by the server, and will be ignored when sending a request. :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :vartype additional_properties: dict[str, any] + :vartype additional_properties: dict[str, JSON] :ivar node_name: Name of the integration runtime node. :vartype node_name: str :ivar machine_name: Machine name of the integration runtime node. :vartype machine_name: str :ivar host_service_uri: URI for the host machine of the integration runtime. :vartype host_service_uri: str - :ivar status: Status of the integration runtime node. Possible values include: - "NeedRegistration", "Online", "Limited", "Offline", "Upgrading", "Initializing", - "InitializeFailed". + :ivar status: Status of the integration runtime node. Known values are: "NeedRegistration", + "Online", "Limited", "Offline", "Upgrading", "Initializing", and "InitializeFailed". :vartype status: str or ~azure.mgmt.synapse.models.SelfHostedIntegrationRuntimeNodeStatus :ivar capabilities: The integration runtime capabilities dictionary. :vartype capabilities: dict[str, str] @@ -9121,8 +8674,8 @@ class SelfHostedIntegrationRuntimeNode(msrest.serialization.Model): :vartype last_start_time: ~datetime.datetime :ivar last_stop_time: The integration runtime node last stop time. :vartype last_stop_time: ~datetime.datetime - :ivar last_update_result: The result of the last integration runtime node update. Possible - values include: "None", "Succeed", "Fail". + :ivar last_update_result: The result of the last integration runtime node update. Known values + are: "None", "Succeed", and "Fail". :vartype last_update_result: str or ~azure.mgmt.synapse.models.IntegrationRuntimeUpdateResult :ivar last_start_update_time: The last time for the integration runtime node update start. :vartype last_start_update_time: ~datetime.datetime @@ -9138,60 +8691,55 @@ class SelfHostedIntegrationRuntimeNode(msrest.serialization.Model): """ _validation = { - 'node_name': {'readonly': True}, - 'machine_name': {'readonly': True}, - 'host_service_uri': {'readonly': True}, - 'status': {'readonly': True}, - 'capabilities': {'readonly': True}, - 'version_status': {'readonly': True}, - 'version': {'readonly': True}, - 'register_time': {'readonly': True}, - 'last_connect_time': {'readonly': True}, - 'expiry_time': {'readonly': True}, - 'last_start_time': {'readonly': True}, - 'last_stop_time': {'readonly': True}, - 'last_update_result': {'readonly': True}, - 'last_start_update_time': {'readonly': True}, - 'last_end_update_time': {'readonly': True}, - 'is_active_dispatcher': {'readonly': True}, - 'concurrent_jobs_limit': {'readonly': True}, - 'max_concurrent_jobs': {'readonly': True}, - } - - _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'node_name': {'key': 'nodeName', 'type': 'str'}, - 'machine_name': {'key': 'machineName', 'type': 'str'}, - 'host_service_uri': {'key': 'hostServiceUri', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'capabilities': {'key': 'capabilities', 'type': '{str}'}, - 'version_status': {'key': 'versionStatus', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'register_time': {'key': 'registerTime', 'type': 'iso-8601'}, - 'last_connect_time': {'key': 'lastConnectTime', 'type': 'iso-8601'}, - 'expiry_time': {'key': 'expiryTime', 'type': 'iso-8601'}, - 'last_start_time': {'key': 'lastStartTime', 'type': 'iso-8601'}, - 'last_stop_time': {'key': 'lastStopTime', 'type': 'iso-8601'}, - 'last_update_result': {'key': 'lastUpdateResult', 'type': 'str'}, - 'last_start_update_time': {'key': 'lastStartUpdateTime', 'type': 'iso-8601'}, - 'last_end_update_time': {'key': 'lastEndUpdateTime', 'type': 'iso-8601'}, - 'is_active_dispatcher': {'key': 'isActiveDispatcher', 'type': 'bool'}, - 'concurrent_jobs_limit': {'key': 'concurrentJobsLimit', 'type': 'int'}, - 'max_concurrent_jobs': {'key': 'maxConcurrentJobs', 'type': 'int'}, - } - - def __init__( - self, - *, - additional_properties: Optional[Dict[str, Any]] = None, - **kwargs - ): + "node_name": {"readonly": True}, + "machine_name": {"readonly": True}, + "host_service_uri": {"readonly": True}, + "status": {"readonly": True}, + "capabilities": {"readonly": True}, + "version_status": {"readonly": True}, + "version": {"readonly": True}, + "register_time": {"readonly": True}, + "last_connect_time": {"readonly": True}, + "expiry_time": {"readonly": True}, + "last_start_time": {"readonly": True}, + "last_stop_time": {"readonly": True}, + "last_update_result": {"readonly": True}, + "last_start_update_time": {"readonly": True}, + "last_end_update_time": {"readonly": True}, + "is_active_dispatcher": {"readonly": True}, + "concurrent_jobs_limit": {"readonly": True}, + "max_concurrent_jobs": {"readonly": True}, + } + + _attribute_map = { + "additional_properties": {"key": "", "type": "{object}"}, + "node_name": {"key": "nodeName", "type": "str"}, + "machine_name": {"key": "machineName", "type": "str"}, + "host_service_uri": {"key": "hostServiceUri", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "capabilities": {"key": "capabilities", "type": "{str}"}, + "version_status": {"key": "versionStatus", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "register_time": {"key": "registerTime", "type": "iso-8601"}, + "last_connect_time": {"key": "lastConnectTime", "type": "iso-8601"}, + "expiry_time": {"key": "expiryTime", "type": "iso-8601"}, + "last_start_time": {"key": "lastStartTime", "type": "iso-8601"}, + "last_stop_time": {"key": "lastStopTime", "type": "iso-8601"}, + "last_update_result": {"key": "lastUpdateResult", "type": "str"}, + "last_start_update_time": {"key": "lastStartUpdateTime", "type": "iso-8601"}, + "last_end_update_time": {"key": "lastEndUpdateTime", "type": "iso-8601"}, + "is_active_dispatcher": {"key": "isActiveDispatcher", "type": "bool"}, + "concurrent_jobs_limit": {"key": "concurrentJobsLimit", "type": "int"}, + "max_concurrent_jobs": {"key": "maxConcurrentJobs", "type": "int"}, + } + + def __init__(self, *, additional_properties: Optional[Dict[str, JSON]] = None, **kwargs): """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. - :paramtype additional_properties: dict[str, any] + :paramtype additional_properties: dict[str, JSON] """ - super(SelfHostedIntegrationRuntimeNode, self).__init__(**kwargs) + super().__init__(**kwargs) self.additional_properties = additional_properties self.node_name = None self.machine_name = None @@ -9213,7 +8761,7 @@ def __init__( self.max_concurrent_jobs = None -class SelfHostedIntegrationRuntimeStatus(IntegrationRuntimeStatus): +class SelfHostedIntegrationRuntimeStatus(IntegrationRuntimeStatus): # pylint: disable=too-many-instance-attributes """Self-hosted integration runtime status. Variables are only populated by the server, and will be ignored when sending a request. @@ -9222,14 +8770,14 @@ class SelfHostedIntegrationRuntimeStatus(IntegrationRuntimeStatus): :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :vartype additional_properties: dict[str, any] - :ivar type: Required. Type of integration runtime.Constant filled by server. Possible values - include: "Managed", "SelfHosted". + :vartype additional_properties: dict[str, JSON] + :ivar type: Type of integration runtime. Required. Known values are: "Managed" and + "SelfHosted". :vartype type: str or ~azure.mgmt.synapse.models.IntegrationRuntimeType :ivar data_factory_name: The workspace name which the integration runtime belong to. :vartype data_factory_name: str - :ivar state: The state of integration runtime. Possible values include: "Initial", "Stopped", - "Started", "Starting", "Stopping", "NeedRegistration", "Online", "Limited", "Offline", + :ivar state: The state of integration runtime. Known values are: "Initial", "Stopped", + "Started", "Starting", "Stopping", "NeedRegistration", "Online", "Limited", "Offline", and "AccessDenied". :vartype state: str or ~azure.mgmt.synapse.models.IntegrationRuntimeState :ivar create_time: The time at which the integration runtime was created, in ISO8601 format. @@ -9240,8 +8788,8 @@ class SelfHostedIntegrationRuntimeStatus(IntegrationRuntimeStatus): mode. :vartype node_communication_channel_encryption_mode: str :ivar internal_channel_encryption: It is used to set the encryption mode for node-node - communication channel (when more than 2 self-hosted integration runtime nodes exist). Possible - values include: "NotSet", "SslEncrypted", "NotEncrypted". + communication channel (when more than 2 self-hosted integration runtime nodes exist). Known + values are: "NotSet", "SslEncrypted", and "NotEncrypted". :vartype internal_channel_encryption: str or ~azure.mgmt.synapse.models.IntegrationRuntimeInternalChannelEncryptionMode :ivar version: Version of the integration runtime. @@ -9261,7 +8809,7 @@ class SelfHostedIntegrationRuntimeStatus(IntegrationRuntimeStatus): :ivar service_urls: The URLs for the services used in integration runtime backend service. :vartype service_urls: list[str] :ivar auto_update: Whether Self-hosted integration runtime auto update has been turned on. - Possible values include: "On", "Off". + Known values are: "On" and "Off". :vartype auto_update: str or ~azure.mgmt.synapse.models.IntegrationRuntimeAutoUpdate :ivar version_status: Status of the integration runtime version. :vartype version_status: str @@ -9282,58 +8830,61 @@ class SelfHostedIntegrationRuntimeStatus(IntegrationRuntimeStatus): """ _validation = { - 'type': {'required': True}, - 'data_factory_name': {'readonly': True}, - 'state': {'readonly': True}, - 'create_time': {'readonly': True}, - 'task_queue_id': {'readonly': True}, - 'node_communication_channel_encryption_mode': {'readonly': True}, - 'internal_channel_encryption': {'readonly': True}, - 'version': {'readonly': True}, - 'scheduled_update_date': {'readonly': True}, - 'update_delay_offset': {'readonly': True}, - 'local_time_zone_offset': {'readonly': True}, - 'capabilities': {'readonly': True}, - 'service_urls': {'readonly': True}, - 'auto_update': {'readonly': True}, - 'version_status': {'readonly': True}, - 'pushed_version': {'readonly': True}, - 'latest_version': {'readonly': True}, - 'auto_update_eta': {'readonly': True}, - } - - _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'type': {'key': 'type', 'type': 'str'}, - 'data_factory_name': {'key': 'dataFactoryName', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'create_time': {'key': 'typeProperties.createTime', 'type': 'iso-8601'}, - 'task_queue_id': {'key': 'typeProperties.taskQueueId', 'type': 'str'}, - 'node_communication_channel_encryption_mode': {'key': 'typeProperties.nodeCommunicationChannelEncryptionMode', 'type': 'str'}, - 'internal_channel_encryption': {'key': 'typeProperties.internalChannelEncryption', 'type': 'str'}, - 'version': {'key': 'typeProperties.version', 'type': 'str'}, - 'nodes': {'key': 'typeProperties.nodes', 'type': '[SelfHostedIntegrationRuntimeNode]'}, - 'scheduled_update_date': {'key': 'typeProperties.scheduledUpdateDate', 'type': 'iso-8601'}, - 'update_delay_offset': {'key': 'typeProperties.updateDelayOffset', 'type': 'str'}, - 'local_time_zone_offset': {'key': 'typeProperties.localTimeZoneOffset', 'type': 'str'}, - 'capabilities': {'key': 'typeProperties.capabilities', 'type': '{str}'}, - 'service_urls': {'key': 'typeProperties.serviceUrls', 'type': '[str]'}, - 'auto_update': {'key': 'typeProperties.autoUpdate', 'type': 'str'}, - 'version_status': {'key': 'typeProperties.versionStatus', 'type': 'str'}, - 'links': {'key': 'typeProperties.links', 'type': '[LinkedIntegrationRuntime]'}, - 'pushed_version': {'key': 'typeProperties.pushedVersion', 'type': 'str'}, - 'latest_version': {'key': 'typeProperties.latestVersion', 'type': 'str'}, - 'auto_update_eta': {'key': 'typeProperties.autoUpdateETA', 'type': 'iso-8601'}, - 'service_region': {'key': 'typeProperties.serviceRegion', 'type': 'str'}, - 'newer_versions': {'key': 'typeProperties.newerVersions', 'type': '[str]'}, - } - - def __init__( - self, - *, - additional_properties: Optional[Dict[str, Any]] = None, - nodes: Optional[List["SelfHostedIntegrationRuntimeNode"]] = None, - links: Optional[List["LinkedIntegrationRuntime"]] = None, + "type": {"required": True}, + "data_factory_name": {"readonly": True}, + "state": {"readonly": True}, + "create_time": {"readonly": True}, + "task_queue_id": {"readonly": True}, + "node_communication_channel_encryption_mode": {"readonly": True}, + "internal_channel_encryption": {"readonly": True}, + "version": {"readonly": True}, + "scheduled_update_date": {"readonly": True}, + "update_delay_offset": {"readonly": True}, + "local_time_zone_offset": {"readonly": True}, + "capabilities": {"readonly": True}, + "service_urls": {"readonly": True}, + "auto_update": {"readonly": True}, + "version_status": {"readonly": True}, + "pushed_version": {"readonly": True}, + "latest_version": {"readonly": True}, + "auto_update_eta": {"readonly": True}, + } + + _attribute_map = { + "additional_properties": {"key": "", "type": "{object}"}, + "type": {"key": "type", "type": "str"}, + "data_factory_name": {"key": "dataFactoryName", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "create_time": {"key": "typeProperties.createTime", "type": "iso-8601"}, + "task_queue_id": {"key": "typeProperties.taskQueueId", "type": "str"}, + "node_communication_channel_encryption_mode": { + "key": "typeProperties.nodeCommunicationChannelEncryptionMode", + "type": "str", + }, + "internal_channel_encryption": {"key": "typeProperties.internalChannelEncryption", "type": "str"}, + "version": {"key": "typeProperties.version", "type": "str"}, + "nodes": {"key": "typeProperties.nodes", "type": "[SelfHostedIntegrationRuntimeNode]"}, + "scheduled_update_date": {"key": "typeProperties.scheduledUpdateDate", "type": "iso-8601"}, + "update_delay_offset": {"key": "typeProperties.updateDelayOffset", "type": "str"}, + "local_time_zone_offset": {"key": "typeProperties.localTimeZoneOffset", "type": "str"}, + "capabilities": {"key": "typeProperties.capabilities", "type": "{str}"}, + "service_urls": {"key": "typeProperties.serviceUrls", "type": "[str]"}, + "auto_update": {"key": "typeProperties.autoUpdate", "type": "str"}, + "version_status": {"key": "typeProperties.versionStatus", "type": "str"}, + "links": {"key": "typeProperties.links", "type": "[LinkedIntegrationRuntime]"}, + "pushed_version": {"key": "typeProperties.pushedVersion", "type": "str"}, + "latest_version": {"key": "typeProperties.latestVersion", "type": "str"}, + "auto_update_eta": {"key": "typeProperties.autoUpdateETA", "type": "iso-8601"}, + "service_region": {"key": "typeProperties.serviceRegion", "type": "str"}, + "newer_versions": {"key": "typeProperties.newerVersions", "type": "[str]"}, + } + + def __init__( + self, + *, + additional_properties: Optional[Dict[str, JSON]] = None, + nodes: Optional[List["_models.SelfHostedIntegrationRuntimeNode"]] = None, + links: Optional[List["_models.LinkedIntegrationRuntime"]] = None, service_region: Optional[str] = None, newer_versions: Optional[List[str]] = None, **kwargs @@ -9341,7 +8892,7 @@ def __init__( """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. - :paramtype additional_properties: dict[str, any] + :paramtype additional_properties: dict[str, JSON] :keyword nodes: The list of nodes for this integration runtime. :paramtype nodes: list[~azure.mgmt.synapse.models.SelfHostedIntegrationRuntimeNode] :keyword links: The list of linked integration runtimes that are created to share with this @@ -9352,8 +8903,8 @@ def __init__( :keyword newer_versions: The newer versions on download center. :paramtype newer_versions: list[str] """ - super(SelfHostedIntegrationRuntimeStatus, self).__init__(additional_properties=additional_properties, **kwargs) - self.type = 'SelfHosted' # type: str + super().__init__(additional_properties=additional_properties, **kwargs) + self.type = "SelfHosted" # type: str self.create_time = None self.task_queue_id = None self.node_communication_channel_encryption_mode = None @@ -9375,7 +8926,7 @@ def __init__( self.newer_versions = newer_versions -class SensitivityLabel(ProxyResource): +class SensitivityLabel(ProxyResource): # pylint: disable=too-many-instance-attributes """A sensitivity label. Variables are only populated by the server, and will be ignored when sending a request. @@ -9408,35 +8959,35 @@ class SensitivityLabel(ProxyResource): sensitivity label only. Specifies whether the sensitivity recommendation on this column is disabled (dismissed) or not. :vartype is_disabled: bool - :ivar rank: Possible values include: "None", "Low", "Medium", "High", "Critical". + :ivar rank: Known values are: "None", "Low", "Medium", "High", and "Critical". :vartype rank: str or ~azure.mgmt.synapse.models.SensitivityLabelRank """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'managed_by': {'readonly': True}, - 'schema_name': {'readonly': True}, - 'table_name': {'readonly': True}, - 'column_name': {'readonly': True}, - 'is_disabled': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "managed_by": {"readonly": True}, + "schema_name": {"readonly": True}, + "table_name": {"readonly": True}, + "column_name": {"readonly": True}, + "is_disabled": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'managed_by': {'key': 'managedBy', 'type': 'str'}, - 'schema_name': {'key': 'properties.schemaName', 'type': 'str'}, - 'table_name': {'key': 'properties.tableName', 'type': 'str'}, - 'column_name': {'key': 'properties.columnName', 'type': 'str'}, - 'label_name': {'key': 'properties.labelName', 'type': 'str'}, - 'label_id': {'key': 'properties.labelId', 'type': 'str'}, - 'information_type': {'key': 'properties.informationType', 'type': 'str'}, - 'information_type_id': {'key': 'properties.informationTypeId', 'type': 'str'}, - 'is_disabled': {'key': 'properties.isDisabled', 'type': 'bool'}, - 'rank': {'key': 'properties.rank', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "managed_by": {"key": "managedBy", "type": "str"}, + "schema_name": {"key": "properties.schemaName", "type": "str"}, + "table_name": {"key": "properties.tableName", "type": "str"}, + "column_name": {"key": "properties.columnName", "type": "str"}, + "label_name": {"key": "properties.labelName", "type": "str"}, + "label_id": {"key": "properties.labelId", "type": "str"}, + "information_type": {"key": "properties.informationType", "type": "str"}, + "information_type_id": {"key": "properties.informationTypeId", "type": "str"}, + "is_disabled": {"key": "properties.isDisabled", "type": "bool"}, + "rank": {"key": "properties.rank", "type": "str"}, } def __init__( @@ -9446,7 +8997,7 @@ def __init__( label_id: Optional[str] = None, information_type: Optional[str] = None, information_type_id: Optional[str] = None, - rank: Optional[Union[str, "SensitivityLabelRank"]] = None, + rank: Optional[Union[str, "_models.SensitivityLabelRank"]] = None, **kwargs ): """ @@ -9458,10 +9009,10 @@ def __init__( :paramtype information_type: str :keyword information_type_id: The information type ID. :paramtype information_type_id: str - :keyword rank: Possible values include: "None", "Low", "Medium", "High", "Critical". + :keyword rank: Known values are: "None", "Low", "Medium", "High", and "Critical". :paramtype rank: str or ~azure.mgmt.synapse.models.SensitivityLabelRank """ - super(SensitivityLabel, self).__init__(**kwargs) + super().__init__(**kwargs) self.managed_by = None self.schema_name = None self.table_name = None @@ -9474,7 +9025,7 @@ def __init__( self.rank = rank -class SensitivityLabelListResult(msrest.serialization.Model): +class SensitivityLabelListResult(_serialization.Model): """A list of sensitivity labels. Variables are only populated by the server, and will be ignored when sending a request. @@ -9486,22 +9037,18 @@ class SensitivityLabelListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SensitivityLabel]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SensitivityLabel]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SensitivityLabelListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None @@ -9519,7 +9066,7 @@ class SensitivityLabelUpdate(ProxyResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar op: Possible values include: "set", "remove". + :ivar op: Known values are: "set" and "remove". :vartype op: str or ~azure.mgmt.synapse.models.SensitivityLabelUpdateKind :ivar schema: Schema name of the column to update. :vartype schema: str @@ -9532,34 +9079,34 @@ class SensitivityLabelUpdate(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'op': {'key': 'properties.op', 'type': 'str'}, - 'schema': {'key': 'properties.schema', 'type': 'str'}, - 'table': {'key': 'properties.table', 'type': 'str'}, - 'column': {'key': 'properties.column', 'type': 'str'}, - 'sensitivity_label': {'key': 'properties.sensitivityLabel', 'type': 'SensitivityLabel'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "op": {"key": "properties.op", "type": "str"}, + "schema": {"key": "properties.schema", "type": "str"}, + "table": {"key": "properties.table", "type": "str"}, + "column": {"key": "properties.column", "type": "str"}, + "sensitivity_label": {"key": "properties.sensitivityLabel", "type": "SensitivityLabel"}, } def __init__( self, *, - op: Optional[Union[str, "SensitivityLabelUpdateKind"]] = None, + op: Optional[Union[str, "_models.SensitivityLabelUpdateKind"]] = None, schema: Optional[str] = None, table: Optional[str] = None, column: Optional[str] = None, - sensitivity_label: Optional["SensitivityLabel"] = None, + sensitivity_label: Optional["_models.SensitivityLabel"] = None, **kwargs ): """ - :keyword op: Possible values include: "set", "remove". + :keyword op: Known values are: "set" and "remove". :paramtype op: str or ~azure.mgmt.synapse.models.SensitivityLabelUpdateKind :keyword schema: Schema name of the column to update. :paramtype schema: str @@ -9570,7 +9117,7 @@ def __init__( :keyword sensitivity_label: The sensitivity label information to apply on a column. :paramtype sensitivity_label: ~azure.mgmt.synapse.models.SensitivityLabel """ - super(SensitivityLabelUpdate, self).__init__(**kwargs) + super().__init__(**kwargs) self.op = op self.schema = schema self.table = table @@ -9578,7 +9125,7 @@ def __init__( self.sensitivity_label = sensitivity_label -class SensitivityLabelUpdateList(msrest.serialization.Model): +class SensitivityLabelUpdateList(_serialization.Model): """A list of sensitivity label update operations. :ivar operations: @@ -9586,24 +9133,19 @@ class SensitivityLabelUpdateList(msrest.serialization.Model): """ _attribute_map = { - 'operations': {'key': 'operations', 'type': '[SensitivityLabelUpdate]'}, + "operations": {"key": "operations", "type": "[SensitivityLabelUpdate]"}, } - def __init__( - self, - *, - operations: Optional[List["SensitivityLabelUpdate"]] = None, - **kwargs - ): + def __init__(self, *, operations: Optional[List["_models.SensitivityLabelUpdate"]] = None, **kwargs): """ :keyword operations: :paramtype operations: list[~azure.mgmt.synapse.models.SensitivityLabelUpdate] """ - super(SensitivityLabelUpdateList, self).__init__(**kwargs) + super().__init__(**kwargs) self.operations = operations -class ServerBlobAuditingPolicy(ProxyResource): +class ServerBlobAuditingPolicy(ProxyResource): # pylint: disable=too-many-instance-attributes """A server blob auditing policy. Variables are only populated by the server, and will be ignored when sending a request. @@ -9617,7 +9159,7 @@ class ServerBlobAuditingPolicy(ProxyResource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar state: Specifies the state of the policy. If state is Enabled, storageEndpoint or - isAzureMonitorTargetEnabled are required. Possible values include: "Enabled", "Disabled". + isAzureMonitorTargetEnabled are required. Known values are: "Enabled" and "Disabled". :vartype state: str or ~azure.mgmt.synapse.models.BlobAuditingPolicyState :ivar storage_endpoint: Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or @@ -9628,8 +9170,8 @@ class ServerBlobAuditingPolicy(ProxyResource): storageAccountAccessKey will use SQL server system-assigned managed identity to access the storage. Prerequisites for using managed identity authentication: - - + + #. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). #. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data Contributor' RBAC role to the server identity. @@ -9640,21 +9182,21 @@ class ServerBlobAuditingPolicy(ProxyResource): account. :vartype retention_days: int :ivar audit_actions_and_groups: Specifies the Actions-Groups and Actions to audit. - + The recommended set of action groups to use is the following combination - this will audit all the queries and stored procedures executed against the database, as well as successful and failed logins: - + BATCH_COMPLETED_GROUP, SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, FAILED_DATABASE_AUTHENTICATION_GROUP. - + This above combination is also the set that is configured by default when enabling auditing from the Azure portal. - + The supported action groups to audit are (note: choose only specific groups that cover your auditing needs. Using unnecessary groups could lead to very large quantities of audit records): - + APPLICATION_ROLE_CHANGE_PASSWORD_GROUP BACKUP_RESTORE_GROUP DATABASE_LOGOUT_GROUP @@ -9675,14 +9217,14 @@ class ServerBlobAuditingPolicy(ProxyResource): USER_CHANGE_PASSWORD_GROUP BATCH_STARTED_GROUP BATCH_COMPLETED_GROUP - + These are groups that cover all sql statements and stored procedures executed against the database, and should not be used in combination with other groups as this will result in duplicate audit logs. - + For more information, see `Database-Level Audit Action Groups `_. - + 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: SELECT @@ -9692,19 +9234,19 @@ class ServerBlobAuditingPolicy(ProxyResource): EXECUTE RECEIVE REFERENCES - + The general form for defining an action to be audited is: {action} ON {object} BY {principal} - + Note that :code:`` in the above format can refer to an object like a table, view, or stored procedure, or an entire database or schema. For the latter cases, the forms DATABASE::{db_name} and SCHEMA::{schema_name} are used, respectively. - + For example: SELECT on dbo.myTable by public SELECT on DATABASE::myDatabase by public SELECT on SCHEMA::mySchema by public - + For more information, see `Database-Level Audit Actions `_. :vartype audit_actions_and_groups: list[str] @@ -9717,15 +9259,15 @@ class ServerBlobAuditingPolicy(ProxyResource): Monitor. In order to send the events to Azure Monitor, specify 'state' as 'Enabled' and 'isAzureMonitorTargetEnabled' as true. - + When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' diagnostic logs category on the database should be also created. Note that for server level audit you should use the 'master' database as {databaseName}. - + 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 - + For more information, see `Diagnostic Settings REST API `_ or `Diagnostic Settings PowerShell `_. @@ -9738,14 +9280,14 @@ class ServerBlobAuditingPolicy(ProxyResource): logs will be sent to Azure Monitor. In order to send the events to Azure Monitor, specify 'State' as 'Enabled', 'IsAzureMonitorTargetEnabled' as true and 'IsDevopsAuditEnabled' as true - + When using REST API to configure auditing, Diagnostic Settings with 'DevOpsOperationsAudit' diagnostic logs category on the master database should also be created. - + 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 - + For more information, see `Diagnostic Settings REST API `_ or `Diagnostic Settings PowerShell `_. @@ -9753,31 +9295,31 @@ class ServerBlobAuditingPolicy(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'storage_endpoint': {'key': 'properties.storageEndpoint', 'type': 'str'}, - 'storage_account_access_key': {'key': 'properties.storageAccountAccessKey', 'type': 'str'}, - 'retention_days': {'key': 'properties.retentionDays', 'type': 'int'}, - 'audit_actions_and_groups': {'key': 'properties.auditActionsAndGroups', 'type': '[str]'}, - 'storage_account_subscription_id': {'key': 'properties.storageAccountSubscriptionId', 'type': 'str'}, - 'is_storage_secondary_key_in_use': {'key': 'properties.isStorageSecondaryKeyInUse', 'type': 'bool'}, - 'is_azure_monitor_target_enabled': {'key': 'properties.isAzureMonitorTargetEnabled', 'type': 'bool'}, - 'queue_delay_ms': {'key': 'properties.queueDelayMs', 'type': 'int'}, - 'is_devops_audit_enabled': {'key': 'properties.isDevopsAuditEnabled', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "state": {"key": "properties.state", "type": "str"}, + "storage_endpoint": {"key": "properties.storageEndpoint", "type": "str"}, + "storage_account_access_key": {"key": "properties.storageAccountAccessKey", "type": "str"}, + "retention_days": {"key": "properties.retentionDays", "type": "int"}, + "audit_actions_and_groups": {"key": "properties.auditActionsAndGroups", "type": "[str]"}, + "storage_account_subscription_id": {"key": "properties.storageAccountSubscriptionId", "type": "str"}, + "is_storage_secondary_key_in_use": {"key": "properties.isStorageSecondaryKeyInUse", "type": "bool"}, + "is_azure_monitor_target_enabled": {"key": "properties.isAzureMonitorTargetEnabled", "type": "bool"}, + "queue_delay_ms": {"key": "properties.queueDelayMs", "type": "int"}, + "is_devops_audit_enabled": {"key": "properties.isDevopsAuditEnabled", "type": "bool"}, } def __init__( self, *, - state: Optional[Union[str, "BlobAuditingPolicyState"]] = None, + state: Optional[Union[str, "_models.BlobAuditingPolicyState"]] = None, storage_endpoint: Optional[str] = None, storage_account_access_key: Optional[str] = None, retention_days: Optional[int] = None, @@ -9791,7 +9333,7 @@ def __init__( ): """ :keyword state: Specifies the state of the policy. If state is Enabled, storageEndpoint or - isAzureMonitorTargetEnabled are required. Possible values include: "Enabled", "Disabled". + isAzureMonitorTargetEnabled are required. Known values are: "Enabled" and "Disabled". :paramtype state: str or ~azure.mgmt.synapse.models.BlobAuditingPolicyState :keyword storage_endpoint: Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint or @@ -9803,8 +9345,8 @@ def __init__( storageAccountAccessKey will use SQL server system-assigned managed identity to access the storage. Prerequisites for using managed identity authentication: - - + + #. Assign SQL Server a system-assigned managed identity in Azure Active Directory (AAD). #. Grant SQL Server identity access to the storage account by adding 'Storage Blob Data Contributor' RBAC role to the server identity. @@ -9815,21 +9357,21 @@ def __init__( account. :paramtype retention_days: int :keyword audit_actions_and_groups: Specifies the Actions-Groups and Actions to audit. - + The recommended set of action groups to use is the following combination - this will audit all the queries and stored procedures executed against the database, as well as successful and failed logins: - + BATCH_COMPLETED_GROUP, SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, FAILED_DATABASE_AUTHENTICATION_GROUP. - + This above combination is also the set that is configured by default when enabling auditing from the Azure portal. - + The supported action groups to audit are (note: choose only specific groups that cover your auditing needs. Using unnecessary groups could lead to very large quantities of audit records): - + APPLICATION_ROLE_CHANGE_PASSWORD_GROUP BACKUP_RESTORE_GROUP DATABASE_LOGOUT_GROUP @@ -9850,14 +9392,14 @@ def __init__( USER_CHANGE_PASSWORD_GROUP BATCH_STARTED_GROUP BATCH_COMPLETED_GROUP - + These are groups that cover all sql statements and stored procedures executed against the database, and should not be used in combination with other groups as this will result in duplicate audit logs. - + For more information, see `Database-Level Audit Action Groups `_. - + 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: SELECT @@ -9867,19 +9409,19 @@ def __init__( EXECUTE RECEIVE REFERENCES - + The general form for defining an action to be audited is: {action} ON {object} BY {principal} - + Note that :code:`` in the above format can refer to an object like a table, view, or stored procedure, or an entire database or schema. For the latter cases, the forms DATABASE::{db_name} and SCHEMA::{schema_name} are used, respectively. - + For example: SELECT on dbo.myTable by public SELECT on DATABASE::myDatabase by public SELECT on SCHEMA::mySchema by public - + For more information, see `Database-Level Audit Actions `_. :paramtype audit_actions_and_groups: list[str] @@ -9892,15 +9434,15 @@ def __init__( Monitor. In order to send the events to Azure Monitor, specify 'state' as 'Enabled' and 'isAzureMonitorTargetEnabled' as true. - + When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' diagnostic logs category on the database should be also created. Note that for server level audit you should use the 'master' database as {databaseName}. - + 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 - + For more information, see `Diagnostic Settings REST API `_ or `Diagnostic Settings PowerShell `_. @@ -9913,20 +9455,20 @@ def __init__( devops logs will be sent to Azure Monitor. In order to send the events to Azure Monitor, specify 'State' as 'Enabled', 'IsAzureMonitorTargetEnabled' as true and 'IsDevopsAuditEnabled' as true - + When using REST API to configure auditing, Diagnostic Settings with 'DevOpsOperationsAudit' diagnostic logs category on the master database should also be created. - + 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 - + For more information, see `Diagnostic Settings REST API `_ or `Diagnostic Settings PowerShell `_. :paramtype is_devops_audit_enabled: bool """ - super(ServerBlobAuditingPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.state = state self.storage_endpoint = storage_endpoint self.storage_account_access_key = storage_account_access_key @@ -9939,7 +9481,7 @@ def __init__( self.is_devops_audit_enabled = is_devops_audit_enabled -class ServerBlobAuditingPolicyListResult(msrest.serialization.Model): +class ServerBlobAuditingPolicyListResult(_serialization.Model): """A list of server auditing settings. Variables are only populated by the server, and will be ignored when sending a request. @@ -9951,27 +9493,23 @@ class ServerBlobAuditingPolicyListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ServerBlobAuditingPolicy]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ServerBlobAuditingPolicy]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ServerBlobAuditingPolicyListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ServerSecurityAlertPolicy(ProxyResource): +class ServerSecurityAlertPolicy(ProxyResource): # pylint: disable=too-many-instance-attributes """Workspace managed Sql server security alert policy. Variables are only populated by the server, and will be ignored when sending a request. @@ -9985,7 +9523,7 @@ class ServerSecurityAlertPolicy(ProxyResource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar state: Specifies the state of the policy, whether it is enabled or disabled or a policy - has not been applied yet on the specific server. Possible values include: "New", "Enabled", + has not been applied yet on the specific server. Known values are: "New", "Enabled", and "Disabled". :vartype state: str or ~azure.mgmt.synapse.models.SecurityAlertPolicyState :ivar disabled_alerts: Specifies an array of alerts that are disabled. Allowed values are: @@ -10009,30 +9547,30 @@ class ServerSecurityAlertPolicy(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'creation_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "creation_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'disabled_alerts': {'key': 'properties.disabledAlerts', 'type': '[str]'}, - 'email_addresses': {'key': 'properties.emailAddresses', 'type': '[str]'}, - 'email_account_admins': {'key': 'properties.emailAccountAdmins', 'type': 'bool'}, - 'storage_endpoint': {'key': 'properties.storageEndpoint', 'type': 'str'}, - 'storage_account_access_key': {'key': 'properties.storageAccountAccessKey', 'type': 'str'}, - 'retention_days': {'key': 'properties.retentionDays', 'type': 'int'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "state": {"key": "properties.state", "type": "str"}, + "disabled_alerts": {"key": "properties.disabledAlerts", "type": "[str]"}, + "email_addresses": {"key": "properties.emailAddresses", "type": "[str]"}, + "email_account_admins": {"key": "properties.emailAccountAdmins", "type": "bool"}, + "storage_endpoint": {"key": "properties.storageEndpoint", "type": "str"}, + "storage_account_access_key": {"key": "properties.storageAccountAccessKey", "type": "str"}, + "retention_days": {"key": "properties.retentionDays", "type": "int"}, + "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, } def __init__( self, *, - state: Optional[Union[str, "SecurityAlertPolicyState"]] = None, + state: Optional[Union[str, "_models.SecurityAlertPolicyState"]] = None, disabled_alerts: Optional[List[str]] = None, email_addresses: Optional[List[str]] = None, email_account_admins: Optional[bool] = None, @@ -10043,8 +9581,8 @@ def __init__( ): """ :keyword state: Specifies the state of the policy, whether it is enabled or disabled or a - policy has not been applied yet on the specific server. Possible values include: "New", - "Enabled", "Disabled". + policy has not been applied yet on the specific server. Known values are: "New", "Enabled", and + "Disabled". :paramtype state: str or ~azure.mgmt.synapse.models.SecurityAlertPolicyState :keyword disabled_alerts: Specifies an array of alerts that are disabled. Allowed values are: Sql_Injection, Sql_Injection_Vulnerability, Access_Anomaly, Data_Exfiltration, Unsafe_Action. @@ -10064,7 +9602,7 @@ def __init__( logs. :paramtype retention_days: int """ - super(ServerSecurityAlertPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.state = state self.disabled_alerts = disabled_alerts self.email_addresses = email_addresses @@ -10075,7 +9613,7 @@ def __init__( self.creation_time = None -class ServerSecurityAlertPolicyListResult(msrest.serialization.Model): +class ServerSecurityAlertPolicyListResult(_serialization.Model): """A list of the workspace managed sql server's security alert policies. Variables are only populated by the server, and will be ignored when sending a request. @@ -10087,27 +9625,23 @@ class ServerSecurityAlertPolicyListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ServerSecurityAlertPolicy]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ServerSecurityAlertPolicy]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ServerSecurityAlertPolicyListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ServerUsage(msrest.serialization.Model): +class ServerUsage(_serialization.Model): """Represents server metrics. Variables are only populated by the server, and will be ignored when sending a request. @@ -10129,32 +9663,28 @@ class ServerUsage(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'resource_name': {'readonly': True}, - 'display_name': {'readonly': True}, - 'current_value': {'readonly': True}, - 'limit': {'readonly': True}, - 'unit': {'readonly': True}, - 'next_reset_time': {'readonly': True}, + "name": {"readonly": True}, + "resource_name": {"readonly": True}, + "display_name": {"readonly": True}, + "current_value": {"readonly": True}, + "limit": {"readonly": True}, + "unit": {"readonly": True}, + "next_reset_time": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'float'}, - 'limit': {'key': 'limit', 'type': 'float'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'next_reset_time': {'key': 'nextResetTime', 'type': 'iso-8601'}, + "name": {"key": "name", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "current_value": {"key": "currentValue", "type": "float"}, + "limit": {"key": "limit", "type": "float"}, + "unit": {"key": "unit", "type": "str"}, + "next_reset_time": {"key": "nextResetTime", "type": "iso-8601"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ServerUsage, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.resource_name = None self.display_name = None @@ -10164,40 +9694,35 @@ def __init__( self.next_reset_time = None -class ServerUsageListResult(msrest.serialization.Model): +class ServerUsageListResult(_serialization.Model): """Represents the response to a list server metrics request. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar value: Required. The list of server metrics for the server. + :ivar value: The list of server metrics for the server. Required. :vartype value: list[~azure.mgmt.synapse.models.ServerUsage] :ivar next_link: Link to retrieve next page of results. :vartype next_link: str """ _validation = { - 'value': {'required': True}, - 'next_link': {'readonly': True}, + "value": {"required": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ServerUsage]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ServerUsage]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: List["ServerUsage"], - **kwargs - ): + def __init__(self, *, value: List["_models.ServerUsage"], **kwargs): """ - :keyword value: Required. The list of server metrics for the server. + :keyword value: The list of server metrics for the server. Required. :paramtype value: list[~azure.mgmt.synapse.models.ServerUsage] """ - super(ServerUsageListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None @@ -10232,19 +9757,22 @@ class ServerVulnerabilityAssessment(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'storage_container_path': {'key': 'properties.storageContainerPath', 'type': 'str'}, - 'storage_container_sas_key': {'key': 'properties.storageContainerSasKey', 'type': 'str'}, - 'storage_account_access_key': {'key': 'properties.storageAccountAccessKey', 'type': 'str'}, - 'recurring_scans': {'key': 'properties.recurringScans', 'type': 'VulnerabilityAssessmentRecurringScansProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "storage_container_path": {"key": "properties.storageContainerPath", "type": "str"}, + "storage_container_sas_key": {"key": "properties.storageContainerSasKey", "type": "str"}, + "storage_account_access_key": {"key": "properties.storageAccountAccessKey", "type": "str"}, + "recurring_scans": { + "key": "properties.recurringScans", + "type": "VulnerabilityAssessmentRecurringScansProperties", + }, } def __init__( @@ -10253,7 +9781,7 @@ def __init__( storage_container_path: Optional[str] = None, storage_container_sas_key: Optional[str] = None, storage_account_access_key: Optional[str] = None, - recurring_scans: Optional["VulnerabilityAssessmentRecurringScansProperties"] = None, + recurring_scans: Optional["_models.VulnerabilityAssessmentRecurringScansProperties"] = None, **kwargs ): """ @@ -10272,14 +9800,14 @@ def __init__( :paramtype recurring_scans: ~azure.mgmt.synapse.models.VulnerabilityAssessmentRecurringScansProperties """ - super(ServerVulnerabilityAssessment, self).__init__(**kwargs) + super().__init__(**kwargs) self.storage_container_path = storage_container_path self.storage_container_sas_key = storage_container_sas_key self.storage_account_access_key = storage_account_access_key self.recurring_scans = recurring_scans -class ServerVulnerabilityAssessmentListResult(msrest.serialization.Model): +class ServerVulnerabilityAssessmentListResult(_serialization.Model): """A list of the server's vulnerability assessments. Variables are only populated by the server, and will be ignored when sending a request. @@ -10291,27 +9819,23 @@ class ServerVulnerabilityAssessmentListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ServerVulnerabilityAssessment]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ServerVulnerabilityAssessmentListResult, self).__init__(**kwargs) + _attribute_map = { + "value": {"key": "value", "type": "[ServerVulnerabilityAssessment]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """SQL pool SKU. :ivar tier: The service tier. @@ -10324,18 +9848,13 @@ class Sku(msrest.serialization.Model): """ _attribute_map = { - 'tier': {'key': 'tier', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "tier": {"key": "tier", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } def __init__( - self, - *, - tier: Optional[str] = None, - name: Optional[str] = None, - capacity: Optional[int] = None, - **kwargs + self, *, tier: Optional[str] = None, name: Optional[str] = None, capacity: Optional[int] = None, **kwargs ): """ :keyword tier: The service tier. @@ -10346,13 +9865,13 @@ def __init__( included. If scale out/in is not possible for the resource this may be omitted. :paramtype capacity: int """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.tier = tier self.name = name self.capacity = capacity -class SkuDescription(msrest.serialization.Model): +class SkuDescription(_serialization.Model): """The Kusto SKU description of given resource type. Variables are only populated by the server, and will be ignored when sending a request. @@ -10368,34 +9887,30 @@ class SkuDescription(msrest.serialization.Model): :ivar location_info: Locations and zones. :vartype location_info: list[~azure.mgmt.synapse.models.SkuLocationInfoItem] :ivar restrictions: The restrictions because of which SKU cannot be used. - :vartype restrictions: list[any] + :vartype restrictions: list[JSON] """ _validation = { - 'resource_type': {'readonly': True}, - 'name': {'readonly': True}, - 'size': {'readonly': True}, - 'locations': {'readonly': True}, - 'location_info': {'readonly': True}, - 'restrictions': {'readonly': True}, + "resource_type": {"readonly": True}, + "name": {"readonly": True}, + "size": {"readonly": True}, + "locations": {"readonly": True}, + "location_info": {"readonly": True}, + "restrictions": {"readonly": True}, } _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'location_info': {'key': 'locationInfo', 'type': '[SkuLocationInfoItem]'}, - 'restrictions': {'key': 'restrictions', 'type': '[object]'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "size": {"key": "size", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "location_info": {"key": "locationInfo", "type": "[SkuLocationInfoItem]"}, + "restrictions": {"key": "restrictions", "type": "[object]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SkuDescription, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.resource_type = None self.name = None self.size = None @@ -10404,7 +9919,7 @@ def __init__( self.restrictions = None -class SkuDescriptionList(msrest.serialization.Model): +class SkuDescriptionList(_serialization.Model): """The list of the SKU descriptions. Variables are only populated by the server, and will be ignored when sending a request. @@ -10414,62 +9929,52 @@ class SkuDescriptionList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SkuDescription]'}, + "value": {"key": "value", "type": "[SkuDescription]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SkuDescriptionList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class SkuLocationInfoItem(msrest.serialization.Model): +class SkuLocationInfoItem(_serialization.Model): """The locations and zones info for SKU. All required parameters must be populated in order to send to Azure. - :ivar location: Required. The available location of the SKU. + :ivar location: The available location of the SKU. Required. :vartype location: str :ivar zones: The available zone of the SKU. :vartype zones: list[str] """ _validation = { - 'location': {'required': True}, + "location": {"required": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, + "location": {"key": "location", "type": "str"}, + "zones": {"key": "zones", "type": "[str]"}, } - def __init__( - self, - *, - location: str, - zones: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, location: str, zones: Optional[List[str]] = None, **kwargs): """ - :keyword location: Required. The available location of the SKU. + :keyword location: The available location of the SKU. Required. :paramtype location: str :keyword zones: The available zone of the SKU. :paramtype zones: list[str] """ - super(SkuLocationInfoItem, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.zones = zones -class SparkConfigProperties(msrest.serialization.Model): +class SparkConfigProperties(_serialization.Model): """SparkConfig Properties for a Big Data pool powered by Apache Spark. Variables are only populated by the server, and will be ignored when sending a request. @@ -10480,20 +9985,20 @@ class SparkConfigProperties(msrest.serialization.Model): :vartype content: str :ivar filename: The filename of the spark config properties file. :vartype filename: str - :ivar configuration_type: The type of the spark config properties file. Possible values - include: "File", "Artifact". + :ivar configuration_type: The type of the spark config properties file. Known values are: + "File" and "Artifact". :vartype configuration_type: str or ~azure.mgmt.synapse.models.ConfigurationType """ _validation = { - 'time': {'readonly': True}, + "time": {"readonly": True}, } _attribute_map = { - 'time': {'key': 'time', 'type': 'iso-8601'}, - 'content': {'key': 'content', 'type': 'str'}, - 'filename': {'key': 'filename', 'type': 'str'}, - 'configuration_type': {'key': 'configurationType', 'type': 'str'}, + "time": {"key": "time", "type": "iso-8601"}, + "content": {"key": "content", "type": "str"}, + "filename": {"key": "filename", "type": "str"}, + "configuration_type": {"key": "configurationType", "type": "str"}, } def __init__( @@ -10501,7 +10006,7 @@ def __init__( *, content: Optional[str] = None, filename: Optional[str] = None, - configuration_type: Optional[Union[str, "ConfigurationType"]] = None, + configuration_type: Optional[Union[str, "_models.ConfigurationType"]] = None, **kwargs ): """ @@ -10509,56 +10014,50 @@ def __init__( :paramtype content: str :keyword filename: The filename of the spark config properties file. :paramtype filename: str - :keyword configuration_type: The type of the spark config properties file. Possible values - include: "File", "Artifact". + :keyword configuration_type: The type of the spark config properties file. Known values are: + "File" and "Artifact". :paramtype configuration_type: str or ~azure.mgmt.synapse.models.ConfigurationType """ - super(SparkConfigProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.time = None self.content = content self.filename = filename self.configuration_type = configuration_type -class SparkConfigurationListResponse(msrest.serialization.Model): +class SparkConfigurationListResponse(_serialization.Model): """A list of SparkConfiguration resources. All required parameters must be populated in order to send to Azure. - :ivar value: Required. List of SparkConfiguration. + :ivar value: List of SparkConfiguration. Required. :vartype value: list[~azure.mgmt.synapse.models.SparkConfigurationResource] :ivar next_link: The link to the next page of results, if any remaining results exist. :vartype next_link: str """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SparkConfigurationResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SparkConfigurationResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: List["SparkConfigurationResource"], - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: List["_models.SparkConfigurationResource"], next_link: Optional[str] = None, **kwargs): """ - :keyword value: Required. List of SparkConfiguration. + :keyword value: List of SparkConfiguration. Required. :paramtype value: list[~azure.mgmt.synapse.models.SparkConfigurationResource] :keyword next_link: The link to the next page of results, if any remaining results exist. :paramtype next_link: str """ - super(SparkConfigurationListResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SparkConfigurationResource(SubResource): +class SparkConfigurationResource(SubResource): # pylint: disable=too-many-instance-attributes """SparkConfiguration response details. Variables are only populated by the server, and will be ignored when sending a request. @@ -10577,7 +10076,7 @@ class SparkConfigurationResource(SubResource): :vartype etag: str :ivar description: Description about the SparkConfiguration. :vartype description: str - :ivar configs: Required. SparkConfiguration configs. + :ivar configs: SparkConfiguration configs. Required. :vartype configs: dict[str, str] :ivar annotations: Annotations for SparkConfiguration. :vartype annotations: list[str] @@ -10587,27 +10086,30 @@ class SparkConfigurationResource(SubResource): :vartype created_by: str :ivar created: The timestamp of resource creation. :vartype created: ~datetime.datetime + :ivar config_merge_rule: SparkConfiguration merge configs. + :vartype config_merge_rule: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'configs': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "configs": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'configs': {'key': 'properties.configs', 'type': '{str}'}, - 'annotations': {'key': 'properties.annotations', 'type': '[str]'}, - 'notes': {'key': 'properties.notes', 'type': 'str'}, - 'created_by': {'key': 'properties.createdBy', 'type': 'str'}, - 'created': {'key': 'properties.created', 'type': 'iso-8601'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "configs": {"key": "properties.configs", "type": "{str}"}, + "annotations": {"key": "properties.annotations", "type": "[str]"}, + "notes": {"key": "properties.notes", "type": "str"}, + "created_by": {"key": "properties.createdBy", "type": "str"}, + "created": {"key": "properties.created", "type": "iso-8601"}, + "config_merge_rule": {"key": "properties.configMergeRule", "type": "{str}"}, } def __init__( @@ -10619,12 +10121,13 @@ def __init__( notes: Optional[str] = None, created_by: Optional[str] = None, created: Optional[datetime.datetime] = None, + config_merge_rule: Optional[Dict[str, str]] = None, **kwargs ): """ :keyword description: Description about the SparkConfiguration. :paramtype description: str - :keyword configs: Required. SparkConfiguration configs. + :keyword configs: SparkConfiguration configs. Required. :paramtype configs: dict[str, str] :keyword annotations: Annotations for SparkConfiguration. :paramtype annotations: list[str] @@ -10634,17 +10137,20 @@ def __init__( :paramtype created_by: str :keyword created: The timestamp of resource creation. :paramtype created: ~datetime.datetime + :keyword config_merge_rule: SparkConfiguration merge configs. + :paramtype config_merge_rule: dict[str, str] """ - super(SparkConfigurationResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.configs = configs self.annotations = annotations self.notes = notes self.created_by = created_by self.created = created + self.config_merge_rule = config_merge_rule -class SqlPool(TrackedResource): +class SqlPool(TrackedResource): # pylint: disable=too-many-instance-attributes """A SQL Analytics pool. Variables are only populated by the server, and will be ignored when sending a request. @@ -10659,14 +10165,14 @@ class SqlPool(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar sku: SQL pool SKU. :vartype sku: ~azure.mgmt.synapse.models.Sku :ivar max_size_bytes: Maximum size in bytes. - :vartype max_size_bytes: long + :vartype max_size_bytes: int :ivar collation: Collation mode. :vartype collation: str :ivar source_database_id: Source database to create from. @@ -10680,57 +10186,57 @@ class SqlPool(TrackedResource): :ivar restore_point_in_time: Snapshot time to restore. :vartype restore_point_in_time: ~datetime.datetime :ivar create_mode: Specifies the mode of sql pool creation. - + Default: regular sql pool creation. - + PointInTimeRestore: Creates a sql pool by restoring a point in time backup of an existing sql pool. sourceDatabaseId must be specified as the resource ID of the existing sql pool, and restorePointInTime must be specified. - + Recovery: Creates a sql pool by a geo-replicated backup. sourceDatabaseId must be specified as the recoverableDatabaseId to restore. - + Restore: Creates a sql pool by restoring a backup of a deleted sql pool. SourceDatabaseId should be the sql pool's original resource ID. SourceDatabaseId and sourceDatabaseDeletionDate - must be specified. Possible values include: "Default", "PointInTimeRestore", "Recovery", + must be specified. Known values are: "Default", "PointInTimeRestore", "Recovery", and "Restore". :vartype create_mode: str or ~azure.mgmt.synapse.models.CreateMode :ivar creation_date: Date the SQL pool was created. :vartype creation_date: ~datetime.datetime :ivar storage_account_type: The storage account type used to store backups for this sql pool. - Possible values include: "GRS", "LRS". Default value: "GRS". + Known values are: "GRS" and "LRS". :vartype storage_account_type: str or ~azure.mgmt.synapse.models.StorageAccountType :ivar source_database_deletion_date: Specifies the time that the sql pool was deleted. :vartype source_database_deletion_date: ~datetime.datetime """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'status': {'readonly': True}, - 'creation_date': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "status": {"readonly": True}, + "creation_date": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'max_size_bytes': {'key': 'properties.maxSizeBytes', 'type': 'long'}, - 'collation': {'key': 'properties.collation', 'type': 'str'}, - 'source_database_id': {'key': 'properties.sourceDatabaseId', 'type': 'str'}, - 'recoverable_database_id': {'key': 'properties.recoverableDatabaseId', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'restore_point_in_time': {'key': 'properties.restorePointInTime', 'type': 'iso-8601'}, - 'create_mode': {'key': 'properties.createMode', 'type': 'str'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'storage_account_type': {'key': 'properties.storageAccountType', 'type': 'str'}, - 'source_database_deletion_date': {'key': 'properties.sourceDatabaseDeletionDate', 'type': 'iso-8601'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "max_size_bytes": {"key": "properties.maxSizeBytes", "type": "int"}, + "collation": {"key": "properties.collation", "type": "str"}, + "source_database_id": {"key": "properties.sourceDatabaseId", "type": "str"}, + "recoverable_database_id": {"key": "properties.recoverableDatabaseId", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "restore_point_in_time": {"key": "properties.restorePointInTime", "type": "iso-8601"}, + "create_mode": {"key": "properties.createMode", "type": "str"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "storage_account_type": {"key": "properties.storageAccountType", "type": "str"}, + "source_database_deletion_date": {"key": "properties.sourceDatabaseDeletionDate", "type": "iso-8601"}, } def __init__( @@ -10738,27 +10244,27 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, max_size_bytes: Optional[int] = None, - collation: Optional[str] = "", + collation: str = "", source_database_id: Optional[str] = None, recoverable_database_id: Optional[str] = None, provisioning_state: Optional[str] = None, restore_point_in_time: Optional[datetime.datetime] = None, - create_mode: Optional[Union[str, "CreateMode"]] = None, - storage_account_type: Optional[Union[str, "StorageAccountType"]] = "GRS", + create_mode: Optional[Union[str, "_models.CreateMode"]] = None, + storage_account_type: Union[str, "_models.StorageAccountType"] = "GRS", source_database_deletion_date: Optional[datetime.datetime] = None, **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str :keyword sku: SQL pool SKU. :paramtype sku: ~azure.mgmt.synapse.models.Sku :keyword max_size_bytes: Maximum size in bytes. - :paramtype max_size_bytes: long + :paramtype max_size_bytes: int :keyword collation: Collation mode. :paramtype collation: str :keyword source_database_id: Source database to create from. @@ -10770,28 +10276,28 @@ def __init__( :keyword restore_point_in_time: Snapshot time to restore. :paramtype restore_point_in_time: ~datetime.datetime :keyword create_mode: Specifies the mode of sql pool creation. - + Default: regular sql pool creation. - + PointInTimeRestore: Creates a sql pool by restoring a point in time backup of an existing sql pool. sourceDatabaseId must be specified as the resource ID of the existing sql pool, and restorePointInTime must be specified. - + Recovery: Creates a sql pool by a geo-replicated backup. sourceDatabaseId must be specified as the recoverableDatabaseId to restore. - + Restore: Creates a sql pool by restoring a backup of a deleted sql pool. SourceDatabaseId should be the sql pool's original resource ID. SourceDatabaseId and sourceDatabaseDeletionDate - must be specified. Possible values include: "Default", "PointInTimeRestore", "Recovery", + must be specified. Known values are: "Default", "PointInTimeRestore", "Recovery", and "Restore". :paramtype create_mode: str or ~azure.mgmt.synapse.models.CreateMode :keyword storage_account_type: The storage account type used to store backups for this sql - pool. Possible values include: "GRS", "LRS". Default value: "GRS". + pool. Known values are: "GRS" and "LRS". :paramtype storage_account_type: str or ~azure.mgmt.synapse.models.StorageAccountType :keyword source_database_deletion_date: Specifies the time that the sql pool was deleted. :paramtype source_database_deletion_date: ~datetime.datetime """ - super(SqlPool, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.sku = sku self.max_size_bytes = max_size_bytes self.collation = collation @@ -10806,7 +10312,7 @@ def __init__( self.source_database_deletion_date = source_database_deletion_date -class SqlPoolBlobAuditingPolicy(ProxyResource): +class SqlPoolBlobAuditingPolicy(ProxyResource): # pylint: disable=too-many-instance-attributes """A Sql pool blob auditing policy. Variables are only populated by the server, and will be ignored when sending a request. @@ -10822,7 +10328,7 @@ class SqlPoolBlobAuditingPolicy(ProxyResource): :ivar kind: Resource kind. :vartype kind: str :ivar state: Specifies the state of the policy. If state is Enabled, storageEndpoint or - isAzureMonitorTargetEnabled are required. Possible values include: "Enabled", "Disabled". + isAzureMonitorTargetEnabled are required. Known values are: "Enabled" and "Disabled". :vartype state: str or ~azure.mgmt.synapse.models.BlobAuditingPolicyState :ivar storage_endpoint: Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint is required. @@ -10834,21 +10340,21 @@ class SqlPoolBlobAuditingPolicy(ProxyResource): account. :vartype retention_days: int :ivar audit_actions_and_groups: Specifies the Actions-Groups and Actions to audit. - + The recommended set of action groups to use is the following combination - this will audit all the queries and stored procedures executed against the database, as well as successful and failed logins: - + BATCH_COMPLETED_GROUP, SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, FAILED_DATABASE_AUTHENTICATION_GROUP. - + This above combination is also the set that is configured by default when enabling auditing from the Azure portal. - + The supported action groups to audit are (note: choose only specific groups that cover your auditing needs. Using unnecessary groups could lead to very large quantities of audit records): - + APPLICATION_ROLE_CHANGE_PASSWORD_GROUP BACKUP_RESTORE_GROUP DATABASE_LOGOUT_GROUP @@ -10869,14 +10375,14 @@ class SqlPoolBlobAuditingPolicy(ProxyResource): USER_CHANGE_PASSWORD_GROUP BATCH_STARTED_GROUP BATCH_COMPLETED_GROUP - + These are groups that cover all sql statements and stored procedures executed against the database, and should not be used in combination with other groups as this will result in duplicate audit logs. - + For more information, see `Database-Level Audit Action Groups `_. - + 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: SELECT @@ -10886,19 +10392,19 @@ class SqlPoolBlobAuditingPolicy(ProxyResource): EXECUTE RECEIVE REFERENCES - + The general form for defining an action to be audited is: {action} ON {object} BY {principal} - + Note that :code:`` in the above format can refer to an object like a table, view, or stored procedure, or an entire database or schema. For the latter cases, the forms DATABASE::{db_name} and SCHEMA::{schema_name} are used, respectively. - + For example: SELECT on dbo.myTable by public SELECT on DATABASE::myDatabase by public SELECT on SCHEMA::mySchema by public - + For more information, see `Database-Level Audit Actions `_. :vartype audit_actions_and_groups: list[str] @@ -10911,15 +10417,15 @@ class SqlPoolBlobAuditingPolicy(ProxyResource): Monitor. In order to send the events to Azure Monitor, specify 'state' as 'Enabled' and 'isAzureMonitorTargetEnabled' as true. - + When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' diagnostic logs category on the database should be also created. Note that for server level audit you should use the 'master' database as {databaseName}. - + 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 - + For more information, see `Diagnostic Settings REST API `_ or `Diagnostic Settings PowerShell `_. @@ -10927,43 +10433,43 @@ class SqlPoolBlobAuditingPolicy(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'storage_endpoint': {'key': 'properties.storageEndpoint', 'type': 'str'}, - 'storage_account_access_key': {'key': 'properties.storageAccountAccessKey', 'type': 'str'}, - 'retention_days': {'key': 'properties.retentionDays', 'type': 'int'}, - 'audit_actions_and_groups': {'key': 'properties.auditActionsAndGroups', 'type': '[str]'}, - 'storage_account_subscription_id': {'key': 'properties.storageAccountSubscriptionId', 'type': 'str'}, - 'is_storage_secondary_key_in_use': {'key': 'properties.isStorageSecondaryKeyInUse', 'type': 'bool'}, - 'is_azure_monitor_target_enabled': {'key': 'properties.isAzureMonitorTargetEnabled', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "state": {"key": "properties.state", "type": "str"}, + "storage_endpoint": {"key": "properties.storageEndpoint", "type": "str"}, + "storage_account_access_key": {"key": "properties.storageAccountAccessKey", "type": "str"}, + "retention_days": {"key": "properties.retentionDays", "type": "int"}, + "audit_actions_and_groups": {"key": "properties.auditActionsAndGroups", "type": "[str]"}, + "storage_account_subscription_id": {"key": "properties.storageAccountSubscriptionId", "type": "str"}, + "is_storage_secondary_key_in_use": {"key": "properties.isStorageSecondaryKeyInUse", "type": "bool"}, + "is_azure_monitor_target_enabled": {"key": "properties.isAzureMonitorTargetEnabled", "type": "bool"}, } def __init__( self, *, - state: Optional[Union[str, "BlobAuditingPolicyState"]] = None, + state: Optional[Union[str, "_models.BlobAuditingPolicyState"]] = None, storage_endpoint: Optional[str] = None, storage_account_access_key: Optional[str] = None, retention_days: Optional[int] = None, audit_actions_and_groups: Optional[List[str]] = None, storage_account_subscription_id: Optional[str] = None, is_storage_secondary_key_in_use: Optional[bool] = None, - is_azure_monitor_target_enabled: Optional[bool] = False, + is_azure_monitor_target_enabled: bool = False, **kwargs ): """ :keyword state: Specifies the state of the policy. If state is Enabled, storageEndpoint or - isAzureMonitorTargetEnabled are required. Possible values include: "Enabled", "Disabled". + isAzureMonitorTargetEnabled are required. Known values are: "Enabled" and "Disabled". :paramtype state: str or ~azure.mgmt.synapse.models.BlobAuditingPolicyState :keyword storage_endpoint: Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint is required. @@ -10976,21 +10482,21 @@ def __init__( account. :paramtype retention_days: int :keyword audit_actions_and_groups: Specifies the Actions-Groups and Actions to audit. - + The recommended set of action groups to use is the following combination - this will audit all the queries and stored procedures executed against the database, as well as successful and failed logins: - + BATCH_COMPLETED_GROUP, SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP, FAILED_DATABASE_AUTHENTICATION_GROUP. - + This above combination is also the set that is configured by default when enabling auditing from the Azure portal. - + The supported action groups to audit are (note: choose only specific groups that cover your auditing needs. Using unnecessary groups could lead to very large quantities of audit records): - + APPLICATION_ROLE_CHANGE_PASSWORD_GROUP BACKUP_RESTORE_GROUP DATABASE_LOGOUT_GROUP @@ -11011,14 +10517,14 @@ def __init__( USER_CHANGE_PASSWORD_GROUP BATCH_STARTED_GROUP BATCH_COMPLETED_GROUP - + These are groups that cover all sql statements and stored procedures executed against the database, and should not be used in combination with other groups as this will result in duplicate audit logs. - + For more information, see `Database-Level Audit Action Groups `_. - + 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: SELECT @@ -11028,19 +10534,19 @@ def __init__( EXECUTE RECEIVE REFERENCES - + The general form for defining an action to be audited is: {action} ON {object} BY {principal} - + Note that :code:`` in the above format can refer to an object like a table, view, or stored procedure, or an entire database or schema. For the latter cases, the forms DATABASE::{db_name} and SCHEMA::{schema_name} are used, respectively. - + For example: SELECT on dbo.myTable by public SELECT on DATABASE::myDatabase by public SELECT on SCHEMA::mySchema by public - + For more information, see `Database-Level Audit Actions `_. :paramtype audit_actions_and_groups: list[str] @@ -11053,21 +10559,21 @@ def __init__( Monitor. In order to send the events to Azure Monitor, specify 'state' as 'Enabled' and 'isAzureMonitorTargetEnabled' as true. - + When using REST API to configure auditing, Diagnostic Settings with 'SQLSecurityAuditEvents' diagnostic logs category on the database should be also created. Note that for server level audit you should use the 'master' database as {databaseName}. - + 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 - + For more information, see `Diagnostic Settings REST API `_ or `Diagnostic Settings PowerShell `_. :paramtype is_azure_monitor_target_enabled: bool """ - super(SqlPoolBlobAuditingPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.kind = None self.state = state self.storage_endpoint = storage_endpoint @@ -11079,7 +10585,7 @@ def __init__( self.is_azure_monitor_target_enabled = is_azure_monitor_target_enabled -class SqlPoolBlobAuditingPolicyListResult(msrest.serialization.Model): +class SqlPoolBlobAuditingPolicyListResult(_serialization.Model): """A list of Sql pool auditing settings. Variables are only populated by the server, and will be ignored when sending a request. @@ -11091,27 +10597,23 @@ class SqlPoolBlobAuditingPolicyListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SqlPoolBlobAuditingPolicy]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SqlPoolBlobAuditingPolicy]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SqlPoolBlobAuditingPolicyListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class SqlPoolBlobAuditingPolicySqlPoolOperationListResult(msrest.serialization.Model): +class SqlPoolBlobAuditingPolicySqlPoolOperationListResult(_serialization.Model): """The response to a list Sql pool operations request. Variables are only populated by the server, and will be ignored when sending a request. @@ -11123,22 +10625,18 @@ class SqlPoolBlobAuditingPolicySqlPoolOperationListResult(msrest.serialization.M """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SqlPoolOperation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SqlPoolOperation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SqlPoolBlobAuditingPolicySqlPoolOperationListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None @@ -11156,51 +10654,47 @@ class SqlPoolColumn(ProxyResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar column_type: The column data type. Possible values include: "image", "text", - "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", "sysname". + :ivar column_type: The column data type. Known values are: "image", "text", "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". :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 """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'is_computed': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "is_computed": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'column_type': {'key': 'properties.columnType', 'type': 'str'}, - 'is_computed': {'key': 'properties.isComputed', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "column_type": {"key": "properties.columnType", "type": "str"}, + "is_computed": {"key": "properties.isComputed", "type": "bool"}, } - def __init__( - self, - *, - column_type: Optional[Union[str, "ColumnDataType"]] = None, - **kwargs - ): + def __init__(self, *, column_type: Optional[Union[str, "_models.ColumnDataType"]] = None, **kwargs): """ - :keyword column_type: The column data type. Possible values include: "image", "text", + :keyword column_type: The column data type. Known values are: "image", "text", "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", "sysname". + "varbinary", "varchar", "binary", "char", "timestamp", "nvarchar", "nchar", "xml", and + "sysname". :paramtype column_type: str or ~azure.mgmt.synapse.models.ColumnDataType """ - super(SqlPoolColumn, self).__init__(**kwargs) + super().__init__(**kwargs) self.column_type = column_type self.is_computed = None -class SqlPoolColumnListResult(msrest.serialization.Model): +class SqlPoolColumnListResult(_serialization.Model): """A list of Sql pool columns. Variables are only populated by the server, and will be ignored when sending a request. @@ -11212,27 +10706,23 @@ class SqlPoolColumnListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SqlPoolColumn]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SqlPoolColumn]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SqlPoolColumnListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class SqlPoolConnectionPolicy(ProxyResource): +class SqlPoolConnectionPolicy(ProxyResource): # pylint: disable=too-many-instance-attributes """A Sql pool connection policy. Variables are only populated by the server, and will be ignored when sending a request. @@ -11266,26 +10756,26 @@ class SqlPoolConnectionPolicy(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'readonly': True}, - 'location': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"readonly": True}, + "location": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'security_enabled_access': {'key': 'properties.securityEnabledAccess', 'type': 'str'}, - 'proxy_dns_name': {'key': 'properties.proxyDnsName', 'type': 'str'}, - 'proxy_port': {'key': 'properties.proxyPort', 'type': 'str'}, - 'visibility': {'key': 'properties.visibility', 'type': 'str'}, - 'use_server_default': {'key': 'properties.useServerDefault', 'type': 'str'}, - 'redirection_state': {'key': 'properties.redirectionState', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "security_enabled_access": {"key": "properties.securityEnabledAccess", "type": "str"}, + "proxy_dns_name": {"key": "properties.proxyDnsName", "type": "str"}, + "proxy_port": {"key": "properties.proxyPort", "type": "str"}, + "visibility": {"key": "properties.visibility", "type": "str"}, + "use_server_default": {"key": "properties.useServerDefault", "type": "str"}, + "redirection_state": {"key": "properties.redirectionState", "type": "str"}, + "state": {"key": "properties.state", "type": "str"}, } def __init__( @@ -11316,7 +10806,7 @@ def __init__( :keyword state: The connection policy state. :paramtype state: str """ - super(SqlPoolConnectionPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.kind = None self.location = None self.security_enabled_access = security_enabled_access @@ -11328,7 +10818,7 @@ def __init__( self.state = state -class SqlPoolInfoListResult(msrest.serialization.Model): +class SqlPoolInfoListResult(_serialization.Model): """List of SQL pools. :ivar next_link: Link to the next page of results. @@ -11338,29 +10828,23 @@ class SqlPoolInfoListResult(msrest.serialization.Model): """ _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[SqlPool]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[SqlPool]"}, } - def __init__( - self, - *, - next_link: Optional[str] = None, - value: Optional[List["SqlPool"]] = None, - **kwargs - ): + def __init__(self, *, next_link: Optional[str] = None, value: Optional[List["_models.SqlPool"]] = None, **kwargs): """ :keyword next_link: Link to the next page of results. :paramtype next_link: str :keyword value: List of SQL pools. :paramtype value: list[~azure.mgmt.synapse.models.SqlPool] """ - super(SqlPoolInfoListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.next_link = next_link self.value = value -class SqlPoolOperation(ProxyResource): +class SqlPoolOperation(ProxyResource): # pylint: disable=too-many-instance-attributes """A Sql pool operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -11385,8 +10869,8 @@ class SqlPoolOperation(ProxyResource): :vartype server_name: str :ivar start_time: The operation start time. :vartype start_time: ~datetime.datetime - :ivar state: The operation state. Possible values include: "Pending", "InProgress", - "Succeeded", "Failed", "CancelInProgress", "Cancelled". + :ivar state: The operation state. Known values are: "Pending", "InProgress", "Succeeded", + "Failed", "CancelInProgress", and "Cancelled". :vartype state: str or ~azure.mgmt.synapse.models.ManagementOperationState :ivar error_code: The operation error code. :vartype error_code: int @@ -11405,52 +10889,48 @@ class SqlPoolOperation(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'database_name': {'readonly': True}, - 'operation': {'readonly': True}, - 'operation_friendly_name': {'readonly': True}, - 'percent_complete': {'readonly': True}, - 'server_name': {'readonly': True}, - 'start_time': {'readonly': True}, - 'state': {'readonly': True}, - 'error_code': {'readonly': True}, - 'error_description': {'readonly': True}, - 'error_severity': {'readonly': True}, - 'is_user_error': {'readonly': True}, - 'estimated_completion_time': {'readonly': True}, - 'description': {'readonly': True}, - 'is_cancellable': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'database_name': {'key': 'properties.databaseName', 'type': 'str'}, - 'operation': {'key': 'properties.operation', 'type': 'str'}, - 'operation_friendly_name': {'key': 'properties.operationFriendlyName', 'type': 'str'}, - 'percent_complete': {'key': 'properties.percentComplete', 'type': 'int'}, - 'server_name': {'key': 'properties.serverName', 'type': 'str'}, - 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'error_code': {'key': 'properties.errorCode', 'type': 'int'}, - 'error_description': {'key': 'properties.errorDescription', 'type': 'str'}, - 'error_severity': {'key': 'properties.errorSeverity', 'type': 'int'}, - 'is_user_error': {'key': 'properties.isUserError', 'type': 'bool'}, - 'estimated_completion_time': {'key': 'properties.estimatedCompletionTime', 'type': 'iso-8601'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'is_cancellable': {'key': 'properties.isCancellable', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(SqlPoolOperation, self).__init__(**kwargs) + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "database_name": {"readonly": True}, + "operation": {"readonly": True}, + "operation_friendly_name": {"readonly": True}, + "percent_complete": {"readonly": True}, + "server_name": {"readonly": True}, + "start_time": {"readonly": True}, + "state": {"readonly": True}, + "error_code": {"readonly": True}, + "error_description": {"readonly": True}, + "error_severity": {"readonly": True}, + "is_user_error": {"readonly": True}, + "estimated_completion_time": {"readonly": True}, + "description": {"readonly": True}, + "is_cancellable": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "database_name": {"key": "properties.databaseName", "type": "str"}, + "operation": {"key": "properties.operation", "type": "str"}, + "operation_friendly_name": {"key": "properties.operationFriendlyName", "type": "str"}, + "percent_complete": {"key": "properties.percentComplete", "type": "int"}, + "server_name": {"key": "properties.serverName", "type": "str"}, + "start_time": {"key": "properties.startTime", "type": "iso-8601"}, + "state": {"key": "properties.state", "type": "str"}, + "error_code": {"key": "properties.errorCode", "type": "int"}, + "error_description": {"key": "properties.errorDescription", "type": "str"}, + "error_severity": {"key": "properties.errorSeverity", "type": "int"}, + "is_user_error": {"key": "properties.isUserError", "type": "bool"}, + "estimated_completion_time": {"key": "properties.estimatedCompletionTime", "type": "iso-8601"}, + "description": {"key": "properties.description", "type": "str"}, + "is_cancellable": {"key": "properties.isCancellable", "type": "bool"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.database_name = None self.operation = None self.operation_friendly_name = None @@ -11467,19 +10947,19 @@ def __init__( self.is_cancellable = None -class SqlPoolPatchInfo(msrest.serialization.Model): +class SqlPoolPatchInfo(_serialization.Model): # pylint: disable=too-many-instance-attributes """A SQL Analytics pool patch info. Variables are only populated by the server, and will be ignored when sending a request. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar location: The geo-location where the resource lives. :vartype location: str :ivar sku: SQL pool SKU. :vartype sku: ~azure.mgmt.synapse.models.Sku :ivar max_size_bytes: Maximum size in bytes. - :vartype max_size_bytes: long + :vartype max_size_bytes: int :ivar collation: Collation mode. :vartype collation: str :ivar source_database_id: Source database to create from. @@ -11493,50 +10973,50 @@ class SqlPoolPatchInfo(msrest.serialization.Model): :ivar restore_point_in_time: Snapshot time to restore. :vartype restore_point_in_time: ~datetime.datetime :ivar create_mode: Specifies the mode of sql pool creation. - + Default: regular sql pool creation. - + PointInTimeRestore: Creates a sql pool by restoring a point in time backup of an existing sql pool. sourceDatabaseId must be specified as the resource ID of the existing sql pool, and restorePointInTime must be specified. - + Recovery: Creates a sql pool by a geo-replicated backup. sourceDatabaseId must be specified as the recoverableDatabaseId to restore. - + Restore: Creates a sql pool by restoring a backup of a deleted sql pool. SourceDatabaseId should be the sql pool's original resource ID. SourceDatabaseId and sourceDatabaseDeletionDate - must be specified. Possible values include: "Default", "PointInTimeRestore", "Recovery", + must be specified. Known values are: "Default", "PointInTimeRestore", "Recovery", and "Restore". :vartype create_mode: str or ~azure.mgmt.synapse.models.CreateMode :ivar creation_date: Date the SQL pool was created. :vartype creation_date: ~datetime.datetime :ivar storage_account_type: The storage account type used to store backups for this sql pool. - Possible values include: "GRS", "LRS". Default value: "GRS". + Known values are: "GRS" and "LRS". :vartype storage_account_type: str or ~azure.mgmt.synapse.models.StorageAccountType :ivar source_database_deletion_date: Specifies the time that the sql pool was deleted. :vartype source_database_deletion_date: ~datetime.datetime """ _validation = { - 'status': {'readonly': True}, - 'creation_date': {'readonly': True}, + "status": {"readonly": True}, + "creation_date": {"readonly": True}, } _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'max_size_bytes': {'key': 'properties.maxSizeBytes', 'type': 'long'}, - 'collation': {'key': 'properties.collation', 'type': 'str'}, - 'source_database_id': {'key': 'properties.sourceDatabaseId', 'type': 'str'}, - 'recoverable_database_id': {'key': 'properties.recoverableDatabaseId', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'restore_point_in_time': {'key': 'properties.restorePointInTime', 'type': 'iso-8601'}, - 'create_mode': {'key': 'properties.createMode', 'type': 'str'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - 'storage_account_type': {'key': 'properties.storageAccountType', 'type': 'str'}, - 'source_database_deletion_date': {'key': 'properties.sourceDatabaseDeletionDate', 'type': 'iso-8601'}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "max_size_bytes": {"key": "properties.maxSizeBytes", "type": "int"}, + "collation": {"key": "properties.collation", "type": "str"}, + "source_database_id": {"key": "properties.sourceDatabaseId", "type": "str"}, + "recoverable_database_id": {"key": "properties.recoverableDatabaseId", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "restore_point_in_time": {"key": "properties.restorePointInTime", "type": "iso-8601"}, + "create_mode": {"key": "properties.createMode", "type": "str"}, + "creation_date": {"key": "properties.creationDate", "type": "iso-8601"}, + "storage_account_type": {"key": "properties.storageAccountType", "type": "str"}, + "source_database_deletion_date": {"key": "properties.sourceDatabaseDeletionDate", "type": "iso-8601"}, } def __init__( @@ -11544,27 +11024,27 @@ def __init__( *, tags: Optional[Dict[str, str]] = None, location: Optional[str] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, max_size_bytes: Optional[int] = None, - collation: Optional[str] = "", + collation: str = "", source_database_id: Optional[str] = None, recoverable_database_id: Optional[str] = None, provisioning_state: Optional[str] = None, restore_point_in_time: Optional[datetime.datetime] = None, - create_mode: Optional[Union[str, "CreateMode"]] = None, - storage_account_type: Optional[Union[str, "StorageAccountType"]] = "GRS", + create_mode: Optional[Union[str, "_models.CreateMode"]] = None, + storage_account_type: Union[str, "_models.StorageAccountType"] = "GRS", source_database_deletion_date: Optional[datetime.datetime] = None, **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword location: The geo-location where the resource lives. :paramtype location: str :keyword sku: SQL pool SKU. :paramtype sku: ~azure.mgmt.synapse.models.Sku :keyword max_size_bytes: Maximum size in bytes. - :paramtype max_size_bytes: long + :paramtype max_size_bytes: int :keyword collation: Collation mode. :paramtype collation: str :keyword source_database_id: Source database to create from. @@ -11576,28 +11056,28 @@ def __init__( :keyword restore_point_in_time: Snapshot time to restore. :paramtype restore_point_in_time: ~datetime.datetime :keyword create_mode: Specifies the mode of sql pool creation. - + Default: regular sql pool creation. - + PointInTimeRestore: Creates a sql pool by restoring a point in time backup of an existing sql pool. sourceDatabaseId must be specified as the resource ID of the existing sql pool, and restorePointInTime must be specified. - + Recovery: Creates a sql pool by a geo-replicated backup. sourceDatabaseId must be specified as the recoverableDatabaseId to restore. - + Restore: Creates a sql pool by restoring a backup of a deleted sql pool. SourceDatabaseId should be the sql pool's original resource ID. SourceDatabaseId and sourceDatabaseDeletionDate - must be specified. Possible values include: "Default", "PointInTimeRestore", "Recovery", + must be specified. Known values are: "Default", "PointInTimeRestore", "Recovery", and "Restore". :paramtype create_mode: str or ~azure.mgmt.synapse.models.CreateMode :keyword storage_account_type: The storage account type used to store backups for this sql - pool. Possible values include: "GRS", "LRS". Default value: "GRS". + pool. Known values are: "GRS" and "LRS". :paramtype storage_account_type: str or ~azure.mgmt.synapse.models.StorageAccountType :keyword source_database_deletion_date: Specifies the time that the sql pool was deleted. :paramtype source_database_deletion_date: ~datetime.datetime """ - super(SqlPoolPatchInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.location = location self.sku = sku @@ -11630,27 +11110,23 @@ class SqlPoolSchema(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SqlPoolSchema, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) -class SqlPoolSchemaListResult(msrest.serialization.Model): +class SqlPoolSchemaListResult(_serialization.Model): """A list of Sql pool schemas. Variables are only populated by the server, and will be ignored when sending a request. @@ -11662,27 +11138,23 @@ class SqlPoolSchemaListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SqlPoolSchema]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SqlPoolSchema]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SqlPoolSchemaListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class SqlPoolSecurityAlertPolicy(ProxyResource): +class SqlPoolSecurityAlertPolicy(ProxyResource): # pylint: disable=too-many-instance-attributes """A Sql pool security alert policy. Variables are only populated by the server, and will be ignored when sending a request. @@ -11696,7 +11168,7 @@ class SqlPoolSecurityAlertPolicy(ProxyResource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar state: Specifies the state of the policy, whether it is enabled or disabled or a policy - has not been applied yet on the specific Sql pool. Possible values include: "New", "Enabled", + has not been applied yet on the specific Sql pool. Known values are: "New", "Enabled", and "Disabled". :vartype state: str or ~azure.mgmt.synapse.models.SecurityAlertPolicyState :ivar disabled_alerts: Specifies an array of alerts that are disabled. Allowed values are: @@ -11720,30 +11192,30 @@ class SqlPoolSecurityAlertPolicy(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'creation_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "creation_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'disabled_alerts': {'key': 'properties.disabledAlerts', 'type': '[str]'}, - 'email_addresses': {'key': 'properties.emailAddresses', 'type': '[str]'}, - 'email_account_admins': {'key': 'properties.emailAccountAdmins', 'type': 'bool'}, - 'storage_endpoint': {'key': 'properties.storageEndpoint', 'type': 'str'}, - 'storage_account_access_key': {'key': 'properties.storageAccountAccessKey', 'type': 'str'}, - 'retention_days': {'key': 'properties.retentionDays', 'type': 'int'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "state": {"key": "properties.state", "type": "str"}, + "disabled_alerts": {"key": "properties.disabledAlerts", "type": "[str]"}, + "email_addresses": {"key": "properties.emailAddresses", "type": "[str]"}, + "email_account_admins": {"key": "properties.emailAccountAdmins", "type": "bool"}, + "storage_endpoint": {"key": "properties.storageEndpoint", "type": "str"}, + "storage_account_access_key": {"key": "properties.storageAccountAccessKey", "type": "str"}, + "retention_days": {"key": "properties.retentionDays", "type": "int"}, + "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, } def __init__( self, *, - state: Optional[Union[str, "SecurityAlertPolicyState"]] = None, + state: Optional[Union[str, "_models.SecurityAlertPolicyState"]] = None, disabled_alerts: Optional[List[str]] = None, email_addresses: Optional[List[str]] = None, email_account_admins: Optional[bool] = None, @@ -11754,8 +11226,8 @@ def __init__( ): """ :keyword state: Specifies the state of the policy, whether it is enabled or disabled or a - policy has not been applied yet on the specific Sql pool. Possible values include: "New", - "Enabled", "Disabled". + policy has not been applied yet on the specific Sql pool. Known values are: "New", "Enabled", + and "Disabled". :paramtype state: str or ~azure.mgmt.synapse.models.SecurityAlertPolicyState :keyword disabled_alerts: Specifies an array of alerts that are disabled. Allowed values are: Sql_Injection, Sql_Injection_Vulnerability, Access_Anomaly, Data_Exfiltration, Unsafe_Action. @@ -11775,7 +11247,7 @@ def __init__( logs. :paramtype retention_days: int """ - super(SqlPoolSecurityAlertPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.state = state self.disabled_alerts = disabled_alerts self.email_addresses = email_addresses @@ -11802,27 +11274,23 @@ class SqlPoolTable(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SqlPoolTable, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) -class SqlPoolTableListResult(msrest.serialization.Model): +class SqlPoolTableListResult(_serialization.Model): """A list of Sql pool tables. Variables are only populated by the server, and will be ignored when sending a request. @@ -11834,27 +11302,23 @@ class SqlPoolTableListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SqlPoolTable]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SqlPoolTable]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SqlPoolTableListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class SqlPoolUsage(msrest.serialization.Model): +class SqlPoolUsage(_serialization.Model): """The Sql pool usages. Variables are only populated by the server, and will be ignored when sending a request. @@ -11876,32 +11340,28 @@ class SqlPoolUsage(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'resource_name': {'readonly': True}, - 'display_name': {'readonly': True}, - 'current_value': {'readonly': True}, - 'limit': {'readonly': True}, - 'unit': {'readonly': True}, - 'next_reset_time': {'readonly': True}, + "name": {"readonly": True}, + "resource_name": {"readonly": True}, + "display_name": {"readonly": True}, + "current_value": {"readonly": True}, + "limit": {"readonly": True}, + "unit": {"readonly": True}, + "next_reset_time": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'float'}, - 'limit': {'key': 'limit', 'type': 'float'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'next_reset_time': {'key': 'nextResetTime', 'type': 'iso-8601'}, + "name": {"key": "name", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "current_value": {"key": "currentValue", "type": "float"}, + "limit": {"key": "limit", "type": "float"}, + "unit": {"key": "unit", "type": "str"}, + "next_reset_time": {"key": "nextResetTime", "type": "iso-8601"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SqlPoolUsage, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.resource_name = None self.display_name = None @@ -11911,40 +11371,35 @@ def __init__( self.next_reset_time = None -class SqlPoolUsageListResult(msrest.serialization.Model): +class SqlPoolUsageListResult(_serialization.Model): """The response to a list Sql pool usages request. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar value: Required. The list of usages for the Sql pool. + :ivar value: The list of usages for the Sql pool. Required. :vartype value: list[~azure.mgmt.synapse.models.SqlPoolUsage] :ivar next_link: Link to retrieve next page of results. :vartype next_link: str """ _validation = { - 'value': {'required': True}, - 'next_link': {'readonly': True}, + "value": {"required": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SqlPoolUsage]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SqlPoolUsage]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: List["SqlPoolUsage"], - **kwargs - ): + def __init__(self, *, value: List["_models.SqlPoolUsage"], **kwargs): """ - :keyword value: Required. The list of usages for the Sql pool. + :keyword value: The list of usages for the Sql pool. Required. :paramtype value: list[~azure.mgmt.synapse.models.SqlPoolUsage] """ - super(SqlPoolUsageListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None @@ -11980,19 +11435,22 @@ class SqlPoolVulnerabilityAssessment(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'storage_container_path': {'key': 'properties.storageContainerPath', 'type': 'str'}, - 'storage_container_sas_key': {'key': 'properties.storageContainerSasKey', 'type': 'str'}, - 'storage_account_access_key': {'key': 'properties.storageAccountAccessKey', 'type': 'str'}, - 'recurring_scans': {'key': 'properties.recurringScans', 'type': 'VulnerabilityAssessmentRecurringScansProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "storage_container_path": {"key": "properties.storageContainerPath", "type": "str"}, + "storage_container_sas_key": {"key": "properties.storageContainerSasKey", "type": "str"}, + "storage_account_access_key": {"key": "properties.storageAccountAccessKey", "type": "str"}, + "recurring_scans": { + "key": "properties.recurringScans", + "type": "VulnerabilityAssessmentRecurringScansProperties", + }, } def __init__( @@ -12001,7 +11459,7 @@ def __init__( storage_container_path: Optional[str] = None, storage_container_sas_key: Optional[str] = None, storage_account_access_key: Optional[str] = None, - recurring_scans: Optional["VulnerabilityAssessmentRecurringScansProperties"] = None, + recurring_scans: Optional["_models.VulnerabilityAssessmentRecurringScansProperties"] = None, **kwargs ): """ @@ -12021,14 +11479,14 @@ def __init__( :paramtype recurring_scans: ~azure.mgmt.synapse.models.VulnerabilityAssessmentRecurringScansProperties """ - super(SqlPoolVulnerabilityAssessment, self).__init__(**kwargs) + super().__init__(**kwargs) self.storage_container_path = storage_container_path self.storage_container_sas_key = storage_container_sas_key self.storage_account_access_key = storage_account_access_key self.recurring_scans = recurring_scans -class SqlPoolVulnerabilityAssessmentListResult(msrest.serialization.Model): +class SqlPoolVulnerabilityAssessmentListResult(_serialization.Model): """A list of the Sql pool's vulnerability assessments. Variables are only populated by the server, and will be ignored when sending a request. @@ -12040,22 +11498,18 @@ class SqlPoolVulnerabilityAssessmentListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SqlPoolVulnerabilityAssessment]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SqlPoolVulnerabilityAssessment]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SqlPoolVulnerabilityAssessmentListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None @@ -12079,22 +11533,25 @@ class SqlPoolVulnerabilityAssessmentRuleBaseline(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'baseline_results': {'key': 'properties.baselineResults', 'type': '[SqlPoolVulnerabilityAssessmentRuleBaselineItem]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "baseline_results": { + "key": "properties.baselineResults", + "type": "[SqlPoolVulnerabilityAssessmentRuleBaselineItem]", + }, } def __init__( self, *, - baseline_results: Optional[List["SqlPoolVulnerabilityAssessmentRuleBaselineItem"]] = None, + baseline_results: Optional[List["_models.SqlPoolVulnerabilityAssessmentRuleBaselineItem"]] = None, **kwargs ): """ @@ -12102,38 +11559,33 @@ def __init__( :paramtype baseline_results: list[~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessmentRuleBaselineItem] """ - super(SqlPoolVulnerabilityAssessmentRuleBaseline, self).__init__(**kwargs) + super().__init__(**kwargs) self.baseline_results = baseline_results -class SqlPoolVulnerabilityAssessmentRuleBaselineItem(msrest.serialization.Model): +class SqlPoolVulnerabilityAssessmentRuleBaselineItem(_serialization.Model): """Properties for an Sql pool vulnerability assessment rule baseline's result. All required parameters must be populated in order to send to Azure. - :ivar result: Required. The rule baseline result. + :ivar result: The rule baseline result. Required. :vartype result: list[str] """ _validation = { - 'result': {'required': True}, + "result": {"required": True}, } _attribute_map = { - 'result': {'key': 'result', 'type': '[str]'}, + "result": {"key": "result", "type": "[str]"}, } - def __init__( - self, - *, - result: List[str], - **kwargs - ): + def __init__(self, *, result: List[str], **kwargs): """ - :keyword result: Required. The rule baseline result. + :keyword result: The rule baseline result. Required. :paramtype result: list[str] """ - super(SqlPoolVulnerabilityAssessmentRuleBaselineItem, self).__init__(**kwargs) + super().__init__(**kwargs) self.result = result @@ -12156,42 +11608,38 @@ class SqlPoolVulnerabilityAssessmentScansExport(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'exported_report_location': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "exported_report_location": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'exported_report_location': {'key': 'properties.exportedReportLocation', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "exported_report_location": {"key": "properties.exportedReportLocation", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SqlPoolVulnerabilityAssessmentScansExport, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.exported_report_location = None -class SsisObjectMetadata(msrest.serialization.Model): +class SsisObjectMetadata(_serialization.Model): """SSIS object metadata. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: SsisEnvironment, SsisFolder, SsisPackage, SsisProject. + 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. - :ivar type: Required. Type of metadata.Constant filled by server. Possible values include: - "Folder", "Project", "Package", "Environment". + :ivar type: Type of metadata. Required. Known values are: "Folder", "Project", "Package", and + "Environment". :vartype type: str or ~azure.mgmt.synapse.models.SsisObjectMetadataType :ivar id: Metadata id. - :vartype id: long + :vartype id: int :ivar name: Metadata name. :vartype name: str :ivar description: Metadata description. @@ -12199,37 +11647,42 @@ class SsisObjectMetadata(msrest.serialization.Model): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'long'}, - 'name': {'key': 'name', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "id": {"key": "id", "type": "int"}, + "name": {"key": "name", "type": "str"}, + "description": {"key": "description", "type": "str"}, } _subtype_map = { - 'type': {'Environment': 'SsisEnvironment', 'Folder': 'SsisFolder', 'Package': 'SsisPackage', 'Project': 'SsisProject'} + "type": { + "Environment": "SsisEnvironment", + "Folder": "SsisFolder", + "Package": "SsisPackage", + "Project": "SsisProject", + } } def __init__( self, *, - id: Optional[int] = None, + id: Optional[int] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, description: Optional[str] = None, **kwargs ): """ :keyword id: Metadata id. - :paramtype id: long + :paramtype id: int :keyword name: Metadata name. :paramtype name: str :keyword description: Metadata description. :paramtype description: str """ - super(SsisObjectMetadata, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = None # type: Optional[str] self.id = id self.name = name @@ -12241,67 +11694,67 @@ class SsisEnvironment(SsisObjectMetadata): All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of metadata.Constant filled by server. Possible values include: - "Folder", "Project", "Package", "Environment". + :ivar type: Type of metadata. Required. Known values are: "Folder", "Project", "Package", and + "Environment". :vartype type: str or ~azure.mgmt.synapse.models.SsisObjectMetadataType :ivar id: Metadata id. - :vartype id: long + :vartype id: int :ivar name: Metadata name. :vartype name: str :ivar description: Metadata description. :vartype description: str :ivar folder_id: Folder id which contains environment. - :vartype folder_id: long + :vartype folder_id: int :ivar variables: Variable in environment. :vartype variables: list[~azure.mgmt.synapse.models.SsisVariable] """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'long'}, - 'name': {'key': 'name', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'folder_id': {'key': 'folderId', 'type': 'long'}, - 'variables': {'key': 'variables', 'type': '[SsisVariable]'}, + "type": {"key": "type", "type": "str"}, + "id": {"key": "id", "type": "int"}, + "name": {"key": "name", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "folder_id": {"key": "folderId", "type": "int"}, + "variables": {"key": "variables", "type": "[SsisVariable]"}, } def __init__( self, *, - id: Optional[int] = None, + id: Optional[int] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, description: Optional[str] = None, folder_id: Optional[int] = None, - variables: Optional[List["SsisVariable"]] = None, + variables: Optional[List["_models.SsisVariable"]] = None, **kwargs ): """ :keyword id: Metadata id. - :paramtype id: long + :paramtype id: int :keyword name: Metadata name. :paramtype name: str :keyword description: Metadata description. :paramtype description: str :keyword folder_id: Folder id which contains environment. - :paramtype folder_id: long + :paramtype folder_id: int :keyword variables: Variable in environment. :paramtype variables: list[~azure.mgmt.synapse.models.SsisVariable] """ - super(SsisEnvironment, self).__init__(id=id, name=name, description=description, **kwargs) - self.type = 'Environment' # type: str + super().__init__(id=id, name=name, description=description, **kwargs) + self.type = "Environment" # type: str self.folder_id = folder_id self.variables = variables -class SsisEnvironmentReference(msrest.serialization.Model): +class SsisEnvironmentReference(_serialization.Model): """Ssis environment reference. :ivar id: Environment reference id. - :vartype id: long + :vartype id: int :ivar environment_folder_name: Environment folder name. :vartype environment_folder_name: str :ivar environment_name: Environment name. @@ -12311,16 +11764,16 @@ class SsisEnvironmentReference(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'long'}, - 'environment_folder_name': {'key': 'environmentFolderName', 'type': 'str'}, - 'environment_name': {'key': 'environmentName', 'type': 'str'}, - 'reference_type': {'key': 'referenceType', 'type': 'str'}, + "id": {"key": "id", "type": "int"}, + "environment_folder_name": {"key": "environmentFolderName", "type": "str"}, + "environment_name": {"key": "environmentName", "type": "str"}, + "reference_type": {"key": "referenceType", "type": "str"}, } def __init__( self, *, - id: Optional[int] = None, + id: Optional[int] = None, # pylint: disable=redefined-builtin environment_folder_name: Optional[str] = None, environment_name: Optional[str] = None, reference_type: Optional[str] = None, @@ -12328,7 +11781,7 @@ def __init__( ): """ :keyword id: Environment reference id. - :paramtype id: long + :paramtype id: int :keyword environment_folder_name: Environment folder name. :paramtype environment_folder_name: str :keyword environment_name: Environment name. @@ -12336,7 +11789,7 @@ def __init__( :keyword reference_type: Reference type. :paramtype reference_type: str """ - super(SsisEnvironmentReference, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.environment_folder_name = environment_folder_name self.environment_name = environment_name @@ -12348,11 +11801,11 @@ class SsisFolder(SsisObjectMetadata): All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of metadata.Constant filled by server. Possible values include: - "Folder", "Project", "Package", "Environment". + :ivar type: Type of metadata. Required. Known values are: "Folder", "Project", "Package", and + "Environment". :vartype type: str or ~azure.mgmt.synapse.models.SsisObjectMetadataType :ivar id: Metadata id. - :vartype id: long + :vartype id: int :ivar name: Metadata name. :vartype name: str :ivar description: Metadata description. @@ -12360,37 +11813,37 @@ class SsisFolder(SsisObjectMetadata): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'long'}, - 'name': {'key': 'name', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "id": {"key": "id", "type": "int"}, + "name": {"key": "name", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( self, *, - id: Optional[int] = None, + id: Optional[int] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, description: Optional[str] = None, **kwargs ): """ :keyword id: Metadata id. - :paramtype id: long + :paramtype id: int :keyword name: Metadata name. :paramtype name: str :keyword description: Metadata description. :paramtype description: str """ - super(SsisFolder, self).__init__(id=id, name=name, description=description, **kwargs) - self.type = 'Folder' # type: str + super().__init__(id=id, name=name, description=description, **kwargs) + self.type = "Folder" # type: str -class SsisObjectMetadataListResponse(msrest.serialization.Model): +class SsisObjectMetadataListResponse(_serialization.Model): """A list of SSIS object metadata. :ivar value: List of SSIS object metadata. @@ -12400,16 +11853,12 @@ class SsisObjectMetadataListResponse(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SsisObjectMetadata]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SsisObjectMetadata]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["SsisObjectMetadata"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SsisObjectMetadata"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: List of SSIS object metadata. @@ -12417,12 +11866,12 @@ def __init__( :keyword next_link: The link to the next page of results, if any remaining results exist. :paramtype next_link: str """ - super(SsisObjectMetadataListResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SsisObjectMetadataStatusResponse(msrest.serialization.Model): +class SsisObjectMetadataStatusResponse(_serialization.Model): """The status of the operation. :ivar status: The status of the operation. @@ -12436,10 +11885,10 @@ class SsisObjectMetadataStatusResponse(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "str"}, + "error": {"key": "error", "type": "str"}, } def __init__( @@ -12461,7 +11910,7 @@ def __init__( :keyword error: The operation error message. :paramtype error: str """ - super(SsisObjectMetadataStatusResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.name = name self.properties = properties @@ -12473,81 +11922,81 @@ class SsisPackage(SsisObjectMetadata): All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of metadata.Constant filled by server. Possible values include: - "Folder", "Project", "Package", "Environment". + :ivar type: Type of metadata. Required. Known values are: "Folder", "Project", "Package", and + "Environment". :vartype type: str or ~azure.mgmt.synapse.models.SsisObjectMetadataType :ivar id: Metadata id. - :vartype id: long + :vartype id: int :ivar name: Metadata name. :vartype name: str :ivar description: Metadata description. :vartype description: str :ivar folder_id: Folder id which contains package. - :vartype folder_id: long + :vartype folder_id: int :ivar project_version: Project version which contains package. - :vartype project_version: long + :vartype project_version: int :ivar project_id: Project id which contains package. - :vartype project_id: long + :vartype project_id: int :ivar parameters: Parameters in package. :vartype parameters: list[~azure.mgmt.synapse.models.SsisParameter] """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'long'}, - 'name': {'key': 'name', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'folder_id': {'key': 'folderId', 'type': 'long'}, - 'project_version': {'key': 'projectVersion', 'type': 'long'}, - 'project_id': {'key': 'projectId', 'type': 'long'}, - 'parameters': {'key': 'parameters', 'type': '[SsisParameter]'}, + "type": {"key": "type", "type": "str"}, + "id": {"key": "id", "type": "int"}, + "name": {"key": "name", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "folder_id": {"key": "folderId", "type": "int"}, + "project_version": {"key": "projectVersion", "type": "int"}, + "project_id": {"key": "projectId", "type": "int"}, + "parameters": {"key": "parameters", "type": "[SsisParameter]"}, } def __init__( self, *, - id: Optional[int] = None, + id: Optional[int] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, description: Optional[str] = None, folder_id: Optional[int] = None, project_version: Optional[int] = None, project_id: Optional[int] = None, - parameters: Optional[List["SsisParameter"]] = None, + parameters: Optional[List["_models.SsisParameter"]] = None, **kwargs ): """ :keyword id: Metadata id. - :paramtype id: long + :paramtype id: int :keyword name: Metadata name. :paramtype name: str :keyword description: Metadata description. :paramtype description: str :keyword folder_id: Folder id which contains package. - :paramtype folder_id: long + :paramtype folder_id: int :keyword project_version: Project version which contains package. - :paramtype project_version: long + :paramtype project_version: int :keyword project_id: Project id which contains package. - :paramtype project_id: long + :paramtype project_id: int :keyword parameters: Parameters in package. :paramtype parameters: list[~azure.mgmt.synapse.models.SsisParameter] """ - super(SsisPackage, self).__init__(id=id, name=name, description=description, **kwargs) - self.type = 'Package' # type: str + super().__init__(id=id, name=name, description=description, **kwargs) + self.type = "Package" # type: str self.folder_id = folder_id self.project_version = project_version self.project_id = project_id self.parameters = parameters -class SsisParameter(msrest.serialization.Model): +class SsisParameter(_serialization.Model): # pylint: disable=too-many-instance-attributes """Ssis parameter. :ivar id: Parameter id. - :vartype id: long + :vartype id: int :ivar name: Parameter name. :vartype name: str :ivar description: Parameter description. @@ -12573,24 +12022,24 @@ class SsisParameter(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'long'}, - 'name': {'key': 'name', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'data_type': {'key': 'dataType', 'type': 'str'}, - 'required': {'key': 'required', 'type': 'bool'}, - 'sensitive': {'key': 'sensitive', 'type': 'bool'}, - 'design_default_value': {'key': 'designDefaultValue', 'type': 'str'}, - 'default_value': {'key': 'defaultValue', 'type': 'str'}, - 'sensitive_default_value': {'key': 'sensitiveDefaultValue', 'type': 'str'}, - 'value_type': {'key': 'valueType', 'type': 'str'}, - 'value_set': {'key': 'valueSet', 'type': 'bool'}, - 'variable': {'key': 'variable', 'type': 'str'}, + "id": {"key": "id", "type": "int"}, + "name": {"key": "name", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "data_type": {"key": "dataType", "type": "str"}, + "required": {"key": "required", "type": "bool"}, + "sensitive": {"key": "sensitive", "type": "bool"}, + "design_default_value": {"key": "designDefaultValue", "type": "str"}, + "default_value": {"key": "defaultValue", "type": "str"}, + "sensitive_default_value": {"key": "sensitiveDefaultValue", "type": "str"}, + "value_type": {"key": "valueType", "type": "str"}, + "value_set": {"key": "valueSet", "type": "bool"}, + "variable": {"key": "variable", "type": "str"}, } def __init__( self, *, - id: Optional[int] = None, + id: Optional[int] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, description: Optional[str] = None, data_type: Optional[str] = None, @@ -12606,7 +12055,7 @@ def __init__( ): """ :keyword id: Parameter id. - :paramtype id: long + :paramtype id: int :keyword name: Parameter name. :paramtype name: str :keyword description: Parameter description. @@ -12630,7 +12079,7 @@ def __init__( :keyword variable: Parameter reference variable. :paramtype variable: str """ - super(SsisParameter, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.name = name self.description = description @@ -12650,19 +12099,19 @@ class SsisProject(SsisObjectMetadata): All required parameters must be populated in order to send to Azure. - :ivar type: Required. Type of metadata.Constant filled by server. Possible values include: - "Folder", "Project", "Package", "Environment". + :ivar type: Type of metadata. Required. Known values are: "Folder", "Project", "Package", and + "Environment". :vartype type: str or ~azure.mgmt.synapse.models.SsisObjectMetadataType :ivar id: Metadata id. - :vartype id: long + :vartype id: int :ivar name: Metadata name. :vartype name: str :ivar description: Metadata description. :vartype description: str :ivar folder_id: Folder id which contains project. - :vartype folder_id: long + :vartype folder_id: int :ivar version: Project version. - :vartype version: long + :vartype version: int :ivar environment_refs: Environment reference in project. :vartype environment_refs: list[~azure.mgmt.synapse.models.SsisEnvironmentReference] :ivar parameters: Parameters in project. @@ -12670,61 +12119,61 @@ class SsisProject(SsisObjectMetadata): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'long'}, - 'name': {'key': 'name', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'folder_id': {'key': 'folderId', 'type': 'long'}, - 'version': {'key': 'version', 'type': 'long'}, - 'environment_refs': {'key': 'environmentRefs', 'type': '[SsisEnvironmentReference]'}, - 'parameters': {'key': 'parameters', 'type': '[SsisParameter]'}, + "type": {"key": "type", "type": "str"}, + "id": {"key": "id", "type": "int"}, + "name": {"key": "name", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "folder_id": {"key": "folderId", "type": "int"}, + "version": {"key": "version", "type": "int"}, + "environment_refs": {"key": "environmentRefs", "type": "[SsisEnvironmentReference]"}, + "parameters": {"key": "parameters", "type": "[SsisParameter]"}, } def __init__( self, *, - id: Optional[int] = None, + id: Optional[int] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, description: Optional[str] = None, folder_id: Optional[int] = None, version: Optional[int] = None, - environment_refs: Optional[List["SsisEnvironmentReference"]] = None, - parameters: Optional[List["SsisParameter"]] = None, + environment_refs: Optional[List["_models.SsisEnvironmentReference"]] = None, + parameters: Optional[List["_models.SsisParameter"]] = None, **kwargs ): """ :keyword id: Metadata id. - :paramtype id: long + :paramtype id: int :keyword name: Metadata name. :paramtype name: str :keyword description: Metadata description. :paramtype description: str :keyword folder_id: Folder id which contains project. - :paramtype folder_id: long + :paramtype folder_id: int :keyword version: Project version. - :paramtype version: long + :paramtype version: int :keyword environment_refs: Environment reference in project. :paramtype environment_refs: list[~azure.mgmt.synapse.models.SsisEnvironmentReference] :keyword parameters: Parameters in project. :paramtype parameters: list[~azure.mgmt.synapse.models.SsisParameter] """ - super(SsisProject, self).__init__(id=id, name=name, description=description, **kwargs) - self.type = 'Project' # type: str + super().__init__(id=id, name=name, description=description, **kwargs) + self.type = "Project" # type: str self.folder_id = folder_id self.version = version self.environment_refs = environment_refs self.parameters = parameters -class SsisVariable(msrest.serialization.Model): +class SsisVariable(_serialization.Model): """Ssis variable. :ivar id: Variable id. - :vartype id: long + :vartype id: int :ivar name: Variable name. :vartype name: str :ivar description: Variable description. @@ -12740,19 +12189,19 @@ class SsisVariable(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'long'}, - 'name': {'key': 'name', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'data_type': {'key': 'dataType', 'type': 'str'}, - 'sensitive': {'key': 'sensitive', 'type': 'bool'}, - 'value': {'key': 'value', 'type': 'str'}, - 'sensitive_value': {'key': 'sensitiveValue', 'type': 'str'}, + "id": {"key": "id", "type": "int"}, + "name": {"key": "name", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "data_type": {"key": "dataType", "type": "str"}, + "sensitive": {"key": "sensitive", "type": "bool"}, + "value": {"key": "value", "type": "str"}, + "sensitive_value": {"key": "sensitiveValue", "type": "str"}, } def __init__( self, *, - id: Optional[int] = None, + id: Optional[int] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, description: Optional[str] = None, data_type: Optional[str] = None, @@ -12763,7 +12212,7 @@ def __init__( ): """ :keyword id: Variable id. - :paramtype id: long + :paramtype id: int :keyword name: Variable name. :paramtype name: str :keyword description: Variable description. @@ -12777,7 +12226,7 @@ def __init__( :keyword sensitive_value: Variable sensitive value. :paramtype sensitive_value: str """ - super(SsisVariable, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.name = name self.description = description @@ -12787,62 +12236,62 @@ def __init__( self.sensitive_value = sensitive_value -class SystemData(msrest.serialization.Model): +class SystemData(_serialization.Model): """Metadata pertaining to creation and last modification of the resource. :ivar created_by: The identity that created the resource. :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Possible values include: - "User", "Application", "ManagedIdentity", "Key". + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~azure.mgmt.synapse.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.synapse.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, } def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.synapse.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.synapse.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(SystemData, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -12851,7 +12300,7 @@ def __init__( self.last_modified_at = last_modified_at -class TableLevelSharingProperties(msrest.serialization.Model): +class TableLevelSharingProperties(_serialization.Model): """Tables that will be included and excluded in the follower database. :ivar tables_to_include: List of tables to include in the follower database. @@ -12871,12 +12320,12 @@ class TableLevelSharingProperties(msrest.serialization.Model): """ _attribute_map = { - 'tables_to_include': {'key': 'tablesToInclude', 'type': '[str]'}, - 'tables_to_exclude': {'key': 'tablesToExclude', 'type': '[str]'}, - 'external_tables_to_include': {'key': 'externalTablesToInclude', 'type': '[str]'}, - 'external_tables_to_exclude': {'key': 'externalTablesToExclude', 'type': '[str]'}, - 'materialized_views_to_include': {'key': 'materializedViewsToInclude', 'type': '[str]'}, - 'materialized_views_to_exclude': {'key': 'materializedViewsToExclude', 'type': '[str]'}, + "tables_to_include": {"key": "tablesToInclude", "type": "[str]"}, + "tables_to_exclude": {"key": "tablesToExclude", "type": "[str]"}, + "external_tables_to_include": {"key": "externalTablesToInclude", "type": "[str]"}, + "external_tables_to_exclude": {"key": "externalTablesToExclude", "type": "[str]"}, + "materialized_views_to_include": {"key": "materializedViewsToInclude", "type": "[str]"}, + "materialized_views_to_exclude": {"key": "materializedViewsToExclude", "type": "[str]"}, } def __init__( @@ -12908,7 +12357,7 @@ def __init__( database. :paramtype materialized_views_to_exclude: list[str] """ - super(TableLevelSharingProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.tables_to_include = tables_to_include self.tables_to_exclude = tables_to_exclude self.external_tables_to_include = external_tables_to_include @@ -12917,16 +12366,16 @@ def __init__( self.materialized_views_to_exclude = materialized_views_to_exclude -class TopQueries(msrest.serialization.Model): +class TopQueries(_serialization.Model): """A database query. Variables are only populated by the server, and will be ignored when sending a request. - :ivar aggregation_function: The function that is used to aggregate each query's metrics. - Possible values include: "min", "max", "avg", "sum". + :ivar aggregation_function: The function that is used to aggregate each query's metrics. Known + values are: "min", "max", "avg", and "sum". :vartype aggregation_function: str or ~azure.mgmt.synapse.models.QueryAggregationFunction :ivar execution_type: The execution type that is used to filter the query instances that are - returned. Possible values include: "any", "regular", "irregular", "aborted", "exception". + returned. Known values are: "any", "regular", "irregular", "aborted", and "exception". :vartype execution_type: str or ~azure.mgmt.synapse.models.QueryExecutionType :ivar interval_type: The duration of the interval (ISO8601 duration format). :vartype interval_type: str @@ -12936,42 +12385,38 @@ class TopQueries(msrest.serialization.Model): :vartype observation_start_time: ~datetime.datetime :ivar observation_end_time: The end time for queries that are returned (ISO8601 format). :vartype observation_end_time: ~datetime.datetime - :ivar observed_metric: The type of metric to use for ordering the top metrics. Possible values - include: "cpu", "io", "logio", "duration", "executionCount". + :ivar observed_metric: The type of metric to use for ordering the top metrics. Known values + are: "cpu", "io", "logio", "duration", and "executionCount". :vartype observed_metric: str or ~azure.mgmt.synapse.models.QueryObservedMetricType :ivar queries: The list of queries. :vartype queries: list[~azure.mgmt.synapse.models.QueryStatistic] """ _validation = { - 'aggregation_function': {'readonly': True}, - 'execution_type': {'readonly': True}, - 'interval_type': {'readonly': True}, - 'number_of_top_queries': {'readonly': True}, - 'observation_start_time': {'readonly': True}, - 'observation_end_time': {'readonly': True}, - 'observed_metric': {'readonly': True}, - 'queries': {'readonly': True}, + "aggregation_function": {"readonly": True}, + "execution_type": {"readonly": True}, + "interval_type": {"readonly": True}, + "number_of_top_queries": {"readonly": True}, + "observation_start_time": {"readonly": True}, + "observation_end_time": {"readonly": True}, + "observed_metric": {"readonly": True}, + "queries": {"readonly": True}, } _attribute_map = { - 'aggregation_function': {'key': 'aggregationFunction', 'type': 'str'}, - 'execution_type': {'key': 'executionType', 'type': 'str'}, - 'interval_type': {'key': 'intervalType', 'type': 'str'}, - 'number_of_top_queries': {'key': 'numberOfTopQueries', 'type': 'int'}, - 'observation_start_time': {'key': 'observationStartTime', 'type': 'iso-8601'}, - 'observation_end_time': {'key': 'observationEndTime', 'type': 'iso-8601'}, - 'observed_metric': {'key': 'observedMetric', 'type': 'str'}, - 'queries': {'key': 'queries', 'type': '[QueryStatistic]'}, + "aggregation_function": {"key": "aggregationFunction", "type": "str"}, + "execution_type": {"key": "executionType", "type": "str"}, + "interval_type": {"key": "intervalType", "type": "str"}, + "number_of_top_queries": {"key": "numberOfTopQueries", "type": "int"}, + "observation_start_time": {"key": "observationStartTime", "type": "iso-8601"}, + "observation_end_time": {"key": "observationEndTime", "type": "iso-8601"}, + "observed_metric": {"key": "observedMetric", "type": "str"}, + "queries": {"key": "queries", "type": "[QueryStatistic]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(TopQueries, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.aggregation_function = None self.execution_type = None self.interval_type = None @@ -12982,34 +12427,29 @@ def __init__( self.queries = None -class TopQueriesListResult(msrest.serialization.Model): +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. - :ivar value: Required. The list of top queries. + :ivar value: The list of top queries. Required. :vartype value: list[~azure.mgmt.synapse.models.TopQueries] """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TopQueries]'}, + "value": {"key": "value", "type": "[TopQueries]"}, } - def __init__( - self, - *, - value: List["TopQueries"], - **kwargs - ): + def __init__(self, *, value: List["_models.TopQueries"], **kwargs): """ - :keyword value: Required. The list of top queries. + :keyword value: The list of top queries. Required. :paramtype value: list[~azure.mgmt.synapse.models.TopQueries] """ - super(TopQueriesListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value @@ -13028,43 +12468,38 @@ class TransparentDataEncryption(ProxyResource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar status: The status of the database transparent data encryption. Possible values include: - "Enabled", "Disabled". + :ivar status: The status of the database transparent data encryption. Known values are: + "Enabled" and "Disabled". :vartype status: str or ~azure.mgmt.synapse.models.TransparentDataEncryptionStatus """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, } - def __init__( - self, - *, - status: Optional[Union[str, "TransparentDataEncryptionStatus"]] = None, - **kwargs - ): + def __init__(self, *, status: Optional[Union[str, "_models.TransparentDataEncryptionStatus"]] = None, **kwargs): """ - :keyword status: The status of the database transparent data encryption. Possible values - include: "Enabled", "Disabled". + :keyword status: The status of the database transparent data encryption. Known values are: + "Enabled" and "Disabled". :paramtype status: str or ~azure.mgmt.synapse.models.TransparentDataEncryptionStatus """ - super(TransparentDataEncryption, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = None self.status = status -class TransparentDataEncryptionListResult(msrest.serialization.Model): +class TransparentDataEncryptionListResult(_serialization.Model): """A list of transparent data encryption configurations. Variables are only populated by the server, and will be ignored when sending a request. @@ -13076,27 +12511,23 @@ class TransparentDataEncryptionListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TransparentDataEncryption]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[TransparentDataEncryption]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(TransparentDataEncryptionListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class UpdateIntegrationRuntimeNodeRequest(msrest.serialization.Model): +class UpdateIntegrationRuntimeNodeRequest(_serialization.Model): """Update integration runtime node request. :ivar concurrent_jobs_limit: The number of concurrent jobs permitted to run on the integration @@ -13105,34 +12536,28 @@ class UpdateIntegrationRuntimeNodeRequest(msrest.serialization.Model): """ _validation = { - 'concurrent_jobs_limit': {'minimum': 1}, + "concurrent_jobs_limit": {"minimum": 1}, } _attribute_map = { - 'concurrent_jobs_limit': {'key': 'concurrentJobsLimit', 'type': 'int'}, + "concurrent_jobs_limit": {"key": "concurrentJobsLimit", "type": "int"}, } - def __init__( - self, - *, - concurrent_jobs_limit: Optional[int] = None, - **kwargs - ): + def __init__(self, *, concurrent_jobs_limit: Optional[int] = None, **kwargs): """ :keyword concurrent_jobs_limit: The number of concurrent jobs permitted to run on the integration runtime node. Values between 1 and maxConcurrentJobs(inclusive) are allowed. :paramtype concurrent_jobs_limit: int """ - super(UpdateIntegrationRuntimeNodeRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.concurrent_jobs_limit = concurrent_jobs_limit -class UpdateIntegrationRuntimeRequest(msrest.serialization.Model): +class UpdateIntegrationRuntimeRequest(_serialization.Model): """Update integration runtime request. :ivar auto_update: Enables or disables the auto-update feature of the self-hosted integration - runtime. See https://go.microsoft.com/fwlink/?linkid=854189. Possible values include: "On", - "Off". + runtime. See https://go.microsoft.com/fwlink/?linkid=854189. Known values are: "On" and "Off". :vartype auto_update: str or ~azure.mgmt.synapse.models.IntegrationRuntimeAutoUpdate :ivar update_delay_offset: The time offset (in hours) in the day, e.g., PT03H is 3 hours. The integration runtime auto update will happen on that time. @@ -13140,32 +12565,32 @@ class UpdateIntegrationRuntimeRequest(msrest.serialization.Model): """ _attribute_map = { - 'auto_update': {'key': 'autoUpdate', 'type': 'str'}, - 'update_delay_offset': {'key': 'updateDelayOffset', 'type': 'str'}, + "auto_update": {"key": "autoUpdate", "type": "str"}, + "update_delay_offset": {"key": "updateDelayOffset", "type": "str"}, } def __init__( self, *, - auto_update: Optional[Union[str, "IntegrationRuntimeAutoUpdate"]] = None, + auto_update: Optional[Union[str, "_models.IntegrationRuntimeAutoUpdate"]] = None, update_delay_offset: Optional[str] = None, **kwargs ): """ :keyword auto_update: Enables or disables the auto-update feature of the self-hosted - integration runtime. See https://go.microsoft.com/fwlink/?linkid=854189. Possible values - include: "On", "Off". + integration runtime. See https://go.microsoft.com/fwlink/?linkid=854189. Known values are: "On" + and "Off". :paramtype auto_update: str or ~azure.mgmt.synapse.models.IntegrationRuntimeAutoUpdate :keyword update_delay_offset: The time offset (in hours) in the day, e.g., PT03H is 3 hours. The integration runtime auto update will happen on that time. :paramtype update_delay_offset: str """ - super(UpdateIntegrationRuntimeRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.auto_update = auto_update self.update_delay_offset = update_delay_offset -class UserAssignedManagedIdentity(msrest.serialization.Model): +class UserAssignedManagedIdentity(_serialization.Model): """User Assigned Managed Identity. Variables are only populated by the server, and will be ignored when sending a request. @@ -13177,27 +12602,23 @@ class UserAssignedManagedIdentity(msrest.serialization.Model): """ _validation = { - 'client_id': {'readonly': True}, - 'principal_id': {'readonly': True}, + "client_id": {"readonly": True}, + "principal_id": {"readonly": True}, } _attribute_map = { - 'client_id': {'key': 'clientId', 'type': 'str'}, - 'principal_id': {'key': 'principalId', 'type': 'str'}, + "client_id": {"key": "clientId", "type": "str"}, + "principal_id": {"key": "principalId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UserAssignedManagedIdentity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.client_id = None self.principal_id = None -class VirtualNetworkProfile(msrest.serialization.Model): +class VirtualNetworkProfile(_serialization.Model): """Virtual Network Profile. :ivar compute_subnet_id: Subnet ID used for computes in workspace. @@ -13205,24 +12626,19 @@ class VirtualNetworkProfile(msrest.serialization.Model): """ _attribute_map = { - 'compute_subnet_id': {'key': 'computeSubnetId', 'type': 'str'}, + "compute_subnet_id": {"key": "computeSubnetId", "type": "str"}, } - def __init__( - self, - *, - compute_subnet_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, compute_subnet_id: Optional[str] = None, **kwargs): """ :keyword compute_subnet_id: Subnet ID used for computes in workspace. :paramtype compute_subnet_id: str """ - super(VirtualNetworkProfile, self).__init__(**kwargs) + super().__init__(**kwargs) self.compute_subnet_id = compute_subnet_id -class VulnerabilityAssessmentRecurringScansProperties(msrest.serialization.Model): +class VulnerabilityAssessmentRecurringScansProperties(_serialization.Model): """Properties of a Vulnerability Assessment recurring scans. :ivar is_enabled: Recurring scans state. @@ -13235,16 +12651,16 @@ class VulnerabilityAssessmentRecurringScansProperties(msrest.serialization.Model """ _attribute_map = { - 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, - 'email_subscription_admins': {'key': 'emailSubscriptionAdmins', 'type': 'bool'}, - 'emails': {'key': 'emails', 'type': '[str]'}, + "is_enabled": {"key": "isEnabled", "type": "bool"}, + "email_subscription_admins": {"key": "emailSubscriptionAdmins", "type": "bool"}, + "emails": {"key": "emails", "type": "[str]"}, } def __init__( self, *, is_enabled: Optional[bool] = None, - email_subscription_admins: Optional[bool] = True, + email_subscription_admins: bool = True, emails: Optional[List[str]] = None, **kwargs ): @@ -13257,13 +12673,13 @@ def __init__( :keyword emails: Specifies an array of e-mail addresses to which the scan notification is sent. :paramtype emails: list[str] """ - super(VulnerabilityAssessmentRecurringScansProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.is_enabled = is_enabled self.email_subscription_admins = email_subscription_admins self.emails = emails -class VulnerabilityAssessmentScanError(msrest.serialization.Model): +class VulnerabilityAssessmentScanError(_serialization.Model): """Properties of a vulnerability assessment scan error. Variables are only populated by the server, and will be ignored when sending a request. @@ -13275,27 +12691,23 @@ class VulnerabilityAssessmentScanError(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(VulnerabilityAssessmentScanError, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None -class VulnerabilityAssessmentScanRecord(ProxyResource): +class VulnerabilityAssessmentScanRecord(ProxyResource): # pylint: disable=too-many-instance-attributes """A vulnerability assessment scan record. Variables are only populated by the server, and will be ignored when sending a request. @@ -13310,9 +12722,9 @@ class VulnerabilityAssessmentScanRecord(ProxyResource): :vartype type: str :ivar scan_id: The scan ID. :vartype scan_id: str - :ivar trigger_type: The scan trigger type. Possible values include: "OnDemand", "Recurring". + :ivar trigger_type: The scan trigger type. Known values are: "OnDemand" and "Recurring". :vartype trigger_type: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentScanTriggerType - :ivar state: The scan status. Possible values include: "Passed", "Failed", "FailedToRun", + :ivar state: The scan status. Known values are: "Passed", "Failed", "FailedToRun", and "InProgress". :vartype state: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentScanState :ivar start_time: The scan start time (UTC). @@ -13328,40 +12740,36 @@ class VulnerabilityAssessmentScanRecord(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'scan_id': {'readonly': True}, - 'trigger_type': {'readonly': True}, - 'state': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'errors': {'readonly': True}, - 'storage_container_path': {'readonly': True}, - 'number_of_failed_security_checks': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "scan_id": {"readonly": True}, + "trigger_type": {"readonly": True}, + "state": {"readonly": True}, + "start_time": {"readonly": True}, + "end_time": {"readonly": True}, + "errors": {"readonly": True}, + "storage_container_path": {"readonly": True}, + "number_of_failed_security_checks": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'scan_id': {'key': 'properties.scanId', 'type': 'str'}, - 'trigger_type': {'key': 'properties.triggerType', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'properties.endTime', 'type': 'iso-8601'}, - 'errors': {'key': 'properties.errors', 'type': '[VulnerabilityAssessmentScanError]'}, - 'storage_container_path': {'key': 'properties.storageContainerPath', 'type': 'str'}, - 'number_of_failed_security_checks': {'key': 'properties.numberOfFailedSecurityChecks', 'type': 'int'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "scan_id": {"key": "properties.scanId", "type": "str"}, + "trigger_type": {"key": "properties.triggerType", "type": "str"}, + "state": {"key": "properties.state", "type": "str"}, + "start_time": {"key": "properties.startTime", "type": "iso-8601"}, + "end_time": {"key": "properties.endTime", "type": "iso-8601"}, + "errors": {"key": "properties.errors", "type": "[VulnerabilityAssessmentScanError]"}, + "storage_container_path": {"key": "properties.storageContainerPath", "type": "str"}, + "number_of_failed_security_checks": {"key": "properties.numberOfFailedSecurityChecks", "type": "int"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(VulnerabilityAssessmentScanRecord, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.scan_id = None self.trigger_type = None self.state = None @@ -13372,7 +12780,7 @@ def __init__( self.number_of_failed_security_checks = None -class VulnerabilityAssessmentScanRecordListResult(msrest.serialization.Model): +class VulnerabilityAssessmentScanRecordListResult(_serialization.Model): """A list of vulnerability assessment scan records. Variables are only populated by the server, and will be ignored when sending a request. @@ -13384,22 +12792,18 @@ class VulnerabilityAssessmentScanRecordListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[VulnerabilityAssessmentScanRecord]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[VulnerabilityAssessmentScanRecord]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(VulnerabilityAssessmentScanRecordListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None @@ -13432,21 +12836,21 @@ class WorkloadClassifier(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'member_name': {'key': 'properties.memberName', 'type': 'str'}, - 'label': {'key': 'properties.label', 'type': 'str'}, - 'context': {'key': 'properties.context', 'type': 'str'}, - 'start_time': {'key': 'properties.startTime', 'type': 'str'}, - 'end_time': {'key': 'properties.endTime', 'type': 'str'}, - 'importance': {'key': 'properties.importance', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "member_name": {"key": "properties.memberName", "type": "str"}, + "label": {"key": "properties.label", "type": "str"}, + "context": {"key": "properties.context", "type": "str"}, + "start_time": {"key": "properties.startTime", "type": "str"}, + "end_time": {"key": "properties.endTime", "type": "str"}, + "importance": {"key": "properties.importance", "type": "str"}, } def __init__( @@ -13474,7 +12878,7 @@ def __init__( :keyword importance: The workload classifier importance. :paramtype importance: str """ - super(WorkloadClassifier, self).__init__(**kwargs) + super().__init__(**kwargs) self.member_name = member_name self.label = label self.context = context @@ -13483,7 +12887,7 @@ def __init__( self.importance = importance -class WorkloadClassifierListResult(msrest.serialization.Model): +class WorkloadClassifierListResult(_serialization.Model): """A list of workload classifiers for a workload group. Variables are only populated by the server, and will be ignored when sending a request. @@ -13495,22 +12899,18 @@ class WorkloadClassifierListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[WorkloadClassifier]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[WorkloadClassifier]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(WorkloadClassifierListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None @@ -13543,21 +12943,21 @@ class WorkloadGroup(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'min_resource_percent': {'key': 'properties.minResourcePercent', 'type': 'int'}, - 'max_resource_percent': {'key': 'properties.maxResourcePercent', 'type': 'int'}, - 'min_resource_percent_per_request': {'key': 'properties.minResourcePercentPerRequest', 'type': 'float'}, - 'max_resource_percent_per_request': {'key': 'properties.maxResourcePercentPerRequest', 'type': 'float'}, - 'importance': {'key': 'properties.importance', 'type': 'str'}, - 'query_execution_timeout': {'key': 'properties.queryExecutionTimeout', 'type': 'int'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "min_resource_percent": {"key": "properties.minResourcePercent", "type": "int"}, + "max_resource_percent": {"key": "properties.maxResourcePercent", "type": "int"}, + "min_resource_percent_per_request": {"key": "properties.minResourcePercentPerRequest", "type": "float"}, + "max_resource_percent_per_request": {"key": "properties.maxResourcePercentPerRequest", "type": "float"}, + "importance": {"key": "properties.importance", "type": "str"}, + "query_execution_timeout": {"key": "properties.queryExecutionTimeout", "type": "int"}, } def __init__( @@ -13585,7 +12985,7 @@ def __init__( :keyword query_execution_timeout: The workload group query execution timeout. :paramtype query_execution_timeout: int """ - super(WorkloadGroup, self).__init__(**kwargs) + super().__init__(**kwargs) self.min_resource_percent = min_resource_percent self.max_resource_percent = max_resource_percent self.min_resource_percent_per_request = min_resource_percent_per_request @@ -13594,7 +12994,7 @@ def __init__( self.query_execution_timeout = query_execution_timeout -class WorkloadGroupListResult(msrest.serialization.Model): +class WorkloadGroupListResult(_serialization.Model): """A list of workload groups. Variables are only populated by the server, and will be ignored when sending a request. @@ -13606,27 +13006,23 @@ class WorkloadGroupListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[WorkloadGroup]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[WorkloadGroup]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(WorkloadGroupListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class Workspace(TrackedResource): +class Workspace(TrackedResource): # pylint: disable=too-many-instance-attributes """A workspace. Variables are only populated by the server, and will be ignored when sending a request. @@ -13641,9 +13037,9 @@ class Workspace(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar identity: Identity of the workspace. :vartype identity: ~azure.mgmt.synapse.models.ManagedIdentity @@ -13675,7 +13071,7 @@ class Workspace(TrackedResource): :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, any] + :vartype extra_properties: dict[str, JSON] :ivar managed_virtual_network_settings: Managed Virtual Network Settings. :vartype managed_virtual_network_settings: ~azure.mgmt.synapse.models.ManagedVirtualNetworkSettings @@ -13686,14 +13082,14 @@ class Workspace(TrackedResource): :vartype purview_configuration: ~azure.mgmt.synapse.models.PurviewConfiguration :ivar adla_resource_id: The ADLA resource ID. :vartype adla_resource_id: str - :ivar public_network_access: Enable or Disable public network access to workspace. Possible - values include: "Enabled", "Disabled". + :ivar public_network_access: Enable or Disable public network access to workspace. Known values + are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.synapse.models.WorkspacePublicNetworkAccess :ivar csp_workspace_admin_properties: Initial workspace AAD admin properties for a CSP subscription. :vartype csp_workspace_admin_properties: ~azure.mgmt.synapse.models.CspWorkspaceAdminProperties :ivar settings: Workspace settings. - :vartype settings: dict[str, any] + :vartype settings: dict[str, JSON] :ivar azure_ad_only_authentication: Enable or Disable AzureADOnlyAuthentication on All Workspace subresource. :vartype azure_ad_only_authentication: bool @@ -13702,75 +13098,90 @@ class Workspace(TrackedResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'workspace_uid': {'readonly': True}, - 'extra_properties': {'readonly': True}, - 'adla_resource_id': {'readonly': True}, - 'settings': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentity'}, - 'default_data_lake_storage': {'key': 'properties.defaultDataLakeStorage', 'type': 'DataLakeStorageAccountDetails'}, - 'sql_administrator_login_password': {'key': 'properties.sqlAdministratorLoginPassword', 'type': 'str'}, - 'managed_resource_group_name': {'key': 'properties.managedResourceGroupName', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'sql_administrator_login': {'key': 'properties.sqlAdministratorLogin', 'type': 'str'}, - 'virtual_network_profile': {'key': 'properties.virtualNetworkProfile', 'type': 'VirtualNetworkProfile'}, - 'connectivity_endpoints': {'key': 'properties.connectivityEndpoints', 'type': '{str}'}, - 'managed_virtual_network': {'key': 'properties.managedVirtualNetwork', 'type': 'str'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'encryption': {'key': 'properties.encryption', 'type': 'EncryptionDetails'}, - 'workspace_uid': {'key': 'properties.workspaceUID', 'type': 'str'}, - 'extra_properties': {'key': 'properties.extraProperties', 'type': '{object}'}, - 'managed_virtual_network_settings': {'key': 'properties.managedVirtualNetworkSettings', 'type': 'ManagedVirtualNetworkSettings'}, - 'workspace_repository_configuration': {'key': 'properties.workspaceRepositoryConfiguration', 'type': 'WorkspaceRepositoryConfiguration'}, - 'purview_configuration': {'key': 'properties.purviewConfiguration', 'type': 'PurviewConfiguration'}, - 'adla_resource_id': {'key': 'properties.adlaResourceId', 'type': 'str'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'csp_workspace_admin_properties': {'key': 'properties.cspWorkspaceAdminProperties', 'type': 'CspWorkspaceAdminProperties'}, - 'settings': {'key': 'properties.settings', 'type': '{object}'}, - 'azure_ad_only_authentication': {'key': 'properties.azureADOnlyAuthentication', 'type': 'bool'}, - 'trusted_service_bypass_enabled': {'key': 'properties.trustedServiceBypassEnabled', 'type': 'bool'}, - } - - def __init__( + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, + "workspace_uid": {"readonly": True}, + "extra_properties": {"readonly": True}, + "adla_resource_id": {"readonly": True}, + "settings": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "default_data_lake_storage": { + "key": "properties.defaultDataLakeStorage", + "type": "DataLakeStorageAccountDetails", + }, + "sql_administrator_login_password": {"key": "properties.sqlAdministratorLoginPassword", "type": "str"}, + "managed_resource_group_name": {"key": "properties.managedResourceGroupName", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "sql_administrator_login": {"key": "properties.sqlAdministratorLogin", "type": "str"}, + "virtual_network_profile": {"key": "properties.virtualNetworkProfile", "type": "VirtualNetworkProfile"}, + "connectivity_endpoints": {"key": "properties.connectivityEndpoints", "type": "{str}"}, + "managed_virtual_network": {"key": "properties.managedVirtualNetwork", "type": "str"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + "encryption": {"key": "properties.encryption", "type": "EncryptionDetails"}, + "workspace_uid": {"key": "properties.workspaceUID", "type": "str"}, + "extra_properties": {"key": "properties.extraProperties", "type": "{object}"}, + "managed_virtual_network_settings": { + "key": "properties.managedVirtualNetworkSettings", + "type": "ManagedVirtualNetworkSettings", + }, + "workspace_repository_configuration": { + "key": "properties.workspaceRepositoryConfiguration", + "type": "WorkspaceRepositoryConfiguration", + }, + "purview_configuration": {"key": "properties.purviewConfiguration", "type": "PurviewConfiguration"}, + "adla_resource_id": {"key": "properties.adlaResourceId", "type": "str"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "csp_workspace_admin_properties": { + "key": "properties.cspWorkspaceAdminProperties", + "type": "CspWorkspaceAdminProperties", + }, + "settings": {"key": "properties.settings", "type": "{object}"}, + "azure_ad_only_authentication": {"key": "properties.azureADOnlyAuthentication", "type": "bool"}, + "trusted_service_bypass_enabled": {"key": "properties.trustedServiceBypassEnabled", "type": "bool"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["ManagedIdentity"] = None, - default_data_lake_storage: Optional["DataLakeStorageAccountDetails"] = None, + identity: Optional["_models.ManagedIdentity"] = None, + default_data_lake_storage: Optional["_models.DataLakeStorageAccountDetails"] = None, sql_administrator_login_password: Optional[str] = None, managed_resource_group_name: Optional[str] = None, sql_administrator_login: Optional[str] = None, - virtual_network_profile: Optional["VirtualNetworkProfile"] = 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["PrivateEndpointConnection"]] = None, - encryption: Optional["EncryptionDetails"] = None, - managed_virtual_network_settings: Optional["ManagedVirtualNetworkSettings"] = None, - workspace_repository_configuration: Optional["WorkspaceRepositoryConfiguration"] = None, - purview_configuration: Optional["PurviewConfiguration"] = None, - public_network_access: Optional[Union[str, "WorkspacePublicNetworkAccess"]] = None, - csp_workspace_admin_properties: Optional["CspWorkspaceAdminProperties"] = None, + private_endpoint_connections: Optional[List["_models.PrivateEndpointConnection"]] = None, + encryption: Optional["_models.EncryptionDetails"] = None, + managed_virtual_network_settings: Optional["_models.ManagedVirtualNetworkSettings"] = None, + workspace_repository_configuration: Optional["_models.WorkspaceRepositoryConfiguration"] = None, + purview_configuration: Optional["_models.PurviewConfiguration"] = None, + public_network_access: Optional[Union[str, "_models.WorkspacePublicNetworkAccess"]] = None, + csp_workspace_admin_properties: Optional["_models.CspWorkspaceAdminProperties"] = None, azure_ad_only_authentication: Optional[bool] = None, - trusted_service_bypass_enabled: Optional[bool] = False, + trusted_service_bypass_enabled: bool = False, **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str :keyword identity: Identity of the workspace. :paramtype identity: ~azure.mgmt.synapse.models.ManagedIdentity @@ -13805,8 +13216,8 @@ def __init__( ~azure.mgmt.synapse.models.WorkspaceRepositoryConfiguration :keyword purview_configuration: Purview Configuration. :paramtype purview_configuration: ~azure.mgmt.synapse.models.PurviewConfiguration - :keyword public_network_access: Enable or Disable public network access to workspace. Possible - values include: "Enabled", "Disabled". + :keyword public_network_access: Enable or Disable public network access to workspace. Known + values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.synapse.models.WorkspacePublicNetworkAccess :keyword csp_workspace_admin_properties: Initial workspace AAD admin properties for a CSP @@ -13819,7 +13230,7 @@ def __init__( :keyword trusted_service_bypass_enabled: Is trustedServiceBypassEnabled for the workspace. :paramtype trusted_service_bypass_enabled: bool """ - super(Workspace, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.identity = identity self.default_data_lake_storage = default_data_lake_storage self.sql_administrator_login_password = sql_administrator_login_password @@ -13868,19 +13279,19 @@ class WorkspaceAadAdminInfo(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tenant_id': {'key': 'properties.tenantId', 'type': 'str'}, - 'login': {'key': 'properties.login', 'type': 'str'}, - 'administrator_type': {'key': 'properties.administratorType', 'type': 'str'}, - 'sid': {'key': 'properties.sid', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tenant_id": {"key": "properties.tenantId", "type": "str"}, + "login": {"key": "properties.login", "type": "str"}, + "administrator_type": {"key": "properties.administratorType", "type": "str"}, + "sid": {"key": "properties.sid", "type": "str"}, } def __init__( @@ -13902,14 +13313,14 @@ def __init__( :keyword sid: Object ID of the workspace active directory administrator. :paramtype sid: str """ - super(WorkspaceAadAdminInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.tenant_id = tenant_id self.login = login self.administrator_type = administrator_type self.sid = sid -class WorkspaceInfoListResult(msrest.serialization.Model): +class WorkspaceInfoListResult(_serialization.Model): """List of workspaces. :ivar next_link: Link to the next page of results. @@ -13919,29 +13330,23 @@ class WorkspaceInfoListResult(msrest.serialization.Model): """ _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[Workspace]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[Workspace]"}, } - def __init__( - self, - *, - next_link: Optional[str] = None, - value: Optional[List["Workspace"]] = None, - **kwargs - ): + def __init__(self, *, next_link: Optional[str] = None, value: Optional[List["_models.Workspace"]] = None, **kwargs): """ :keyword next_link: Link to the next page of results. :paramtype next_link: str :keyword value: List of workspaces. :paramtype value: list[~azure.mgmt.synapse.models.Workspace] """ - super(WorkspaceInfoListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.next_link = next_link self.value = value -class WorkspaceKeyDetails(msrest.serialization.Model): +class WorkspaceKeyDetails(_serialization.Model): """Details of the customer managed key associated with the workspace. :ivar name: Workspace Key sub-resource name. @@ -13951,34 +13356,28 @@ class WorkspaceKeyDetails(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'key_vault_url': {'key': 'keyVaultUrl', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "key_vault_url": {"key": "keyVaultUrl", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - key_vault_url: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, key_vault_url: Optional[str] = None, **kwargs): """ :keyword name: Workspace Key sub-resource name. :paramtype name: str :keyword key_vault_url: Workspace Key sub-resource key vault url. :paramtype key_vault_url: str """ - super(WorkspaceKeyDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.key_vault_url = key_vault_url -class WorkspacePatchInfo(msrest.serialization.Model): +class WorkspacePatchInfo(_serialization.Model): """Workspace patch details. Variables are only populated by the server, and will be ignored when sending a request. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar identity: The identity of the workspace. :vartype identity: ~azure.mgmt.synapse.models.ManagedIdentity @@ -13996,42 +13395,48 @@ class WorkspacePatchInfo(msrest.serialization.Model): :vartype provisioning_state: str :ivar encryption: The encryption details of the workspace. :vartype encryption: ~azure.mgmt.synapse.models.EncryptionDetails - :ivar public_network_access: Enable or Disable public network access to workspace. Possible - values include: "Enabled", "Disabled". + :ivar public_network_access: Enable or Disable public network access to workspace. Known values + are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.synapse.models.WorkspacePublicNetworkAccess """ _validation = { - 'provisioning_state': {'readonly': True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentity'}, - 'sql_administrator_login_password': {'key': 'properties.sqlAdministratorLoginPassword', 'type': 'str'}, - 'managed_virtual_network_settings': {'key': 'properties.managedVirtualNetworkSettings', 'type': 'ManagedVirtualNetworkSettings'}, - 'workspace_repository_configuration': {'key': 'properties.workspaceRepositoryConfiguration', 'type': 'WorkspaceRepositoryConfiguration'}, - 'purview_configuration': {'key': 'properties.purviewConfiguration', 'type': 'PurviewConfiguration'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'encryption': {'key': 'properties.encryption', 'type': 'EncryptionDetails'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "sql_administrator_login_password": {"key": "properties.sqlAdministratorLoginPassword", "type": "str"}, + "managed_virtual_network_settings": { + "key": "properties.managedVirtualNetworkSettings", + "type": "ManagedVirtualNetworkSettings", + }, + "workspace_repository_configuration": { + "key": "properties.workspaceRepositoryConfiguration", + "type": "WorkspaceRepositoryConfiguration", + }, + "purview_configuration": {"key": "properties.purviewConfiguration", "type": "PurviewConfiguration"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "encryption": {"key": "properties.encryption", "type": "EncryptionDetails"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - identity: Optional["ManagedIdentity"] = None, + identity: Optional["_models.ManagedIdentity"] = None, sql_administrator_login_password: Optional[str] = None, - managed_virtual_network_settings: Optional["ManagedVirtualNetworkSettings"] = None, - workspace_repository_configuration: Optional["WorkspaceRepositoryConfiguration"] = None, - purview_configuration: Optional["PurviewConfiguration"] = None, - encryption: Optional["EncryptionDetails"] = None, - public_network_access: Optional[Union[str, "WorkspacePublicNetworkAccess"]] = None, + managed_virtual_network_settings: Optional["_models.ManagedVirtualNetworkSettings"] = None, + workspace_repository_configuration: Optional["_models.WorkspaceRepositoryConfiguration"] = None, + purview_configuration: Optional["_models.PurviewConfiguration"] = None, + encryption: Optional["_models.EncryptionDetails"] = None, + public_network_access: Optional[Union[str, "_models.WorkspacePublicNetworkAccess"]] = None, **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword identity: The identity of the workspace. :paramtype identity: ~azure.mgmt.synapse.models.ManagedIdentity @@ -14047,12 +13452,12 @@ def __init__( :paramtype purview_configuration: ~azure.mgmt.synapse.models.PurviewConfiguration :keyword encryption: The encryption details of the workspace. :paramtype encryption: ~azure.mgmt.synapse.models.EncryptionDetails - :keyword public_network_access: Enable or Disable public network access to workspace. Possible - values include: "Enabled", "Disabled". + :keyword public_network_access: Enable or Disable public network access to workspace. Known + values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.synapse.models.WorkspacePublicNetworkAccess """ - super(WorkspacePatchInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.identity = identity self.sql_administrator_login_password = sql_administrator_login_password @@ -14064,7 +13469,7 @@ def __init__( self.public_network_access = public_network_access -class WorkspaceRepositoryConfiguration(msrest.serialization.Model): +class WorkspaceRepositoryConfiguration(_serialization.Model): """Git integration settings. :ivar type: Type of workspace repositoryID configuration. Example WorkspaceVSTSConfiguration, @@ -14089,15 +13494,15 @@ class WorkspaceRepositoryConfiguration(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'host_name': {'key': 'hostName', 'type': 'str'}, - 'account_name': {'key': 'accountName', 'type': 'str'}, - 'project_name': {'key': 'projectName', 'type': 'str'}, - 'repository_name': {'key': 'repositoryName', 'type': 'str'}, - 'collaboration_branch': {'key': 'collaborationBranch', 'type': 'str'}, - 'root_folder': {'key': 'rootFolder', 'type': 'str'}, - 'last_commit_id': {'key': 'lastCommitId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "host_name": {"key": "hostName", "type": "str"}, + "account_name": {"key": "accountName", "type": "str"}, + "project_name": {"key": "projectName", "type": "str"}, + "repository_name": {"key": "repositoryName", "type": "str"}, + "collaboration_branch": {"key": "collaborationBranch", "type": "str"}, + "root_folder": {"key": "rootFolder", "type": "str"}, + "last_commit_id": {"key": "lastCommitId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, } def __init__( @@ -14135,7 +13540,7 @@ def __init__( :keyword tenant_id: The VSTS tenant ID. :paramtype tenant_id: str """ - super(WorkspaceRepositoryConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.host_name = host_name self.account_name = account_name diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/models/_patch.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 04fee4a1b20e..0f549cb33d61 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 @@ -7,27 +7,40 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AzureADOnlyAuthenticationName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ActualState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Actual state.""" + + ENABLING = "Enabling" + ENABLED = "Enabled" + DISABLING = "Disabling" + DISABLED = "Disabled" + UNKNOWN = "Unknown" + + +class AzureADOnlyAuthenticationName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """AzureADOnlyAuthenticationName.""" DEFAULT = "default" -class AzureScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Scale type. - """ + +class AzureScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Scale type.""" AUTOMATIC = "automatic" MANUAL = "manual" NONE = "none" -class BlobAuditingPolicyName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class BlobAuditingPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """BlobAuditingPolicyName.""" DEFAULT = "default" -class BlobAuditingPolicyState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class BlobAuditingPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the state of the policy. If state is Enabled, storageEndpoint or isAzureMonitorTargetEnabled are required. """ @@ -35,23 +48,23 @@ class BlobAuditingPolicyState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) ENABLED = "Enabled" DISABLED = "Disabled" -class BlobStorageEventType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The name of blob storage event type to process. - """ + +class BlobStorageEventType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The name of blob storage event type to process.""" MICROSOFT_STORAGE_BLOB_CREATED = "Microsoft.Storage.BlobCreated" MICROSOFT_STORAGE_BLOB_RENAMED = "Microsoft.Storage.BlobRenamed" -class ClusterPrincipalRole(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Cluster principal role. - """ + +class ClusterPrincipalRole(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Cluster principal role.""" ALL_DATABASES_ADMIN = "AllDatabasesAdmin" ALL_DATABASES_VIEWER = "AllDatabasesViewer" -class ColumnDataType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The column data type. - """ + +class ColumnDataType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The column data type.""" IMAGE = "image" TEXT = "text" @@ -88,45 +101,48 @@ class ColumnDataType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): XML = "xml" SYSNAME = "sysname" -class Compression(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The compression type - """ + +class Compression(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The compression type.""" NONE = "None" G_ZIP = "GZip" -class ConfigurationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the spark config properties file. - """ + +class ConfigurationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the spark config properties file.""" FILE = "File" ARTIFACT = "Artifact" -class ConnectionPolicyName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ConnectionPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ConnectionPolicyName.""" DEFAULT = "default" -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that created the resource. - """ + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class CreateMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class CreateMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of sql pool creation. - + Default: regular sql pool creation. - + PointInTimeRestore: Creates a sql pool by restoring a point in time backup of an existing sql pool. sourceDatabaseId must be specified as the resource ID of the existing sql pool, and restorePointInTime must be specified. - + Recovery: Creates a sql pool by a geo-replicated backup. sourceDatabaseId must be specified as the recoverableDatabaseId to restore. - + Restore: Creates a sql pool by restoring a backup of a deleted sql pool. SourceDatabaseId should be the sql pool's original resource ID. SourceDatabaseId and sourceDatabaseDeletionDate must be specified. @@ -137,9 +153,9 @@ class CreateMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): RECOVERY = "Recovery" RESTORE = "Restore" -class DatabasePrincipalRole(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Database principal role. - """ + +class DatabasePrincipalRole(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Database principal role.""" ADMIN = "Admin" INGESTOR = "Ingestor" @@ -148,25 +164,25 @@ class DatabasePrincipalRole(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): UNRESTRICTED_VIEWER = "UnrestrictedViewer" VIEWER = "Viewer" -class DataConnectionKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Kind of the endpoint for the data connection - """ + +class DataConnectionKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Kind of the endpoint for the data connection.""" EVENT_HUB = "EventHub" EVENT_GRID = "EventGrid" IOT_HUB = "IotHub" -class DataFlowComputeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Compute type of the cluster which will execute data flow job. - """ + +class DataFlowComputeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Compute type of the cluster which will execute data flow job.""" GENERAL = "General" MEMORY_OPTIMIZED = "MemoryOptimized" COMPUTE_OPTIMIZED = "ComputeOptimized" -class DataMaskingFunction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The masking function that is used for the data masking rule. - """ + +class DataMaskingFunction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The masking function that is used for the data masking rule.""" DEFAULT = "Default" CCN = "CCN" @@ -175,7 +191,8 @@ class DataMaskingFunction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SSN = "SSN" TEXT = "Text" -class DataMaskingRuleState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class DataMaskingRuleState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The rule state. Used to delete a rule. To delete an existing rule, specify the schemaName, tableName, columnName, maskingFunction, and specify ruleState as disabled. However, if the rule doesn't already exist, the rule will be created with ruleState set to enabled, regardless of @@ -185,20 +202,22 @@ class DataMaskingRuleState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DISABLED = "Disabled" ENABLED = "Enabled" -class DataMaskingState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The state of the data masking policy. - """ + +class DataMaskingState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The state of the data masking policy.""" DISABLED = "Disabled" ENABLED = "Enabled" -class DataWarehouseUserActivityName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class DataWarehouseUserActivityName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """DataWarehouseUserActivityName.""" CURRENT = "current" -class DayOfWeek(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Day of maintenance window. - """ + +class DayOfWeek(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Day of maintenance window.""" SUNDAY = "Sunday" MONDAY = "Monday" @@ -208,25 +227,36 @@ class DayOfWeek(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FRIDAY = "Friday" SATURDAY = "Saturday" -class DedicatedSQLMinimalTlsSettingsName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class DedicatedSQLMinimalTlsSettingsName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """DedicatedSQLMinimalTlsSettingsName.""" DEFAULT = "default" -class DefaultPrincipalsModificationKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The default principals modification kind - """ + +class DefaultPrincipalsModificationKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The default principals modification kind.""" UNION = "Union" REPLACE = "Replace" NONE = "None" -class EncryptionProtectorName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class DesiredState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Desired state.""" + + ENABLED = "Enabled" + DISABLED = "Disabled" + + +class EncryptionProtectorName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """EncryptionProtectorName.""" CURRENT = "current" -class EventGridDataFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The data format of the message. Optionally the data format can be added to each message. - """ + +class EventGridDataFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The data format of the message. Optionally the data format can be added to each message.""" MULTIJSON = "MULTIJSON" JSON = "JSON" @@ -245,9 +275,9 @@ class EventGridDataFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): APACHEAVRO = "APACHEAVRO" W3_CLOGFILE = "W3CLOGFILE" -class EventHubDataFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The data format of the message. Optionally the data format can be added to each message. - """ + +class EventHubDataFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The data format of the message. Optionally the data format can be added to each message.""" MULTIJSON = "MULTIJSON" JSON = "JSON" @@ -266,46 +296,49 @@ class EventHubDataFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): APACHEAVRO = "APACHEAVRO" W3_CLOGFILE = "W3CLOGFILE" -class GeoBackupPolicyName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class GeoBackupPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """GeoBackupPolicyName.""" DEFAULT = "Default" -class GeoBackupPolicyState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The state of the geo backup policy. - """ + +class GeoBackupPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The state of the geo backup policy.""" DISABLED = "Disabled" ENABLED = "Enabled" -class IntegrationRuntimeAuthKeyName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The name of the authentication key to regenerate. - """ + +class IntegrationRuntimeAuthKeyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The name of the authentication key to regenerate.""" AUTH_KEY1 = "authKey1" AUTH_KEY2 = "authKey2" -class IntegrationRuntimeAutoUpdate(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The state of integration runtime auto update. - """ + +class IntegrationRuntimeAutoUpdate(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The state of integration runtime auto update.""" ON = "On" OFF = "Off" -class IntegrationRuntimeEdition(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The edition for the SSIS Integration Runtime - """ + +class IntegrationRuntimeEdition(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The edition for the SSIS Integration Runtime.""" STANDARD = "Standard" ENTERPRISE = "Enterprise" -class IntegrationRuntimeEntityReferenceType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of this referenced entity. - """ + +class IntegrationRuntimeEntityReferenceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of this referenced entity.""" INTEGRATION_RUNTIME_REFERENCE = "IntegrationRuntimeReference" LINKED_SERVICE_REFERENCE = "LinkedServiceReference" -class IntegrationRuntimeInternalChannelEncryptionMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class IntegrationRuntimeInternalChannelEncryptionMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """It is used to set the encryption mode for node-node communication channel (when more than 2 self-hosted integration runtime nodes exist). """ @@ -314,16 +347,17 @@ class IntegrationRuntimeInternalChannelEncryptionMode(with_metaclass(CaseInsensi SSL_ENCRYPTED = "SslEncrypted" NOT_ENCRYPTED = "NotEncrypted" -class IntegrationRuntimeLicenseType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """License type for bringing your own license scenario. - """ + +class IntegrationRuntimeLicenseType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """License type for bringing your own license scenario.""" BASE_PRICE = "BasePrice" LICENSE_INCLUDED = "LicenseIncluded" -class IntegrationRuntimeSsisCatalogPricingTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class IntegrationRuntimeSsisCatalogPricingTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The pricing tier for the catalog database. The valid values could be found in - https://azure.microsoft.com/en-us/pricing/details/sql-database/ + https://azure.microsoft.com/en-us/pricing/details/sql-database/. """ BASIC = "Basic" @@ -331,9 +365,9 @@ class IntegrationRuntimeSsisCatalogPricingTier(with_metaclass(CaseInsensitiveEnu PREMIUM = "Premium" PREMIUM_RS = "PremiumRS" -class IntegrationRuntimeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The state of integration runtime. - """ + +class IntegrationRuntimeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The state of integration runtime.""" INITIAL = "Initial" STOPPED = "Stopped" @@ -346,24 +380,24 @@ class IntegrationRuntimeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) OFFLINE = "Offline" ACCESS_DENIED = "AccessDenied" -class IntegrationRuntimeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of integration runtime. - """ + +class IntegrationRuntimeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of integration runtime.""" MANAGED = "Managed" SELF_HOSTED = "SelfHosted" -class IntegrationRuntimeUpdateResult(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The result of the last integration runtime node update. - """ + +class IntegrationRuntimeUpdateResult(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The result of the last integration runtime node update.""" NONE = "None" SUCCEED = "Succeed" FAIL = "Fail" -class IotHubDataFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The data format of the message. Optionally the data format can be added to each message. - """ + +class IotHubDataFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The data format of the message. Optionally the data format can be added to each message.""" MULTIJSON = "MULTIJSON" JSON = "JSON" @@ -382,49 +416,32 @@ class IotHubDataFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): APACHEAVRO = "APACHEAVRO" W3_CLOGFILE = "W3CLOGFILE" -class Kind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Kind of the database - """ + +class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Kind of the database.""" READ_WRITE = "ReadWrite" READ_ONLY_FOLLOWING = "ReadOnlyFollowing" -class LanguageExtensionName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Language extension that can run within KQL query. - """ + +class LanguageExtensionName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Language extension that can run within KQL query.""" PYTHON = "PYTHON" R = "R" -class ManagedIdentitySqlControlSettingsModelPropertiesGrantSqlControlToManagedIdentityActualState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Actual state - """ - ENABLING = "Enabling" - ENABLED = "Enabled" - DISABLING = "Disabling" - DISABLED = "Disabled" - UNKNOWN = "Unknown" - -class ManagedIdentitySqlControlSettingsModelPropertiesGrantSqlControlToManagedIdentityDesiredState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Desired state - """ - - ENABLED = "Enabled" - DISABLED = "Disabled" - -class ManagedIntegrationRuntimeNodeStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The managed integration runtime node status. - """ +class ManagedIntegrationRuntimeNodeStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The managed integration runtime node status.""" STARTING = "Starting" AVAILABLE = "Available" RECYCLING = "Recycling" UNAVAILABLE = "Unavailable" -class ManagementOperationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The operation state. - """ + +class ManagementOperationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The operation state.""" PENDING = "Pending" IN_PROGRESS = "InProgress" @@ -433,9 +450,9 @@ class ManagementOperationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum CANCEL_IN_PROGRESS = "CancelInProgress" CANCELLED = "Cancelled" -class NodeSize(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The level of compute power that each node in the Big Data pool has. - """ + +class NodeSize(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The level of compute power that each node in the Big Data pool has.""" NONE = "None" SMALL = "Small" @@ -445,43 +462,43 @@ class NodeSize(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): XX_LARGE = "XXLarge" XXX_LARGE = "XXXLarge" -class NodeSizeFamily(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The kind of nodes that the Big Data pool provides. - """ + +class NodeSizeFamily(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The kind of nodes that the Big Data pool provides.""" NONE = "None" MEMORY_OPTIMIZED = "MemoryOptimized" HARDWARE_ACCELERATED_FPGA = "HardwareAcceleratedFPGA" HARDWARE_ACCELERATED_GPU = "HardwareAcceleratedGPU" -class OperationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Operation status - """ + +class OperationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Operation status.""" IN_PROGRESS = "InProgress" SUCCEEDED = "Succeeded" FAILED = "Failed" CANCELED = "Canceled" -class PrincipalsModificationKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The principals modification kind of the database - """ + +class PrincipalsModificationKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The principals modification kind of the database.""" UNION = "Union" REPLACE = "Replace" NONE = "None" -class PrincipalType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Principal type. - """ + +class PrincipalType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Principal type.""" APP = "App" GROUP = "Group" USER = "User" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Resource provisioning state - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Resource provisioning state.""" PROVISIONING = "Provisioning" SUCCEEDED = "Succeeded" @@ -489,18 +506,18 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" DELETE_ERROR = "DeleteError" -class QueryAggregationFunction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The function that is used to aggregate each query's metrics. - """ + +class QueryAggregationFunction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The function that is used to aggregate each query's metrics.""" MIN = "min" MAX = "max" AVG = "avg" SUM = "sum" -class QueryExecutionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The execution type that is used to filter the query instances that are returned. - """ + +class QueryExecutionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The execution type that is used to filter the query instances that are returned.""" ANY = "any" REGULAR = "regular" @@ -508,17 +525,17 @@ class QueryExecutionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ABORTED = "aborted" EXCEPTION = "exception" -class QueryMetricUnit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The unit of measurement - """ + +class QueryMetricUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The unit of measurement.""" PERCENTAGE = "percentage" KB = "KB" MICROSECONDS = "microseconds" -class QueryObservedMetricType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of metric to use for ordering the top metrics. - """ + +class QueryObservedMetricType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of metric to use for ordering the top metrics.""" CPU = "cpu" IO = "io" @@ -526,21 +543,23 @@ class QueryObservedMetricType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) DURATION = "duration" EXECUTION_COUNT = "executionCount" -class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Message providing the reason why the given name is invalid. - """ + +class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Message providing the reason why the given name is invalid.""" INVALID = "Invalid" ALREADY_EXISTS = "AlreadyExists" -class RecommendedSensitivityLabelUpdateKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class RecommendedSensitivityLabelUpdateKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """RecommendedSensitivityLabelUpdateKind.""" ENABLE = "enable" DISABLE = "disable" -class ReplicationRole(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The role of the Sql pool in the replication link. - """ + +class ReplicationRole(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The role of the Sql pool in the replication link.""" PRIMARY = "Primary" SECONDARY = "Secondary" @@ -548,26 +567,26 @@ class ReplicationRole(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SOURCE = "Source" COPY = "Copy" -class ReplicationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The replication state for the replication link. - """ + +class ReplicationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The replication state for the replication link.""" PENDING = "PENDING" SEEDING = "SEEDING" CATCH_UP = "CATCH_UP" SUSPENDED = "SUSPENDED" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of managed identity for the workspace - """ + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of managed identity for the workspace.""" NONE = "None" SYSTEM_ASSIGNED = "SystemAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" -class ResourceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The provisioned state of the resource. - """ + +class ResourceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioned state of the resource.""" RUNNING = "Running" CREATING = "Creating" @@ -577,22 +596,27 @@ class ResourceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enu MOVING = "Moving" CANCELED = "Canceled" -class RestorePointType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of restore point - """ + +class RestorePointType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of restore point.""" CONTINUOUS = "CONTINUOUS" DISCRETE = "DISCRETE" -class SecurityAlertPolicyName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class SecurityAlertPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """SecurityAlertPolicyName.""" DEFAULT = "default" -class SecurityAlertPolicyNameAutoGenerated(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class SecurityAlertPolicyNameAutoGenerated(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """SecurityAlertPolicyNameAutoGenerated.""" DEFAULT = "Default" -class SecurityAlertPolicyState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class SecurityAlertPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the state of the policy, whether it is enabled or disabled or a policy has not been applied yet on the specific Sql pool. """ @@ -601,9 +625,9 @@ class SecurityAlertPolicyState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum ENABLED = "Enabled" DISABLED = "Disabled" -class SelfHostedIntegrationRuntimeNodeStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Status of the integration runtime node. - """ + +class SelfHostedIntegrationRuntimeNodeStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Status of the integration runtime node.""" NEED_REGISTRATION = "NeedRegistration" ONLINE = "Online" @@ -613,7 +637,9 @@ class SelfHostedIntegrationRuntimeNodeStatus(with_metaclass(CaseInsensitiveEnumM INITIALIZING = "Initializing" INITIALIZE_FAILED = "InitializeFailed" -class SensitivityLabelRank(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class SensitivityLabelRank(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """SensitivityLabelRank.""" NONE = "None" LOW = "Low" @@ -621,51 +647,55 @@ class SensitivityLabelRank(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): HIGH = "High" CRITICAL = "Critical" -class SensitivityLabelSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class SensitivityLabelSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """SensitivityLabelSource.""" CURRENT = "current" RECOMMENDED = "recommended" -class SensitivityLabelUpdateKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class SensitivityLabelUpdateKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """SensitivityLabelUpdateKind.""" SET = "set" REMOVE = "remove" -class ServerKeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The encryption protector type like 'ServiceManaged', 'AzureKeyVault'. - """ + +class ServerKeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The encryption protector type like 'ServiceManaged', 'AzureKeyVault'.""" SERVICE_MANAGED = "ServiceManaged" AZURE_KEY_VAULT = "AzureKeyVault" -class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """SKU name. - """ + +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """SKU name.""" COMPUTE_OPTIMIZED = "Compute optimized" STORAGE_OPTIMIZED = "Storage optimized" -class SkuSize(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """SKU size. - """ + +class SkuSize(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """SKU size.""" EXTRA_SMALL = "Extra small" SMALL = "Small" MEDIUM = "Medium" LARGE = "Large" -class SsisObjectMetadataType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of SSIS object metadata. - """ + +class SsisObjectMetadataType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of SSIS object metadata.""" FOLDER = "Folder" PROJECT = "Project" PACKAGE = "Package" ENVIRONMENT = "Environment" -class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The state of the resource. - """ + +class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The state of the resource.""" CREATING = "Creating" UNAVAILABLE = "Unavailable" @@ -677,67 +707,75 @@ class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STARTING = "Starting" UPDATING = "Updating" -class StateValue(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """property configuration state - """ + +class StateValue(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """property configuration state.""" CONSISTENT = "Consistent" IN_CONSISTENT = "InConsistent" UPDATING = "Updating" -class StorageAccountType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The storage account type used to store backups for this sql pool. - """ + +class StorageAccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The storage account type used to store backups for this sql pool.""" GRS = "GRS" LRS = "LRS" -class TransparentDataEncryptionName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class TransparentDataEncryptionName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """TransparentDataEncryptionName.""" CURRENT = "current" -class TransparentDataEncryptionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The status of the database transparent data encryption. - """ + +class TransparentDataEncryptionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the database transparent data encryption.""" ENABLED = "Enabled" DISABLED = "Disabled" -class Type(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of resource, for instance Microsoft.Synapse/workspaces/kustoPools/databases. - """ + +class Type(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of resource, for instance Microsoft.Synapse/workspaces/kustoPools/databases.""" MICROSOFT_SYNAPSE_WORKSPACES_KUSTO_POOLS_DATABASES = "Microsoft.Synapse/workspaces/kustoPools/databases" - MICROSOFT_SYNAPSE_WORKSPACES_KUSTO_POOLS_ATTACHED_DATABASE_CONFIGURATIONS = "Microsoft.Synapse/workspaces/kustoPools/attachedDatabaseConfigurations" + MICROSOFT_SYNAPSE_WORKSPACES_KUSTO_POOLS_ATTACHED_DATABASE_CONFIGURATIONS = ( + "Microsoft.Synapse/workspaces/kustoPools/attachedDatabaseConfigurations" + ) + -class VulnerabilityAssessmentName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VulnerabilityAssessmentName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """VulnerabilityAssessmentName.""" DEFAULT = "default" -class VulnerabilityAssessmentPolicyBaselineName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class VulnerabilityAssessmentPolicyBaselineName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """VulnerabilityAssessmentPolicyBaselineName.""" MASTER = "master" DEFAULT = "default" -class VulnerabilityAssessmentScanState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The scan status. - """ + +class VulnerabilityAssessmentScanState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The scan status.""" PASSED = "Passed" FAILED = "Failed" FAILED_TO_RUN = "FailedToRun" IN_PROGRESS = "InProgress" -class VulnerabilityAssessmentScanTriggerType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The scan trigger type. - """ + +class VulnerabilityAssessmentScanTriggerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The scan trigger type.""" ON_DEMAND = "OnDemand" RECURRING = "Recurring" -class WorkspacePublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Enable or Disable public network access to workspace - """ + +class WorkspacePublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enable or Disable public network access to workspace.""" ENABLED = "Enabled" DISABLED = "Disabled" 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 20541b1ecb35..1c679de80542 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 @@ -14,7 +14,9 @@ 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 ._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 @@ -37,25 +39,43 @@ 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 ._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_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 ._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 ._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 @@ -80,78 +100,84 @@ from ._kusto_pool_principal_assignments_operations import KustoPoolPrincipalAssignmentsOperations from ._kusto_pool_database_principal_assignments_operations import KustoPoolDatabasePrincipalAssignmentsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AzureADOnlyAuthenticationsOperations', - 'Operations', - 'IpFirewallRulesOperations', - 'KeysOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'PrivateLinkHubPrivateLinkResourcesOperations', - 'PrivateLinkHubsOperations', - 'PrivateEndpointConnectionsPrivateLinkHubOperations', - 'SqlPoolsOperations', - 'SqlPoolMetadataSyncConfigsOperations', - 'SqlPoolOperationResultsOperations', - 'SqlPoolGeoBackupPoliciesOperations', - 'SqlPoolDataWarehouseUserActivitiesOperations', - 'SqlPoolRestorePointsOperations', - 'SqlPoolReplicationLinksOperations', - 'SqlPoolMaintenanceWindowsOperations', - 'SqlPoolMaintenanceWindowOptionsOperations', - 'SqlPoolTransparentDataEncryptionsOperations', - 'SqlPoolBlobAuditingPoliciesOperations', - 'SqlPoolOperationsOperations', - 'SqlPoolUsagesOperations', - 'SqlPoolSensitivityLabelsOperations', - 'SqlPoolRecommendedSensitivityLabelsOperations', - 'SqlPoolSchemasOperations', - 'SqlPoolTablesOperations', - 'SqlPoolTableColumnsOperations', - 'SqlPoolConnectionPoliciesOperations', - 'SqlPoolVulnerabilityAssessmentsOperations', - 'SqlPoolVulnerabilityAssessmentScansOperations', - 'SqlPoolSecurityAlertPoliciesOperations', - 'SqlPoolVulnerabilityAssessmentRuleBaselinesOperations', - 'ExtendedSqlPoolBlobAuditingPoliciesOperations', - 'DataMaskingPoliciesOperations', - 'DataMaskingRulesOperations', - 'SqlPoolColumnsOperations', - 'SqlPoolWorkloadGroupOperations', - 'SqlPoolWorkloadClassifierOperations', - 'WorkspaceManagedSqlServerBlobAuditingPoliciesOperations', - 'WorkspaceManagedSqlServerExtendedBlobAuditingPoliciesOperations', - 'WorkspaceManagedSqlServerSecurityAlertPolicyOperations', - 'WorkspaceManagedSqlServerVulnerabilityAssessmentsOperations', - 'WorkspaceManagedSqlServerEncryptionProtectorOperations', - 'WorkspaceManagedSqlServerUsagesOperations', - 'WorkspaceManagedSqlServerRecoverableSqlPoolsOperations', - 'WorkspaceManagedSqlServerDedicatedSQLMinimalTlsSettingsOperations', - 'WorkspacesOperations', - 'WorkspaceAadAdminsOperations', - 'WorkspaceSqlAadAdminsOperations', - 'WorkspaceManagedIdentitySqlControlSettingsOperations', - 'RestorableDroppedSqlPoolsOperations', - 'BigDataPoolsOperations', - 'LibraryOperations', - 'LibrariesOperations', - 'IntegrationRuntimesOperations', - 'IntegrationRuntimeNodeIpAddressOperations', - 'IntegrationRuntimeObjectMetadataOperations', - 'IntegrationRuntimeNodesOperations', - 'IntegrationRuntimeCredentialsOperations', - 'IntegrationRuntimeConnectionInfosOperations', - 'IntegrationRuntimeAuthKeysOperations', - 'IntegrationRuntimeMonitoringDataOperations', - 'IntegrationRuntimeStatusOperations', - 'SparkConfigurationOperations', - 'SparkConfigurationsOperations', - 'KustoOperationsOperations', - 'KustoPoolsOperations', - 'KustoPoolChildResourceOperations', - 'KustoPoolAttachedDatabaseConfigurationsOperations', - 'KustoPoolDatabasesOperations', - 'KustoPoolDataConnectionsOperations', - 'KustoPoolPrincipalAssignmentsOperations', - 'KustoPoolDatabasePrincipalAssignmentsOperations', + "AzureADOnlyAuthenticationsOperations", + "Operations", + "IpFirewallRulesOperations", + "KeysOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "PrivateLinkHubPrivateLinkResourcesOperations", + "PrivateLinkHubsOperations", + "PrivateEndpointConnectionsPrivateLinkHubOperations", + "SqlPoolsOperations", + "SqlPoolMetadataSyncConfigsOperations", + "SqlPoolOperationResultsOperations", + "SqlPoolGeoBackupPoliciesOperations", + "SqlPoolDataWarehouseUserActivitiesOperations", + "SqlPoolRestorePointsOperations", + "SqlPoolReplicationLinksOperations", + "SqlPoolMaintenanceWindowsOperations", + "SqlPoolMaintenanceWindowOptionsOperations", + "SqlPoolTransparentDataEncryptionsOperations", + "SqlPoolBlobAuditingPoliciesOperations", + "SqlPoolOperationsOperations", + "SqlPoolUsagesOperations", + "SqlPoolSensitivityLabelsOperations", + "SqlPoolRecommendedSensitivityLabelsOperations", + "SqlPoolSchemasOperations", + "SqlPoolTablesOperations", + "SqlPoolTableColumnsOperations", + "SqlPoolConnectionPoliciesOperations", + "SqlPoolVulnerabilityAssessmentsOperations", + "SqlPoolVulnerabilityAssessmentScansOperations", + "SqlPoolSecurityAlertPoliciesOperations", + "SqlPoolVulnerabilityAssessmentRuleBaselinesOperations", + "ExtendedSqlPoolBlobAuditingPoliciesOperations", + "DataMaskingPoliciesOperations", + "DataMaskingRulesOperations", + "SqlPoolColumnsOperations", + "SqlPoolWorkloadGroupOperations", + "SqlPoolWorkloadClassifierOperations", + "WorkspaceManagedSqlServerBlobAuditingPoliciesOperations", + "WorkspaceManagedSqlServerExtendedBlobAuditingPoliciesOperations", + "WorkspaceManagedSqlServerSecurityAlertPolicyOperations", + "WorkspaceManagedSqlServerVulnerabilityAssessmentsOperations", + "WorkspaceManagedSqlServerEncryptionProtectorOperations", + "WorkspaceManagedSqlServerUsagesOperations", + "WorkspaceManagedSqlServerRecoverableSqlPoolsOperations", + "WorkspaceManagedSqlServerDedicatedSQLMinimalTlsSettingsOperations", + "WorkspacesOperations", + "WorkspaceAadAdminsOperations", + "WorkspaceSqlAadAdminsOperations", + "WorkspaceManagedIdentitySqlControlSettingsOperations", + "RestorableDroppedSqlPoolsOperations", + "BigDataPoolsOperations", + "LibraryOperations", + "LibrariesOperations", + "IntegrationRuntimesOperations", + "IntegrationRuntimeNodeIpAddressOperations", + "IntegrationRuntimeObjectMetadataOperations", + "IntegrationRuntimeNodesOperations", + "IntegrationRuntimeCredentialsOperations", + "IntegrationRuntimeConnectionInfosOperations", + "IntegrationRuntimeAuthKeysOperations", + "IntegrationRuntimeMonitoringDataOperations", + "IntegrationRuntimeStatusOperations", + "SparkConfigurationOperations", + "SparkConfigurationsOperations", + "KustoOperationsOperations", + "KustoPoolsOperations", + "KustoPoolChildResourceOperations", + "KustoPoolAttachedDatabaseConfigurationsOperations", + "KustoPoolDatabasesOperations", + "KustoPoolDataConnectionsOperations", + "KustoPoolPrincipalAssignmentsOperations", + "KustoPoolDatabasePrincipalAssignmentsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_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 e1bca17a8afc..dfeab15b7fbf 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 @@ -6,169 +6,171 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, workspace_name: str, azure_ad_only_authentication_name: Union[str, "_models.AzureADOnlyAuthenticationName"], + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/azureADOnlyAuthentications/{azureADOnlyAuthenticationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/azureADOnlyAuthentications/{azureADOnlyAuthenticationName}", + ) # 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'), - "azureADOnlyAuthenticationName": _SERIALIZER.url("azure_ad_only_authentication_name", azure_ad_only_authentication_name, 'str'), + "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"), + "azureADOnlyAuthenticationName": _SERIALIZER.url( + "azure_ad_only_authentication_name", azure_ad_only_authentication_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, +def build_create_request( resource_group_name: str, workspace_name: str, azure_ad_only_authentication_name: Union[str, "_models.AzureADOnlyAuthenticationName"], - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/azureADOnlyAuthentications/{azureADOnlyAuthenticationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/azureADOnlyAuthentications/{azureADOnlyAuthenticationName}", + ) # 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'), - "azureADOnlyAuthenticationName": _SERIALIZER.url("azure_ad_only_authentication_name", azure_ad_only_authentication_name, 'str'), + "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"), + "azureADOnlyAuthenticationName": _SERIALIZER.url( + "azure_ad_only_authentication_name", azure_ad_only_authentication_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/azureADOnlyAuthentications") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/azureADOnlyAuthentications", + ) # 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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class AzureADOnlyAuthenticationsOperations(object): - """AzureADOnlyAuthenticationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class AzureADOnlyAuthenticationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`azure_ad_only_authentications` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( @@ -177,51 +179,55 @@ def get( workspace_name: str, azure_ad_only_authentication_name: Union[str, "_models.AzureADOnlyAuthenticationName"], **kwargs: Any - ) -> "_models.AzureADOnlyAuthentication": + ) -> _models.AzureADOnlyAuthentication: """Get Azure Active Directory only authentication property. Gets a Azure Active Directory only authentication property. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param azure_ad_only_authentication_name: name of the property. + :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 api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureADOnlyAuthentication, or the result of cls(response) + :return: AzureADOnlyAuthentication or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.AzureADOnlyAuthentication - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureADOnlyAuthentication"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureADOnlyAuthentication] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -229,73 +235,170 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/azureADOnlyAuthentications/{azureADOnlyAuthenticationName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/azureADOnlyAuthentications/{azureADOnlyAuthenticationName}"} # 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: "_models.AzureADOnlyAuthentication", + azure_ad_only_authentication_info: Union[_models.AzureADOnlyAuthentication, IO], **kwargs: Any - ) -> Optional["_models.AzureADOnlyAuthentication"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AzureADOnlyAuthentication"]] + ) -> Optional[_models.AzureADOnlyAuthentication]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(azure_ad_only_authentication_info, 'AzureADOnlyAuthentication') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.AzureADOnlyAuthentication]] - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(azure_ad_only_authentication_info, (IO, bytes)): + _content = azure_ad_only_authentication_info + else: + _json = self._serialize.body(azure_ad_only_authentication_info, "AzureADOnlyAuthentication") + + request = build_create_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, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("AzureADOnlyAuthentication", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AzureADOnlyAuthentication', pipeline_response) + deserialized = self._deserialize("AzureADOnlyAuthentication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/azureADOnlyAuthentications/{azureADOnlyAuthenticationName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/azureADOnlyAuthentications/{azureADOnlyAuthenticationName}"} # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + workspace_name: str, + azure_ad_only_authentication_name: Union[str, "_models.AzureADOnlyAuthenticationName"], + azure_ad_only_authentication_info: _models.AzureADOnlyAuthentication, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AzureADOnlyAuthentication]: + """Create or Update Azure Active Directory only authentication property. + + Create or Update a Azure Active Directory only authentication property for the workspaces. + + :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 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. Required. + :type azure_ad_only_authentication_info: ~azure.mgmt.synapse.models.AzureADOnlyAuthentication + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + workspace_name: str, + azure_ad_only_authentication_name: Union[str, "_models.AzureADOnlyAuthenticationName"], + azure_ad_only_authentication_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AzureADOnlyAuthentication]: + """Create or Update Azure Active Directory only authentication property. + Create or Update a Azure Active Directory only authentication property for the workspaces. + + :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 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. Required. + :type azure_ad_only_authentication_info: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AzureADOnlyAuthentication or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.AzureADOnlyAuthentication] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -303,25 +406,28 @@ def begin_create( resource_group_name: str, workspace_name: str, azure_ad_only_authentication_name: Union[str, "_models.AzureADOnlyAuthenticationName"], - azure_ad_only_authentication_info: "_models.AzureADOnlyAuthentication", + azure_ad_only_authentication_info: Union[_models.AzureADOnlyAuthentication, IO], **kwargs: Any - ) -> LROPoller["_models.AzureADOnlyAuthentication"]: + ) -> LROPoller[_models.AzureADOnlyAuthentication]: """Create or Update Azure Active Directory only authentication property. Create or Update a Azure Active Directory only authentication property for the workspaces. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param azure_ad_only_authentication_name: name of the property. + :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. + :param azure_ad_only_authentication_info: Azure Active Directory Property. Is either a model + type or a IO type. Required. :type azure_ad_only_authentication_info: ~azure.mgmt.synapse.models.AzureADOnlyAuthentication - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/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 @@ -333,108 +439,109 @@ def begin_create( :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] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureADOnlyAuthentication"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureADOnlyAuthentication] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, azure_ad_only_authentication_name=azure_ad_only_authentication_name, azure_ad_only_authentication_info=azure_ad_only_authentication_info, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AzureADOnlyAuthentication', pipeline_response) + deserialized = self._deserialize("AzureADOnlyAuthentication", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/azureADOnlyAuthentications/{azureADOnlyAuthenticationName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/azureADOnlyAuthentications/{azureADOnlyAuthenticationName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> Iterable["_models.AzureADOnlyAuthenticationListResult"]: + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> Iterable["_models.AzureADOnlyAuthentication"]: """Gets a list of Azure Active Directory only authentication property. Gets a list of Azure Active Directory only authentication property for a workspace. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AzureADOnlyAuthenticationListResult or the result - of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.AzureADOnlyAuthenticationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either AzureADOnlyAuthentication or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.AzureADOnlyAuthentication] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureADOnlyAuthenticationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureADOnlyAuthenticationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -448,10 +555,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -462,8 +567,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/azureADOnlyAuthentications"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/azureADOnlyAuthentications"} # type: ignore 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 4146907e6f53..d112c03943cf 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 @@ -6,308 +6,296 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - big_data_pool_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, big_data_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}", + ) # 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'), - "bigDataPoolName": _SERIALIZER.url("big_data_pool_name", big_data_pool_name, 'str'), + "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"), + "bigDataPoolName": _SERIALIZER.url("big_data_pool_name", big_data_pool_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - big_data_pool_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, workspace_name: str, big_data_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}", + ) # 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'), - "bigDataPoolName": _SERIALIZER.url("big_data_pool_name", big_data_pool_name, 'str'), + "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"), + "bigDataPoolName": _SERIALIZER.url("big_data_pool_name", big_data_pool_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, +def build_create_or_update_request( resource_group_name: str, workspace_name: str, big_data_pool_name: str, + subscription_id: str, *, - json: JSONType = None, - content: Any = None, - force: Optional[bool] = False, + force: bool = False, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}", + ) # 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'), - "bigDataPoolName": _SERIALIZER.url("big_data_pool_name", big_data_pool_name, 'str'), + "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"), + "bigDataPoolName": _SERIALIZER.url("big_data_pool_name", big_data_pool_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if force is not None: - _query_parameters['force'] = _SERIALIZER.query("force", force, 'bool') + _params["force"] = _SERIALIZER.query("force", force, "bool") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - big_data_pool_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, workspace_name: str, big_data_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}", + ) # 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'), - "bigDataPoolName": _SERIALIZER.url("big_data_pool_name", big_data_pool_name, 'str'), + "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"), + "bigDataPoolName": _SERIALIZER.url("big_data_pool_name", big_data_pool_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_workspace_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools", + ) # 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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class BigDataPoolsOperations(object): - """BigDataPoolsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class BigDataPoolsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`big_data_pools` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - workspace_name: str, - big_data_pool_name: str, - **kwargs: Any - ) -> "_models.BigDataPoolResourceInfo": + self, resource_group_name: str, workspace_name: str, big_data_pool_name: str, **kwargs: Any + ) -> _models.BigDataPoolResourceInfo: """Get Big Data pool. Get a Big Data 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param big_data_pool_name: Big Data pool name. + :param big_data_pool_name: Big Data pool name. Required. :type big_data_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BigDataPoolResourceInfo, or the result of cls(response) + :return: BigDataPoolResourceInfo or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.BigDataPoolResourceInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BigDataPoolResourceInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.BigDataPoolResourceInfo] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -315,15 +303,80 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}"} # type: ignore + @overload + def update( + self, + resource_group_name: str, + workspace_name: str, + big_data_pool_name: str, + big_data_pool_patch_info: _models.BigDataPoolPatchInfo, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BigDataPoolResourceInfo: + """Update a Big Data pool. + + Patch a Big Data 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 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: ~azure.mgmt.synapse.models.BigDataPoolPatchInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: + """ + + @overload + def update( + self, + resource_group_name: str, + workspace_name: str, + big_data_pool_name: str, + big_data_pool_patch_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BigDataPoolResourceInfo: + """Update a Big Data pool. + + Patch a Big Data 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: + """ @distributed_trace def update( @@ -331,58 +384,74 @@ def update( resource_group_name: str, workspace_name: str, big_data_pool_name: str, - big_data_pool_patch_info: "_models.BigDataPoolPatchInfo", + big_data_pool_patch_info: Union[_models.BigDataPoolPatchInfo, IO], **kwargs: Any - ) -> "_models.BigDataPoolResourceInfo": + ) -> _models.BigDataPoolResourceInfo: """Update a Big Data pool. Patch a Big Data 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param big_data_pool_name: Big Data pool name. + :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. - :type big_data_pool_patch_info: ~azure.mgmt.synapse.models.BigDataPoolPatchInfo - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: 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 - :return: BigDataPoolResourceInfo, or the result of cls(response) + :return: BigDataPoolResourceInfo or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.BigDataPoolResourceInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BigDataPoolResourceInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(big_data_pool_patch_info, 'BigDataPoolPatchInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BigDataPoolResourceInfo] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(big_data_pool_patch_info, (IO, bytes)): + _content = big_data_pool_patch_info + else: + _json = self._serialize.body(big_data_pool_patch_info, "BigDataPoolPatchInfo") request = build_update_request( - subscription_id=self._config.subscription_id, 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, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -390,74 +459,175 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, workspace_name: str, big_data_pool_name: str, - big_data_pool_info: "_models.BigDataPoolResourceInfo", - force: Optional[bool] = False, + big_data_pool_info: Union[_models.BigDataPoolResourceInfo, IO], + force: bool = False, **kwargs: Any - ) -> "_models.BigDataPoolResourceInfo": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BigDataPoolResourceInfo"] + ) -> _models.BigDataPoolResourceInfo: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(big_data_pool_info, 'BigDataPoolResourceInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BigDataPoolResourceInfo] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(big_data_pool_info, (IO, bytes)): + _content = big_data_pool_info + else: + _json = self._serialize.body(big_data_pool_info, "BigDataPoolResourceInfo") + + request = build_create_or_update_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, + force=force, api_version=api_version, content_type=content_type, json=_json, - force=force, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("BigDataPoolResourceInfo", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BigDataPoolResourceInfo', pipeline_response) + deserialized = self._deserialize("BigDataPoolResourceInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + big_data_pool_name: str, + big_data_pool_info: _models.BigDataPoolResourceInfo, + force: bool = False, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BigDataPoolResourceInfo]: + """Create a Big Data pool. + + Create a new Big Data 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 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: ~azure.mgmt.synapse.models.BigDataPoolResourceInfo + :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 JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + big_data_pool_name: str, + big_data_pool_info: IO, + force: bool = False, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BigDataPoolResourceInfo]: + """Create a Big Data pool. + + Create a new Big Data 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 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 + :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] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -465,27 +635,29 @@ def begin_create_or_update( resource_group_name: str, workspace_name: str, big_data_pool_name: str, - big_data_pool_info: "_models.BigDataPoolResourceInfo", - force: Optional[bool] = False, + big_data_pool_info: Union[_models.BigDataPoolResourceInfo, IO], + force: bool = False, **kwargs: Any - ) -> LROPoller["_models.BigDataPoolResourceInfo"]: + ) -> LROPoller[_models.BigDataPoolResourceInfo]: """Create a Big Data pool. Create a new Big Data 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param big_data_pool_name: Big Data pool name. + :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. - :type big_data_pool_info: ~azure.mgmt.synapse.models.BigDataPoolResourceInfo + :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 force: Whether to stop any running jobs in the Big Data pool. Default value is False. :type force: bool - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: 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 @@ -497,19 +669,19 @@ def begin_create_or_update( :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] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BigDataPoolResourceInfo"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BigDataPoolResourceInfo] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, big_data_pool_name=big_data_pool_name, @@ -517,107 +689,108 @@ def begin_create_or_update( force=force, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('BigDataPoolResourceInfo', pipeline_response) + deserialized = self._deserialize("BigDataPoolResourceInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}"} # type: ignore def _delete_initial( - self, - resource_group_name: str, - workspace_name: str, - big_data_pool_name: str, - **kwargs: Any - ) -> Optional[Any]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[Any]] + self, resource_group_name: str, workspace_name: str, big_data_pool_name: str, **kwargs: Any + ) -> Optional[JSON]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[JSON]] + + 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'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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('object', pipeline_response) + deserialized = self._deserialize("object", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('object', pipeline_response) + deserialized = self._deserialize("object", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}"} # type: ignore @distributed_trace def begin_delete( - self, - resource_group_name: str, - workspace_name: str, - big_data_pool_name: str, - **kwargs: Any - ) -> LROPoller[Any]: + self, resource_group_name: str, workspace_name: str, big_data_pool_name: str, **kwargs: Any + ) -> LROPoller[JSON]: """Delete a Big Data pool. Delete a Big Data pool from the workspace. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param big_data_pool_name: Big Data pool name. + :param big_data_pool_name: Big Data pool name. Required. :type big_data_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -626,107 +799,108 @@ def begin_delete( :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either any or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[any] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An instance of LROPoller that returns either JSON or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[JSON] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Any] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[JSON] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, big_data_pool_name=big_data_pool_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('object', pipeline_response) + deserialized = self._deserialize("object", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools/{bigDataPoolName}"} # type: ignore @distributed_trace def list_by_workspace( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> Iterable["_models.BigDataPoolResourceInfoListResult"]: + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> Iterable["_models.BigDataPoolResourceInfo"]: """List the Big Data pools in a workspace. List Big Data pools in a workspace. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BigDataPoolResourceInfoListResult or the result of + :return: An iterator like instance of either BigDataPoolResourceInfo or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.BigDataPoolResourceInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.BigDataPoolResourceInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.BigDataPoolResourceInfoListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BigDataPoolResourceInfoListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore else: - - request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -740,10 +914,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -754,8 +926,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_workspace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools"} # type: ignore + list_by_workspace.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/bigDataPools"} # type: ignore 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 bd4f6351950f..a4b7c55f42d8 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 @@ -6,197 +6,276 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_create_or_update_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, workspace_name: str, sql_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - data_masking_policy_name = kwargs.pop('data_masking_policy_name', "Default") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + data_masking_policy_name = kwargs.pop("data_masking_policy_name", "Default") # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataMaskingPolicies/{dataMaskingPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataMaskingPolicies/{dataMaskingPolicyName}", + ) # 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'), - "dataMaskingPolicyName": _SERIALIZER.url("data_masking_policy_name", data_masking_policy_name, 'str'), + "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"), + "dataMaskingPolicyName": _SERIALIZER.url("data_masking_policy_name", data_masking_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, sql_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - data_masking_policy_name = kwargs.pop('data_masking_policy_name', "Default") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + data_masking_policy_name = kwargs.pop("data_masking_policy_name", "Default") # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataMaskingPolicies/{dataMaskingPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataMaskingPolicies/{dataMaskingPolicyName}", + ) # 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'), - "dataMaskingPolicyName": _SERIALIZER.url("data_masking_policy_name", data_masking_policy_name, 'str'), + "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"), + "dataMaskingPolicyName": _SERIALIZER.url("data_masking_policy_name", data_masking_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class DataMaskingPoliciesOperations(object): - """DataMaskingPoliciesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class DataMaskingPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`data_masking_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: "_models.DataMaskingPolicy", + parameters: _models.DataMaskingPolicy, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DataMaskingPolicy": + ) -> _models.DataMaskingPolicy: """Creates or updates a Sql pool data masking policy. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param parameters: Parameters for creating or updating a data masking policy. + :param parameters: Parameters for creating or updating a data masking policy. Required. :type parameters: ~azure.mgmt.synapse.models.DataMaskingPolicy - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword 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: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataMaskingPolicy: + """Creates or updates a Sql pool data masking policy. + + :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: Parameters for creating or updating a data masking policy. 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 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: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + parameters: Union[_models.DataMaskingPolicy, IO], + **kwargs: Any + ) -> _models.DataMaskingPolicy: + """Creates or updates a Sql pool data masking policy. + + :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: 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 - :return: DataMaskingPolicy, or the result of cls(response) + :return: DataMaskingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.DataMaskingPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataMaskingPolicy"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - data_masking_policy_name = kwargs.pop('data_masking_policy_name', "Default") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + data_masking_policy_name = kwargs.pop("data_masking_policy_name", "Default") # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataMaskingPolicy] - _json = self._serialize.body(parameters, 'DataMaskingPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataMaskingPolicy") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, 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, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -204,71 +283,70 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataMaskingPolicies/{dataMaskingPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataMaskingPolicies/{dataMaskingPolicyName}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> "_models.DataMaskingPolicy": + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> _models.DataMaskingPolicy: """Gets a Sql pool data masking policy. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword 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) + :return: DataMaskingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.DataMaskingPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataMaskingPolicy"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - data_masking_policy_name = kwargs.pop('data_masking_policy_name', "Default") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + data_masking_policy_name = kwargs.pop("data_masking_policy_name", "Default") # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataMaskingPolicy] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -276,12 +354,11 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataMaskingPolicies/{dataMaskingPolicyName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataMaskingPolicies/{dataMaskingPolicyName}"} # 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 383662fd97c1..f43fac7a81a3 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 @@ -6,246 +6,337 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_create_or_update_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, data_masking_rule_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - data_masking_policy_name = kwargs.pop('data_masking_policy_name', "Default") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + data_masking_policy_name = kwargs.pop("data_masking_policy_name", "Default") # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules/{dataMaskingRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules/{dataMaskingRuleName}", + ) # 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'), - "dataMaskingPolicyName": _SERIALIZER.url("data_masking_policy_name", data_masking_policy_name, 'str'), - "dataMaskingRuleName": _SERIALIZER.url("data_masking_rule_name", data_masking_rule_name, 'str'), + "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"), + "dataMaskingPolicyName": _SERIALIZER.url("data_masking_policy_name", data_masking_policy_name, "str"), + "dataMaskingRuleName": _SERIALIZER.url("data_masking_rule_name", data_masking_rule_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, data_masking_rule_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - data_masking_policy_name = kwargs.pop('data_masking_policy_name', "Default") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + data_masking_policy_name = kwargs.pop("data_masking_policy_name", "Default") # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules/{dataMaskingRuleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules/{dataMaskingRuleName}", + ) # 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'), - "dataMaskingPolicyName": _SERIALIZER.url("data_masking_policy_name", data_masking_policy_name, 'str'), - "dataMaskingRuleName": _SERIALIZER.url("data_masking_rule_name", data_masking_rule_name, 'str'), + "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"), + "dataMaskingPolicyName": _SERIALIZER.url("data_masking_policy_name", data_masking_policy_name, "str"), + "dataMaskingRuleName": _SERIALIZER.url("data_masking_rule_name", data_masking_rule_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_sql_pool_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, sql_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - data_masking_policy_name = kwargs.pop('data_masking_policy_name', "Default") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + data_masking_policy_name = kwargs.pop("data_masking_policy_name", "Default") # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules", + ) # 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'), - "dataMaskingPolicyName": _SERIALIZER.url("data_masking_policy_name", data_masking_policy_name, 'str'), + "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"), + "dataMaskingPolicyName": _SERIALIZER.url("data_masking_policy_name", data_masking_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class DataMaskingRulesOperations(object): - """DataMaskingRulesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class DataMaskingRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`data_masking_rules` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, data_masking_rule_name: str, - parameters: "_models.DataMaskingRule", + parameters: _models.DataMaskingRule, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.DataMaskingRule": + ) -> _models.DataMaskingRule: """Creates or updates a Sql pool data masking rule. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param data_masking_rule_name: The name of the data masking rule. + :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. + Required. :type parameters: ~azure.mgmt.synapse.models.DataMaskingRule - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword 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) + :return: DataMaskingRule or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.DataMaskingRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + data_masking_rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DataMaskingRule: + """Creates or updates a Sql pool data masking rule. + + :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 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. + 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 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: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + data_masking_rule_name: str, + parameters: Union[_models.DataMaskingRule, IO], + **kwargs: Any + ) -> _models.DataMaskingRule: + """Creates or updates a Sql pool data masking rule. + + :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 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 + :return: DataMaskingRule or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.DataMaskingRule + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataMaskingRule"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - data_masking_policy_name = kwargs.pop('data_masking_policy_name', "Default") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + data_masking_policy_name = kwargs.pop("data_masking_policy_name", "Default") # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataMaskingRule] - _json = self._serialize.body(parameters, 'DataMaskingRule') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataMaskingRule") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, data_masking_rule_name=data_masking_rule_name, + subscription_id=self._config.subscription_id, api_version=api_version, data_masking_policy_name=data_masking_policy_name, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -254,18 +345,17 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('DataMaskingRule', pipeline_response) + deserialized = self._deserialize("DataMaskingRule", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DataMaskingRule', pipeline_response) + deserialized = self._deserialize("DataMaskingRule", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules/{dataMaskingRuleName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules/{dataMaskingRuleName}"} # type: ignore @distributed_trace def get( @@ -275,57 +365,61 @@ def get( sql_pool_name: str, data_masking_rule_name: str, **kwargs: Any - ) -> "_models.DataMaskingRule": + ) -> _models.DataMaskingRule: """Gets the specific Sql pool data masking rule. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param data_masking_rule_name: The name of the data masking rule. + :param data_masking_rule_name: The name of the data masking rule. Required. :type data_masking_rule_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword 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) + :return: DataMaskingRule or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.DataMaskingRule - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataMaskingRule"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - data_masking_policy_name = kwargs.pop('data_masking_policy_name', "Default") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + data_masking_policy_name = kwargs.pop("data_masking_policy_name", "Default") # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataMaskingRule] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, data_masking_rule_name=data_masking_rule_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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -333,81 +427,73 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules/{dataMaskingRuleName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules/{dataMaskingRuleName}"} # type: ignore @distributed_trace def list_by_sql_pool( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> Iterable["_models.DataMaskingRuleListResult"]: + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> Iterable["_models.DataMaskingRule"]: """Gets a list of Sql pool data masking rules. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword 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 DataMaskingRuleListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.DataMaskingRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - data_masking_policy_name = kwargs.pop('data_masking_policy_name', "Default") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + data_masking_policy_name = kwargs.pop("data_masking_policy_name", "Default") # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataMaskingRuleListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataMaskingRuleListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_sql_pool_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore else: - - request = build_list_by_sql_pool_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - api_version=api_version, - data_masking_policy_name=data_masking_policy_name, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -421,10 +507,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -435,8 +519,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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"} # type: ignore + list_by_sql_pool.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules"} # type: ignore 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 256452d058bf..97795ea84493 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 @@ -6,243 +6,299 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, sql_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - blob_auditing_policy_name = kwargs.pop('blob_auditing_policy_name', "default") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + blob_auditing_policy_name = kwargs.pop("blob_auditing_policy_name", "default") # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/extendedAuditingSettings/{blobAuditingPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/extendedAuditingSettings/{blobAuditingPolicyName}", + ) # 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'), - "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, 'str'), + "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"), + "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, workspace_name: str, sql_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - blob_auditing_policy_name = kwargs.pop('blob_auditing_policy_name', "default") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + blob_auditing_policy_name = kwargs.pop("blob_auditing_policy_name", "default") # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/extendedAuditingSettings/{blobAuditingPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/extendedAuditingSettings/{blobAuditingPolicyName}", + ) # 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'), - "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, 'str'), + "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"), + "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_sql_pool_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, sql_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/extendedAuditingSettings") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/extendedAuditingSettings", + ) # 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'), + "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 = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class ExtendedSqlPoolBlobAuditingPoliciesOperations(object): - """ExtendedSqlPoolBlobAuditingPoliciesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ExtendedSqlPoolBlobAuditingPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`extended_sql_pool_blob_auditing_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> "_models.ExtendedSqlPoolBlobAuditingPolicy": + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> _models.ExtendedSqlPoolBlobAuditingPolicy: """Gets an extended Sql pool's blob auditing policy. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword 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) + :return: ExtendedSqlPoolBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ExtendedSqlPoolBlobAuditingPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtendedSqlPoolBlobAuditingPolicy"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - blob_auditing_policy_name = kwargs.pop('blob_auditing_policy_name', "default") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + blob_auditing_policy_name = kwargs.pop("blob_auditing_policy_name", "default") # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ExtendedSqlPoolBlobAuditingPolicy] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/extendedAuditingSettings/{blobAuditingPolicyName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/extendedAuditingSettings/{blobAuditingPolicyName}"} # type: ignore + @overload + def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + parameters: _models.ExtendedSqlPoolBlobAuditingPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ExtendedSqlPoolBlobAuditingPolicy: + """Creates or updates an extended Sql pool's blob auditing policy. + + :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 extended Sql pool blob auditing policy. Required. + :type parameters: ~azure.mgmt.synapse.models.ExtendedSqlPoolBlobAuditingPolicy + :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: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ExtendedSqlPoolBlobAuditingPolicy: + """Creates or updates an extended Sql pool's blob auditing policy. + + :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 extended Sql pool blob auditing policy. 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 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: + """ @distributed_trace def create_or_update( @@ -250,61 +306,77 @@ def create_or_update( resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: "_models.ExtendedSqlPoolBlobAuditingPolicy", + parameters: Union[_models.ExtendedSqlPoolBlobAuditingPolicy, IO], **kwargs: Any - ) -> "_models.ExtendedSqlPoolBlobAuditingPolicy": + ) -> _models.ExtendedSqlPoolBlobAuditingPolicy: """Creates or updates an extended Sql pool's blob auditing policy. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param parameters: The extended Sql pool blob auditing policy. - :type parameters: ~azure.mgmt.synapse.models.ExtendedSqlPoolBlobAuditingPolicy - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 - :return: ExtendedSqlPoolBlobAuditingPolicy, or the result of cls(response) + :return: ExtendedSqlPoolBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ExtendedSqlPoolBlobAuditingPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtendedSqlPoolBlobAuditingPolicy"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - blob_auditing_policy_name = kwargs.pop('blob_auditing_policy_name', "default") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + blob_auditing_policy_name = kwargs.pop("blob_auditing_policy_name", "default") # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ExtendedSqlPoolBlobAuditingPolicy] - _json = self._serialize.body(parameters, 'ExtendedSqlPoolBlobAuditingPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExtendedSqlPoolBlobAuditingPolicy") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, 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, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -312,78 +384,72 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ExtendedSqlPoolBlobAuditingPolicy', pipeline_response) + deserialized = self._deserialize("ExtendedSqlPoolBlobAuditingPolicy", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ExtendedSqlPoolBlobAuditingPolicy', pipeline_response) + deserialized = self._deserialize("ExtendedSqlPoolBlobAuditingPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/extendedAuditingSettings/{blobAuditingPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/extendedAuditingSettings/{blobAuditingPolicyName}"} # type: ignore @distributed_trace def list_by_sql_pool( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> Iterable["_models.ExtendedSqlPoolBlobAuditingPolicyListResult"]: + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> Iterable["_models.ExtendedSqlPoolBlobAuditingPolicy"]: """Lists extended auditing settings of 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExtendedSqlPoolBlobAuditingPolicyListResult or the - result of cls(response) + :return: An iterator like instance of either ExtendedSqlPoolBlobAuditingPolicy or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.ExtendedSqlPoolBlobAuditingPolicyListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.ExtendedSqlPoolBlobAuditingPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ExtendedSqlPoolBlobAuditingPolicyListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtendedSqlPoolBlobAuditingPolicyListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_sql_pool_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore else: - - request = build_list_by_sql_pool_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -397,10 +463,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -410,8 +474,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_sql_pool.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/extendedAuditingSettings"} # type: ignore + list_by_sql_pool.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/extendedAuditingSettings"} # 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 d623ba3974e8..87b951499f7a 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 @@ -6,191 +6,268 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_regenerate_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, workspace_name: str, integration_runtime_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/regenerateAuthKey") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/regenerateAuthKey", + ) # 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'), - "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, 'str'), + "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"), + "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, integration_runtime_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/listAuthKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/listAuthKeys", + ) # 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'), - "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, 'str'), + "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"), + "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class IntegrationRuntimeAuthKeysOperations(object): - """IntegrationRuntimeAuthKeysOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class IntegrationRuntimeAuthKeysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`integration_runtime_auth_keys` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def regenerate( self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, - regenerate_key_parameters: "_models.IntegrationRuntimeRegenerateKeyParameters", + regenerate_key_parameters: _models.IntegrationRuntimeRegenerateKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.IntegrationRuntimeAuthKeys": + ) -> _models.IntegrationRuntimeAuthKeys: """Regenerate integration runtime authentication key. Regenerate the authentication key for an integration runtime. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :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. + authentication key. Required. :type regenerate_key_parameters: ~azure.mgmt.synapse.models.IntegrationRuntimeRegenerateKeyParameters - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IntegrationRuntimeAuthKeys or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeAuthKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate( + self, + resource_group_name: str, + workspace_name: str, + integration_runtime_name: str, + regenerate_key_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IntegrationRuntimeAuthKeys: + """Regenerate integration runtime authentication key. + + Regenerate the authentication key for an integration runtime. + + :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 integration_runtime_name: Integration runtime name. Required. + :type integration_runtime_name: str + :param regenerate_key_parameters: The parameters for regenerating integration runtime + authentication key. Required. + :type regenerate_key_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: IntegrationRuntimeAuthKeys, or the result of cls(response) + :return: IntegrationRuntimeAuthKeys or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeAuthKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate( + self, + resource_group_name: str, + workspace_name: str, + integration_runtime_name: str, + regenerate_key_parameters: Union[_models.IntegrationRuntimeRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.IntegrationRuntimeAuthKeys: + """Regenerate integration runtime authentication key. + + Regenerate the authentication key for an integration runtime. + + :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 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. + :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 + :return: IntegrationRuntimeAuthKeys or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeAuthKeys + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IntegrationRuntimeAuthKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IntegrationRuntimeAuthKeys] - _json = self._serialize.body(regenerate_key_parameters, 'IntegrationRuntimeRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key_parameters, (IO, bytes)): + _content = regenerate_key_parameters + else: + _json = self._serialize.body(regenerate_key_parameters, "IntegrationRuntimeRegenerateKeyParameters") request = build_regenerate_request( - subscription_id=self._config.subscription_id, 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, content_type=content_type, json=_json, - template_url=self.regenerate.metadata['url'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -198,67 +275,66 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/regenerateAuthKey"} # type: ignore - + regenerate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/regenerateAuthKey"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any - ) -> "_models.IntegrationRuntimeAuthKeys": + self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any + ) -> _models.IntegrationRuntimeAuthKeys: """List integration runtime authentication keys. List authentication keys in an integration runtime. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IntegrationRuntimeAuthKeys, or the result of cls(response) + :return: IntegrationRuntimeAuthKeys or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeAuthKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IntegrationRuntimeAuthKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IntegrationRuntimeAuthKeys] - request = build_list_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -266,12 +342,11 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/listAuthKeys"} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/listAuthKeys"} # 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 a496cd902a73..0afec49cb649 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 @@ -8,133 +8,136 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, integration_runtime_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/getConnectionInfo") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/getConnectionInfo", + ) # 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'), - "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, 'str'), + "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"), + "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class IntegrationRuntimeConnectionInfosOperations(object): - """IntegrationRuntimeConnectionInfosOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class IntegrationRuntimeConnectionInfosOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`integration_runtime_connection_infos` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any - ) -> "_models.IntegrationRuntimeConnectionInfo": + self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any + ) -> _models.IntegrationRuntimeConnectionInfo: """Get integration runtime connection info. Get connection info for an integration runtime. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IntegrationRuntimeConnectionInfo, or the result of cls(response) + :return: IntegrationRuntimeConnectionInfo or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeConnectionInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IntegrationRuntimeConnectionInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IntegrationRuntimeConnectionInfo] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -142,12 +145,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IntegrationRuntimeConnectionInfo', pipeline_response) + deserialized = self._deserialize("IntegrationRuntimeConnectionInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/getConnectionInfo"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/getConnectionInfo"} # 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 b9e529c3667a..86f7d1ffb609 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 @@ -8,89 +8,88 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_sync_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, integration_runtime_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/syncCredentials") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/syncCredentials", + ) # 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'), - "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, 'str'), + "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"), + "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class IntegrationRuntimeCredentialsOperations(object): - """IntegrationRuntimeCredentialsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class IntegrationRuntimeCredentialsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`integration_runtime_credentials` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def sync( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any + self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any ) -> None: """Sync integration runtime credentials. @@ -100,44 +99,48 @@ def sync( # pylint: disable=inconsistent-return-statements import it (preferred) on any self-hosted integration runtime node than using this API directly. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_sync_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -148,5 +151,4 @@ def sync( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - sync.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/syncCredentials"} # type: ignore - + sync.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/syncCredentials"} # 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 da1abc2e8f3e..045cc9ef6095 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 @@ -8,133 +8,136 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, integration_runtime_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/monitoringData") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/monitoringData", + ) # 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'), - "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, 'str'), + "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"), + "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class IntegrationRuntimeMonitoringDataOperations(object): - """IntegrationRuntimeMonitoringDataOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class IntegrationRuntimeMonitoringDataOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`integration_runtime_monitoring_data` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any - ) -> "_models.IntegrationRuntimeMonitoringData": + self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any + ) -> _models.IntegrationRuntimeMonitoringData: """Get integration runtime monitoring data. Get monitoring data for an integration runtime. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IntegrationRuntimeMonitoringData, or the result of cls(response) + :return: IntegrationRuntimeMonitoringData or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeMonitoringData - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IntegrationRuntimeMonitoringData"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IntegrationRuntimeMonitoringData] - request = build_list_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -142,12 +145,11 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/monitoringData"} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/monitoringData"} # 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 d627eebdb35a..c227b68453d0 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 @@ -8,83 +8,90 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, workspace_name: str, integration_runtime_name: str, node_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/nodes/{nodeName}/ipAddress") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/nodes/{nodeName}/ipAddress", + ) # 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'), - "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, 'str'), - "nodeName": _SERIALIZER.url("node_name", node_name, 'str'), + "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"), + "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), + "nodeName": _SERIALIZER.url("node_name", node_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class IntegrationRuntimeNodeIpAddressOperations(object): - """IntegrationRuntimeNodeIpAddressOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class IntegrationRuntimeNodeIpAddressOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`integration_runtime_node_ip_address` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( @@ -94,53 +101,57 @@ def get( integration_runtime_name: str, node_name: str, **kwargs: Any - ) -> "_models.IntegrationRuntimeNodeIpAddress": + ) -> _models.IntegrationRuntimeNodeIpAddress: """Get integration runtime node IP address. Get the IP address of an integration runtime node. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :param node_name: Integration runtime node name. + :param node_name: Integration runtime node name. Required. :type node_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IntegrationRuntimeNodeIpAddress, or the result of cls(response) + :return: IntegrationRuntimeNodeIpAddress or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeNodeIpAddress - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IntegrationRuntimeNodeIpAddress"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IntegrationRuntimeNodeIpAddress] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -148,12 +159,11 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/nodes/{nodeName}/ipAddress"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/nodes/{nodeName}/ipAddress"} # 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 e96d92dcf1d0..e4a13c2080d8 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 @@ -6,174 +6,175 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, workspace_name: str, integration_runtime_name: str, node_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/nodes/{nodeName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/nodes/{nodeName}", + ) # 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'), - "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, 'str'), - "nodeName": _SERIALIZER.url("node_name", node_name, 'str'), + "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"), + "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), + "nodeName": _SERIALIZER.url("node_name", node_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - subscription_id: str, resource_group_name: str, workspace_name: str, integration_runtime_name: str, node_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/nodes/{nodeName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/nodes/{nodeName}", + ) # 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'), - "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, 'str'), - "nodeName": _SERIALIZER.url("node_name", node_name, 'str'), + "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"), + "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), + "nodeName": _SERIALIZER.url("node_name", node_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - subscription_id: str, resource_group_name: str, workspace_name: str, integration_runtime_name: str, node_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/nodes/{nodeName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/nodes/{nodeName}", + ) # 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'), - "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, 'str'), - "nodeName": _SERIALIZER.url("node_name", node_name, 'str'), + "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"), + "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), + "nodeName": _SERIALIZER.url("node_name", node_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class IntegrationRuntimeNodesOperations(object): - """IntegrationRuntimeNodesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class IntegrationRuntimeNodesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`integration_runtime_nodes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( @@ -183,53 +184,57 @@ def get( integration_runtime_name: str, node_name: str, **kwargs: Any - ) -> "_models.SelfHostedIntegrationRuntimeNode": + ) -> _models.SelfHostedIntegrationRuntimeNode: """Get integration runtime node. Get an integration runtime node. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :param node_name: Integration runtime node name. + :param node_name: Integration runtime node name. Required. :type node_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SelfHostedIntegrationRuntimeNode, or the result of cls(response) + :return: SelfHostedIntegrationRuntimeNode or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SelfHostedIntegrationRuntimeNode - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SelfHostedIntegrationRuntimeNode"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SelfHostedIntegrationRuntimeNode] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -237,15 +242,89 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/nodes/{nodeName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/nodes/{nodeName}"} # type: ignore + + @overload + def update( + self, + resource_group_name: str, + workspace_name: str, + integration_runtime_name: str, + node_name: str, + update_integration_runtime_node_request: _models.UpdateIntegrationRuntimeNodeRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SelfHostedIntegrationRuntimeNode: + """Create integration runtime node. + + Create an integration runtime node. + + :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 integration_runtime_name: Integration runtime name. Required. + :type integration_runtime_name: str + :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. Required. + :type update_integration_runtime_node_request: + ~azure.mgmt.synapse.models.UpdateIntegrationRuntimeNodeRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: + """ + + @overload + def update( + self, + resource_group_name: str, + workspace_name: str, + integration_runtime_name: str, + node_name: str, + update_integration_runtime_node_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SelfHostedIntegrationRuntimeNode: + """Create integration runtime node. + + Create an integration runtime node. + :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 integration_runtime_name: Integration runtime name. Required. + :type integration_runtime_name: str + :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. Required. + :type update_integration_runtime_node_request: 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: SelfHostedIntegrationRuntimeNode or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.SelfHostedIntegrationRuntimeNode + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( @@ -254,63 +333,78 @@ def update( workspace_name: str, integration_runtime_name: str, node_name: str, - update_integration_runtime_node_request: "_models.UpdateIntegrationRuntimeNodeRequest", + update_integration_runtime_node_request: Union[_models.UpdateIntegrationRuntimeNodeRequest, IO], **kwargs: Any - ) -> "_models.SelfHostedIntegrationRuntimeNode": + ) -> _models.SelfHostedIntegrationRuntimeNode: """Create integration runtime node. Create an integration runtime node. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :param node_name: Integration runtime node name. + :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. + runtime node. Is either a model type or a IO type. Required. :type update_integration_runtime_node_request: - ~azure.mgmt.synapse.models.UpdateIntegrationRuntimeNodeRequest - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + ~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 - :return: SelfHostedIntegrationRuntimeNode, or the result of cls(response) + :return: SelfHostedIntegrationRuntimeNode or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SelfHostedIntegrationRuntimeNode - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SelfHostedIntegrationRuntimeNode"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SelfHostedIntegrationRuntimeNode] - _json = self._serialize.body(update_integration_runtime_node_request, 'UpdateIntegrationRuntimeNodeRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_integration_runtime_node_request, (IO, bytes)): + _content = update_integration_runtime_node_request + else: + _json = self._serialize.body(update_integration_runtime_node_request, "UpdateIntegrationRuntimeNodeRequest") request = build_update_request( - subscription_id=self._config.subscription_id, 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, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -318,15 +412,14 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/nodes/{nodeName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/nodes/{nodeName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -342,47 +435,51 @@ def delete( # pylint: disable=inconsistent-return-statements Delete an integration runtime node. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :param node_name: Integration runtime node name. + :param node_name: Integration runtime node name. Required. :type node_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -393,5 +490,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/nodes/{nodeName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/nodes/{nodeName}"} # 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 3abf0b7aba49..0af7b79d6dee 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 @@ -6,195 +6,271 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, workspace_name: str, integration_runtime_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/getObjectMetadata") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/getObjectMetadata", + ) # 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'), - "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, 'str'), + "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"), + "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_refresh_request_initial( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_refresh_request( + resource_group_name: str, workspace_name: str, integration_runtime_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/refreshObjectMetadata") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/refreshObjectMetadata", + ) # 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'), - "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, 'str'), + "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"), + "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class IntegrationRuntimeObjectMetadataOperations(object): - """IntegrationRuntimeObjectMetadataOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class IntegrationRuntimeObjectMetadataOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`integration_runtime_object_metadata` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def list( self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, - get_metadata_request: Optional["_models.GetSsisObjectMetadataRequest"] = None, + get_metadata_request: Optional[_models.GetSsisObjectMetadataRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.SsisObjectMetadataListResponse": + ) -> _models.SsisObjectMetadataListResponse: """Get integration runtime object metadata. Get object metadata from an integration runtime. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :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. Default value is None. :type get_metadata_request: ~azure.mgmt.synapse.models.GetSsisObjectMetadataRequest - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SsisObjectMetadataListResponse or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.SsisObjectMetadataListResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list( + self, + resource_group_name: str, + workspace_name: str, + integration_runtime_name: str, + get_metadata_request: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SsisObjectMetadataListResponse: + """Get integration runtime object metadata. + + Get object metadata from an integration runtime. + + :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 integration_runtime_name: Integration runtime name. Required. + :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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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) + :return: SsisObjectMetadataListResponse or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SsisObjectMetadataListResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list( + self, + resource_group_name: str, + workspace_name: str, + integration_runtime_name: str, + get_metadata_request: Optional[Union[_models.GetSsisObjectMetadataRequest, IO]] = None, + **kwargs: Any + ) -> _models.SsisObjectMetadataListResponse: + """Get integration runtime object metadata. + + Get object metadata from an integration runtime. + + :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 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 + :return: SsisObjectMetadataListResponse or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.SsisObjectMetadataListResponse + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SsisObjectMetadataListResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SsisObjectMetadataListResponse] - if get_metadata_request is not None: - _json = self._serialize.body(get_metadata_request, 'GetSsisObjectMetadataRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(get_metadata_request, (IO, bytes)): + _content = get_metadata_request else: - _json = None + if get_metadata_request is not None: + _json = self._serialize.body(get_metadata_request, "GetSsisObjectMetadataRequest") + else: + _json = None request = build_list_request( - subscription_id=self._config.subscription_id, 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, content_type=content_type, json=_json, - template_url=self.list.metadata['url'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -202,87 +278,82 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/getObjectMetadata"} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/getObjectMetadata"} # type: ignore def _refresh_initial( - self, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any - ) -> Optional["_models.SsisObjectMetadataStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.SsisObjectMetadataStatusResponse"]] + self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any + ) -> Optional[_models.SsisObjectMetadataStatusResponse]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_refresh_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SsisObjectMetadataStatusResponse]] + + 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'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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 = self._deserialize("SsisObjectMetadataStatusResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _refresh_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/refreshObjectMetadata"} # type: ignore - + _refresh_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/refreshObjectMetadata"} # type: ignore @distributed_trace def begin_refresh( - self, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any - ) -> LROPoller["_models.SsisObjectMetadataStatusResponse"]: + self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any + ) -> LROPoller[_models.SsisObjectMetadataStatusResponse]: """Refresh integration runtime object metadata. Refresh the object metadata in an integration runtime. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -295,45 +366,48 @@ def begin_refresh( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.SsisObjectMetadataStatusResponse] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SsisObjectMetadataStatusResponse"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SsisObjectMetadataStatusResponse] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._refresh_initial( + raw_result = self._refresh_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('SsisObjectMetadataStatusResponse', pipeline_response) + deserialized = self._deserialize("SsisObjectMetadataStatusResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_refresh.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/refreshObjectMetadata"} # type: ignore + begin_refresh.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/refreshObjectMetadata"} # 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 135e5c156fd0..62763f23ac65 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 @@ -8,133 +8,136 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, integration_runtime_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/getStatus") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/getStatus", + ) # 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'), - "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, 'str'), + "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"), + "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class IntegrationRuntimeStatusOperations(object): - """IntegrationRuntimeStatusOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class IntegrationRuntimeStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`integration_runtime_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any - ) -> "_models.IntegrationRuntimeStatusResponse": + self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any + ) -> _models.IntegrationRuntimeStatusResponse: """Get integration runtime status. Get the integration runtime status. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IntegrationRuntimeStatusResponse, or the result of cls(response) + :return: IntegrationRuntimeStatusResponse or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeStatusResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IntegrationRuntimeStatusResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IntegrationRuntimeStatusResponse] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -142,12 +145,11 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/getStatus"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/getStatus"} # 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 4e1445acdbec..c2485b7ccc49 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,548 +6,595 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_update_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, workspace_name: str, integration_runtime_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}", + ) # 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'), - "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, 'str'), + "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"), + "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, resource_group_name: str, workspace_name: str, integration_runtime_name: str, + subscription_id: str, *, if_none_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}", + ) # 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'), - "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, 'str'), + "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"), + "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_none_match is not None: - _header_parameters['If-None-Match'] = _SERIALIZER.header("if_none_match", if_none_match, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, +def build_create_request( resource_group_name: str, workspace_name: str, integration_runtime_name: str, + subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}", + ) # 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'), - "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, 'str'), + "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"), + "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - _header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, workspace_name: str, integration_runtime_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}", + ) # 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'), - "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, 'str'), + "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"), + "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_upgrade_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, integration_runtime_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/upgrade") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/upgrade", + ) # 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'), - "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, 'str'), + "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"), + "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_workspace_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes", + ) # 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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_start_request_initial( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any +def build_start_request( + resource_group_name: str, workspace_name: str, integration_runtime_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/start") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/start", + ) # 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'), - "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, 'str'), + "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"), + "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_stop_request_initial( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any +def build_stop_request( + resource_group_name: str, workspace_name: str, integration_runtime_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/stop") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/stop", + ) # 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'), - "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, 'str'), + "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"), + "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_outbound_network_dependencies_endpoints_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, integration_runtime_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/outboundNetworkDependenciesEndpoints") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/outboundNetworkDependenciesEndpoints", + ) # 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'), - "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, 'str'), + "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"), + "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_enable_interactive_query_request_initial( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any +def build_enable_interactive_query_request( + resource_group_name: str, workspace_name: str, integration_runtime_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/enableInteractiveQuery") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/enableInteractiveQuery", + ) # 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'), - "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, 'str'), + "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"), + "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_disable_interactive_query_request_initial( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any +def build_disable_interactive_query_request( + resource_group_name: str, workspace_name: str, integration_runtime_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/disableInteractiveQuery") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/disableInteractiveQuery", + ) # 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'), - "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, 'str'), + "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"), + "integrationRuntimeName": _SERIALIZER.url("integration_runtime_name", integration_runtime_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class IntegrationRuntimesOperations(object): - """IntegrationRuntimesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class IntegrationRuntimesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`integration_runtimes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def update( self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, - update_integration_runtime_request: "_models.UpdateIntegrationRuntimeRequest", + update_integration_runtime_request: _models.UpdateIntegrationRuntimeRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.IntegrationRuntimeResource": + ) -> _models.IntegrationRuntimeResource: """Update integration runtime. Update an integration runtime. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :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. + Required. :type update_integration_runtime_request: ~azure.mgmt.synapse.models.UpdateIntegrationRuntimeRequest - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IntegrationRuntimeResource or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + workspace_name: str, + integration_runtime_name: str, + update_integration_runtime_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IntegrationRuntimeResource: + """Update integration runtime. + + Update an integration runtime. + + :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 integration_runtime_name: Integration runtime name. Required. + :type integration_runtime_name: str + :param update_integration_runtime_request: The parameters for updating an integration runtime. + Required. + :type update_integration_runtime_request: 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: IntegrationRuntimeResource or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + workspace_name: str, + integration_runtime_name: str, + update_integration_runtime_request: Union[_models.UpdateIntegrationRuntimeRequest, IO], + **kwargs: Any + ) -> _models.IntegrationRuntimeResource: + """Update integration runtime. + + Update an integration runtime. + + :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 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. + :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 - :return: IntegrationRuntimeResource, or the result of cls(response) + :return: IntegrationRuntimeResource or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IntegrationRuntimeResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IntegrationRuntimeResource] - _json = self._serialize.body(update_integration_runtime_request, 'UpdateIntegrationRuntimeRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_integration_runtime_request, (IO, bytes)): + _content = update_integration_runtime_request + else: + _json = self._serialize.body(update_integration_runtime_request, "UpdateIntegrationRuntimeRequest") request = build_update_request( - subscription_id=self._config.subscription_id, 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, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -555,15 +602,14 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}"} # type: ignore @distributed_trace def get( @@ -573,55 +619,59 @@ def get( integration_runtime_name: str, if_none_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.IntegrationRuntimeResource"]: + ) -> Optional[_models.IntegrationRuntimeResource]: """Get integration runtime. Get an integration runtime. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str :param if_none_match: ETag of the integration runtime entity. Should only be specified for 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 api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IntegrationRuntimeResource, or the result of cls(response) + :return: IntegrationRuntimeResource or None or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeResource or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.IntegrationRuntimeResource"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.IntegrationRuntimeResource]] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_none_match=if_none_match, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 304]: @@ -631,72 +681,177 @@ def get( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('IntegrationRuntimeResource', pipeline_response) + deserialized = self._deserialize("IntegrationRuntimeResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}"} # type: ignore def _create_initial( self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, - integration_runtime: "_models.IntegrationRuntimeResource", + integration_runtime: Union[_models.IntegrationRuntimeResource, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> Optional["_models.IntegrationRuntimeResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.IntegrationRuntimeResource"]] + ) -> Optional[_models.IntegrationRuntimeResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(integration_runtime, 'IntegrationRuntimeResource') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.IntegrationRuntimeResource]] - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(integration_runtime, (IO, bytes)): + _content = integration_runtime + else: + _json = self._serialize.body(integration_runtime, "IntegrationRuntimeResource") + + request = build_create_request( resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, + subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self._create_initial.metadata['url'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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 = self._deserialize("IntegrationRuntimeResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}"} # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + workspace_name: str, + integration_runtime_name: str, + integration_runtime: _models.IntegrationRuntimeResource, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IntegrationRuntimeResource]: + """Create integration runtime. + + Create an integration runtime. + + :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 integration_runtime_name: Integration runtime name. Required. + :type integration_runtime_name: str + :param integration_runtime: Integration runtime resource definition. Required. + :type integration_runtime: ~azure.mgmt.synapse.models.IntegrationRuntimeResource + :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. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + workspace_name: str, + integration_runtime_name: str, + integration_runtime: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IntegrationRuntimeResource]: + """Create integration runtime. + + Create an integration runtime. + :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 integration_runtime_name: Integration runtime name. Required. + :type integration_runtime_name: str + :param integration_runtime: Integration runtime resource definition. Required. + :type integration_runtime: IO + :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. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -704,29 +859,31 @@ def begin_create( resource_group_name: str, workspace_name: str, integration_runtime_name: str, - integration_runtime: "_models.IntegrationRuntimeResource", + integration_runtime: Union[_models.IntegrationRuntimeResource, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> LROPoller["_models.IntegrationRuntimeResource"]: + ) -> LROPoller[_models.IntegrationRuntimeResource]: """Create integration runtime. Create an integration runtime. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :param integration_runtime: Integration runtime resource definition. - :type integration_runtime: ~azure.mgmt.synapse.models.IntegrationRuntimeResource + :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 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 api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: 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 @@ -738,19 +895,19 @@ def begin_create( :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] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IntegrationRuntimeResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IntegrationRuntimeResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, @@ -758,98 +915,97 @@ def begin_create( if_match=if_match, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IntegrationRuntimeResource', pipeline_response) + deserialized = self._deserialize("IntegrationRuntimeResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any + self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + 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'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete integration runtime. Delete an integration runtime. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -860,97 +1016,101 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}"} # type: ignore @distributed_trace def upgrade( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any + self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any ) -> None: """Upgrade integration runtime. Upgrade an integration runtime. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_upgrade_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -961,64 +1121,60 @@ def upgrade( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - upgrade.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/upgrade"} # type: ignore - + upgrade.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/upgrade"} # type: ignore @distributed_trace def list_by_workspace( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> Iterable["_models.IntegrationRuntimeListResponse"]: + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> Iterable["_models.IntegrationRuntimeResource"]: """List integration runtimes. List all integration runtimes. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IntegrationRuntimeListResponse or the result of + :return: An iterator like instance of either IntegrationRuntimeResource or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.IntegrationRuntimeListResponse] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.IntegrationRuntimeResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IntegrationRuntimeListResponse] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IntegrationRuntimeListResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore else: - - request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1032,10 +1188,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1046,83 +1200,77 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_workspace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes"} # type: ignore + list_by_workspace.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes"} # type: ignore def _start_initial( - self, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any - ) -> Optional["_models.IntegrationRuntimeStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.IntegrationRuntimeStatusResponse"]] + self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any + ) -> Optional[_models.IntegrationRuntimeStatusResponse]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_start_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.IntegrationRuntimeStatusResponse]] + + 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'], + template_url=self._start_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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 = self._deserialize("IntegrationRuntimeStatusResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/start"} # type: ignore - + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/start"} # type: ignore @distributed_trace def begin_start( - self, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any - ) -> LROPoller["_models.IntegrationRuntimeStatusResponse"]: + self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any + ) -> LROPoller[_models.IntegrationRuntimeStatusResponse]: """Start integration runtime. Start an integration runtime. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1135,114 +1283,113 @@ def begin_start( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.IntegrationRuntimeStatusResponse] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IntegrationRuntimeStatusResponse"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IntegrationRuntimeStatusResponse] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IntegrationRuntimeStatusResponse', pipeline_response) + deserialized = self._deserialize("IntegrationRuntimeStatusResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/start"} # type: ignore + begin_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/start"} # type: ignore def _stop_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any + self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_stop_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + 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'], + template_url=self._stop_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/stop"} # type: ignore - + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/stop"} # type: ignore @distributed_trace - def begin_stop( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any + def begin_stop( + self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any ) -> LROPoller[None]: """Stop integration runtime. Stop an integration runtime. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1253,99 +1400,105 @@ def begin_stop( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._stop_initial( + raw_result = self._stop_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/stop"} # type: ignore + begin_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/stop"} # type: ignore @distributed_trace def list_outbound_network_dependencies_endpoints( - self, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any - ) -> "_models.IntegrationRuntimeOutboundNetworkDependenciesEndpointsResponse": + 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. Gets the list of outbound network dependencies for a given Azure-SSIS integration runtime. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IntegrationRuntimeOutboundNetworkDependenciesEndpointsResponse, or the result of + :return: IntegrationRuntimeOutboundNetworkDependenciesEndpointsResponse or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IntegrationRuntimeOutboundNetworkDependenciesEndpointsResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IntegrationRuntimeOutboundNetworkDependenciesEndpointsResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop( + "cls", None + ) # type: ClsType[_models.IntegrationRuntimeOutboundNetworkDependenciesEndpointsResponse] - request = build_list_outbound_network_dependencies_endpoints_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.list_outbound_network_dependencies_endpoints.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1353,79 +1506,76 @@ def list_outbound_network_dependencies_endpoints( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('IntegrationRuntimeOutboundNetworkDependenciesEndpointsResponse', pipeline_response) + deserialized = self._deserialize( + "IntegrationRuntimeOutboundNetworkDependenciesEndpointsResponse", pipeline_response + ) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_outbound_network_dependencies_endpoints.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/outboundNetworkDependenciesEndpoints"} # type: ignore - + list_outbound_network_dependencies_endpoints.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/outboundNetworkDependenciesEndpoints"} # type: ignore def _enable_interactive_query_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any + self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_enable_interactive_query_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + 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'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _enable_interactive_query_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/enableInteractiveQuery"} # type: ignore - + _enable_interactive_query_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/enableInteractiveQuery"} # type: ignore @distributed_trace - def begin_enable_interactive_query( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any + def begin_enable_interactive_query( + self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any ) -> LROPoller[None]: """Enable interactive query in integration runtime. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1436,109 +1586,109 @@ def begin_enable_interactive_query( # pylint: disable=inconsistent-return-state Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._enable_interactive_query_initial( + raw_result = self._enable_interactive_query_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_enable_interactive_query.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/enableInteractiveQuery"} # type: ignore + begin_enable_interactive_query.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/enableInteractiveQuery"} # type: ignore def _disable_interactive_query_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any + self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_disable_interactive_query_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + 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'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _disable_interactive_query_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/disableInteractiveQuery"} # type: ignore - + _disable_interactive_query_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/disableInteractiveQuery"} # type: ignore @distributed_trace - def begin_disable_interactive_query( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - integration_runtime_name: str, - **kwargs: Any + def begin_disable_interactive_query( + self, resource_group_name: str, workspace_name: str, integration_runtime_name: str, **kwargs: Any ) -> LROPoller[None]: """Disable interactive query in integration runtime. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param integration_runtime_name: Integration runtime name. + :param integration_runtime_name: Integration runtime name. Required. :type integration_runtime_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1549,42 +1699,46 @@ def begin_disable_interactive_query( # pylint: disable=inconsistent-return-stat Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._disable_interactive_query_initial( + raw_result = self._disable_interactive_query_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, integration_runtime_name=integration_runtime_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_disable_interactive_query.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/disableInteractiveQuery"} # type: ignore + begin_disable_interactive_query.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/integrationRuntimes/{integrationRuntimeName}/disableInteractiveQuery"} # 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 1fb2c31d48dd..1dadbc2c2399 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 @@ -6,305 +6,285 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_by_workspace_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/firewallRules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/firewallRules", + ) # 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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - rule_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, workspace_name: str, rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/firewallRules/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/firewallRules/{ruleName}", + ) # 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'), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), + "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"), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - rule_name: str, - **kwargs: Any + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, workspace_name: str, rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/firewallRules/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/firewallRules/{ruleName}", + ) # 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'), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), + "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"), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - rule_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/firewallRules/{ruleName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/firewallRules/{ruleName}", + ) # 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'), - "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), + "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"), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_replace_all_request_initial( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_replace_all_request( + resource_group_name: str, workspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/replaceAllIpFirewallRules") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/replaceAllIpFirewallRules", + ) # 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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - -class IpFirewallRulesOperations(object): - """IpFirewallRulesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class IpFirewallRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`ip_firewall_rules` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_workspace( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> Iterable["_models.IpFirewallRuleInfoListResult"]: + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> Iterable["_models.IpFirewallRuleInfo"]: """Returns a list of firewall rules. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IpFirewallRuleInfoListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.IpFirewallRuleInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IpFirewallRuleInfoListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IpFirewallRuleInfoListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore else: - - request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -318,10 +298,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -332,69 +310,159 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_workspace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/firewallRules"} # type: ignore + list_by_workspace.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/firewallRules"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, workspace_name: str, rule_name: str, - ip_firewall_rule_info: "_models.IpFirewallRuleInfo", + ip_firewall_rule_info: Union[_models.IpFirewallRuleInfo, IO], **kwargs: Any - ) -> Optional["_models.IpFirewallRuleInfo"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.IpFirewallRuleInfo"]] + ) -> Optional[_models.IpFirewallRuleInfo]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(ip_firewall_rule_info, 'IpFirewallRuleInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.IpFirewallRuleInfo]] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(ip_firewall_rule_info, (IO, bytes)): + _content = ip_firewall_rule_info + else: + _json = self._serialize.body(ip_firewall_rule_info, "IpFirewallRuleInfo") + + request = build_create_or_update_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, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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 = self._deserialize("IpFirewallRuleInfo", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('IpFirewallRuleInfo', pipeline_response) + deserialized = self._deserialize("IpFirewallRuleInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/firewallRules/{ruleName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/firewallRules/{ruleName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + rule_name: str, + ip_firewall_rule_info: _models.IpFirewallRuleInfo, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IpFirewallRuleInfo]: + """Creates or updates a firewall rule. + + :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 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: ~azure.mgmt.synapse.models.IpFirewallRuleInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + rule_name: str, + ip_firewall_rule_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.IpFirewallRuleInfo]: + """Creates or updates a firewall rule. + + :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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -402,22 +470,24 @@ def begin_create_or_update( resource_group_name: str, workspace_name: str, rule_name: str, - ip_firewall_rule_info: "_models.IpFirewallRuleInfo", + ip_firewall_rule_info: Union[_models.IpFirewallRuleInfo, IO], **kwargs: Any - ) -> LROPoller["_models.IpFirewallRuleInfo"]: + ) -> LROPoller[_models.IpFirewallRuleInfo]: """Creates or updates a firewall rule. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param rule_name: The IP firewall rule name. + :param rule_name: The IP firewall rule name. Required. :type rule_name: str - :param ip_firewall_rule_info: IP firewall rule properties. - :type ip_firewall_rule_info: ~azure.mgmt.synapse.models.IpFirewallRuleInfo - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 @@ -429,121 +499,122 @@ def begin_create_or_update( :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] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.IpFirewallRuleInfo"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IpFirewallRuleInfo] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, rule_name=rule_name, ip_firewall_rule_info=ip_firewall_rule_info, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('IpFirewallRuleInfo', pipeline_response) + deserialized = self._deserialize("IpFirewallRuleInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/firewallRules/{ruleName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/firewallRules/{ruleName}"} # type: ignore def _delete_initial( - self, - resource_group_name: str, - workspace_name: str, - rule_name: str, - **kwargs: Any - ) -> Optional[Any]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[Any]] + self, resource_group_name: str, workspace_name: str, rule_name: str, **kwargs: Any + ) -> Optional[JSON]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[JSON]] + + 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'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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('object', pipeline_response) + deserialized = self._deserialize("object", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/firewallRules/{ruleName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/firewallRules/{ruleName}"} # type: ignore @distributed_trace def begin_delete( - self, - resource_group_name: str, - workspace_name: str, - rule_name: str, - **kwargs: Any - ) -> LROPoller[Any]: + self, resource_group_name: str, workspace_name: str, rule_name: str, **kwargs: Any + ) -> LROPoller[JSON]: """Deletes a firewall rule. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param rule_name: The IP firewall rule name. + :param rule_name: The IP firewall rule name. Required. :type rule_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -552,100 +623,105 @@ def begin_delete( :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either any or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[any] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An instance of LROPoller that returns either JSON or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[JSON] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Any] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[JSON] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, rule_name=rule_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('object', pipeline_response) + deserialized = self._deserialize("object", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/firewallRules/{ruleName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/firewallRules/{ruleName}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - workspace_name: str, - rule_name: str, - **kwargs: Any - ) -> "_models.IpFirewallRuleInfo": + self, resource_group_name: str, workspace_name: str, rule_name: str, **kwargs: Any + ) -> _models.IpFirewallRuleInfo: """Get a firewall rule. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param rule_name: The IP firewall rule name. + :param rule_name: The IP firewall rule name. Required. :type rule_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: IpFirewallRuleInfo, or the result of cls(response) + :return: IpFirewallRuleInfo or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.IpFirewallRuleInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IpFirewallRuleInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.IpFirewallRuleInfo] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -653,88 +729,177 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/firewallRules/{ruleName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/firewallRules/{ruleName}"} # type: ignore def _replace_all_initial( self, resource_group_name: str, workspace_name: str, - request: "_models.ReplaceAllIpFirewallRulesRequest", + request: Union[_models.ReplaceAllIpFirewallRulesRequest, IO], **kwargs: Any - ) -> Optional["_models.ReplaceAllFirewallRulesOperationResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ReplaceAllFirewallRulesOperationResponse"]] + ) -> Optional[_models.ReplaceAllFirewallRulesOperationResponse]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(request, 'ReplaceAllIpFirewallRulesRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ReplaceAllFirewallRulesOperationResponse]] - request = build_replace_all_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(request, (IO, bytes)): + _content = request + else: + _json = self._serialize.body(request, "ReplaceAllIpFirewallRulesRequest") + + request = build_replace_all_request( resource_group_name=resource_group_name, workspace_name=workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._replace_all_initial.metadata['url'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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 = self._deserialize("ReplaceAllFirewallRulesOperationResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _replace_all_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/replaceAllIpFirewallRules"} # type: ignore + _replace_all_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/replaceAllIpFirewallRules"} # type: ignore + + @overload + def begin_replace_all( + self, + resource_group_name: str, + workspace_name: str, + request: _models.ReplaceAllIpFirewallRulesRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ReplaceAllFirewallRulesOperationResponse]: + """Replaces firewall rules. + + :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 request: Replace all IP firewall rules request. Required. + :type request: ~azure.mgmt.synapse.models.ReplaceAllIpFirewallRulesRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: + ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.ReplaceAllFirewallRulesOperationResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def begin_replace_all( + self, + resource_group_name: str, + workspace_name: str, + request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ReplaceAllFirewallRulesOperationResponse]: + """Replaces firewall rules. + + :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 request: Replace all IP firewall rules request. Required. + :type request: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ReplaceAllFirewallRulesOperationResponse + or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.ReplaceAllFirewallRulesOperationResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_replace_all( self, resource_group_name: str, workspace_name: str, - request: "_models.ReplaceAllIpFirewallRulesRequest", + request: Union[_models.ReplaceAllIpFirewallRulesRequest, IO], **kwargs: Any - ) -> LROPoller["_models.ReplaceAllFirewallRulesOperationResponse"]: + ) -> LROPoller[_models.ReplaceAllFirewallRulesOperationResponse]: """Replaces firewall rules. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param request: Replace all IP firewall rules request. - :type request: ~azure.mgmt.synapse.models.ReplaceAllIpFirewallRulesRequest - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 @@ -747,47 +912,52 @@ def begin_replace_all( or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.ReplaceAllFirewallRulesOperationResponse] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReplaceAllFirewallRulesOperationResponse"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ReplaceAllFirewallRulesOperationResponse] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._replace_all_initial( + raw_result = self._replace_all_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, request=request, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ReplaceAllFirewallRulesOperationResponse', pipeline_response) + deserialized = self._deserialize("ReplaceAllFirewallRulesOperationResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_replace_all.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/replaceAllIpFirewallRules"} # type: ignore + begin_replace_all.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/replaceAllIpFirewallRules"} # 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 c0e078b8205d..5d9d86a72b28 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 @@ -6,258 +6,241 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_by_workspace_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/keys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/keys", + ) # 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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - key_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, key_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/keys/{keyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/keys/{keyName}", + ) # 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'), - "keyName": _SERIALIZER.url("key_name", key_name, 'str'), + "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"), + "keyName": _SERIALIZER.url("key_name", key_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - key_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, workspace_name: str, key_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/keys/{keyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/keys/{keyName}", + ) # 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'), - "keyName": _SERIALIZER.url("key_name", key_name, 'str'), + "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"), + "keyName": _SERIALIZER.url("key_name", key_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - key_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, key_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/keys/{keyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/keys/{keyName}", + ) # 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'), - "keyName": _SERIALIZER.url("key_name", key_name, 'str'), + "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"), + "keyName": _SERIALIZER.url("key_name", key_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class KeysOperations(object): - """KeysOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class KeysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`keys` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_workspace( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> Iterable["_models.KeyInfoListResult"]: + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> Iterable["_models.Key"]: """Returns a list of keys in a workspace. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either KeyInfoListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.KeyInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.KeyInfoListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.KeyInfoListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore else: - - request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -271,10 +254,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -285,61 +266,57 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_workspace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/keys"} # type: ignore + list_by_workspace.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/keys"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - workspace_name: str, - key_name: str, - **kwargs: Any - ) -> "_models.Key": + def get(self, resource_group_name: str, workspace_name: str, key_name: str, **kwargs: Any) -> _models.Key: """Gets a workspace key. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param key_name: The name of the workspace key. + :param key_name: The name of the workspace key. Required. :type key_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Key, or the result of cls(response) + :return: Key or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.Key - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Key"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Key] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -347,15 +324,76 @@ def get( 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/keys/{keyName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/keys/{keyName}"} # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + key_name: str, + key_properties: _models.Key, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Key: + """Creates or updates a workspace key. + + :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 key_name: The name of the workspace key. Required. + :type key_name: str + :param key_properties: Key put request properties. Required. + :type key_properties: ~azure.mgmt.synapse.models.Key + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: + """ + @overload + def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + key_name: str, + key_properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Key: + """Creates or updates a workspace key. + + :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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: + """ @distributed_trace def create_or_update( @@ -363,56 +401,72 @@ def create_or_update( resource_group_name: str, workspace_name: str, key_name: str, - key_properties: "_models.Key", + key_properties: Union[_models.Key, IO], **kwargs: Any - ) -> "_models.Key": + ) -> _models.Key: """Creates or updates a workspace key. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param key_name: The name of the workspace key. + :param key_name: The name of the workspace key. Required. :type key_name: str - :param key_properties: Key put request properties. - :type key_properties: ~azure.mgmt.synapse.models.Key - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :param key_properties: Key put request properties. Is either a model type or a IO 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 - :return: Key, or the result of cls(response) + :return: Key or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.Key - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Key"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(key_properties, 'Key') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Key] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(key_properties, (IO, bytes)): + _content = key_properties + else: + _json = self._serialize.body(key_properties, "Key") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, key_name=key_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -420,65 +474,64 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/keys/{keyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/keys/{keyName}"} # type: ignore @distributed_trace def delete( - self, - resource_group_name: str, - workspace_name: str, - key_name: str, - **kwargs: Any - ) -> Optional["_models.Key"]: + self, resource_group_name: str, workspace_name: str, key_name: str, **kwargs: Any + ) -> Optional[_models.Key]: """Deletes a workspace key. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param key_name: The name of the workspace key. + :param key_name: The name of the workspace key. Required. :type key_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Key, or the result of cls(response) + :return: Key or None or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.Key or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Key"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.Key]] - request = build_delete_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -488,12 +541,11 @@ def delete( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('Key', pipeline_response) + deserialized = self._deserialize("Key", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/keys/{keyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/keys/{keyName}"} # 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 4a25bb62a7c5..9b4c11b8eaf6 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 @@ -8,111 +8,110 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - accept = "application/json" +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Synapse/kustooperations") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class KustoOperationsOperations(object): - """KustoOperationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class KustoOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`kusto_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists available operations for the Kusto sub-resources inside Microsoft.Synapse provider. - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -126,10 +125,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -140,8 +137,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Synapse/kustooperations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Synapse/kustooperations"} # type: ignore 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 a58557835dd7..373446ffa9d3 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 @@ -6,275 +6,272 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_by_kusto_pool_request( - workspace_name: str, - kusto_pool_name: str, - subscription_id: str, - resource_group_name: str, - **kwargs: Any + workspace_name: str, kusto_pool_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations", + ) # pylint: disable=line-too-long path_format_arguments = { - "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), - "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, 'str'), - "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"), + "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( workspace_name: str, kusto_pool_name: str, attached_database_configuration_name: str, - subscription_id: str, resource_group_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), - "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, 'str'), - "attachedDatabaseConfigurationName": _SERIALIZER.url("attached_database_configuration_name", attached_database_configuration_name, 'str'), - "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"), + "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), + "attachedDatabaseConfigurationName": _SERIALIZER.url( + "attached_database_configuration_name", attached_database_configuration_name, "str" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( +def build_create_or_update_request( workspace_name: str, kusto_pool_name: str, attached_database_configuration_name: str, - subscription_id: str, resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), - "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, 'str'), - "attachedDatabaseConfigurationName": _SERIALIZER.url("attached_database_configuration_name", attached_database_configuration_name, 'str'), - "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"), + "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), + "attachedDatabaseConfigurationName": _SERIALIZER.url( + "attached_database_configuration_name", attached_database_configuration_name, "str" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( +def build_delete_request( workspace_name: str, kusto_pool_name: str, attached_database_configuration_name: str, - subscription_id: str, resource_group_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), - "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, 'str'), - "attachedDatabaseConfigurationName": _SERIALIZER.url("attached_database_configuration_name", attached_database_configuration_name, 'str'), - "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"), + "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), + "attachedDatabaseConfigurationName": _SERIALIZER.url( + "attached_database_configuration_name", attached_database_configuration_name, "str" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class KustoPoolAttachedDatabaseConfigurationsOperations(object): - """KustoPoolAttachedDatabaseConfigurationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class KustoPoolAttachedDatabaseConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`kusto_pool_attached_database_configurations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_kusto_pool( - self, - workspace_name: str, - kusto_pool_name: str, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.AttachedDatabaseConfigurationListResult"]: + self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.AttachedDatabaseConfiguration"]: """Returns the list of attached database configurations of the given Kusto Pool. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AttachedDatabaseConfigurationListResult or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.AttachedDatabaseConfigurationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either AttachedDatabaseConfiguration or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.AttachedDatabaseConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AttachedDatabaseConfigurationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AttachedDatabaseConfigurationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_kusto_pool_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore else: - - request = build_list_by_kusto_pool_request( - workspace_name=workspace_name, - kusto_pool_name=kusto_pool_name, - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -288,10 +285,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -302,11 +297,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_kusto_pool.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations"} # type: ignore + list_by_kusto_pool.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations"} # type: ignore @distributed_trace def get( @@ -316,51 +309,56 @@ def get( attached_database_configuration_name: str, resource_group_name: str, **kwargs: Any - ) -> "_models.AttachedDatabaseConfiguration": + ) -> _models.AttachedDatabaseConfiguration: """Returns an attached database configuration. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str :param attached_database_configuration_name: The name of the attached database configuration. + Required. :type attached_database_configuration_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AttachedDatabaseConfiguration, or the result of cls(response) + :return: AttachedDatabaseConfiguration or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.AttachedDatabaseConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AttachedDatabaseConfiguration"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AttachedDatabaseConfiguration] - request = build_get_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, attached_database_configuration_name=attached_database_configuration_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -368,15 +366,14 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}"} # type: ignore def _create_or_update_initial( self, @@ -384,61 +381,161 @@ def _create_or_update_initial( kusto_pool_name: str, attached_database_configuration_name: str, resource_group_name: str, - parameters: "_models.AttachedDatabaseConfiguration", + parameters: Union[_models.AttachedDatabaseConfiguration, IO], **kwargs: Any - ) -> "_models.AttachedDatabaseConfiguration": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AttachedDatabaseConfiguration"] + ) -> _models.AttachedDatabaseConfiguration: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AttachedDatabaseConfiguration] - _json = self._serialize.body(parameters, 'AttachedDatabaseConfiguration') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AttachedDatabaseConfiguration") - request = build_create_or_update_request_initial( + request = build_create_or_update_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, attached_database_configuration_name=attached_database_configuration_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("AttachedDatabaseConfiguration", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AttachedDatabaseConfiguration', pipeline_response) + deserialized = self._deserialize("AttachedDatabaseConfiguration", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('AttachedDatabaseConfiguration', pipeline_response) + deserialized = self._deserialize("AttachedDatabaseConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}"} # type: ignore + @overload + def begin_create_or_update( + self, + workspace_name: str, + kusto_pool_name: str, + attached_database_configuration_name: str, + resource_group_name: str, + parameters: _models.AttachedDatabaseConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AttachedDatabaseConfiguration]: + """Creates or updates an attached database configuration. + + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param kusto_pool_name: The name of the Kusto pool. Required. + :type kusto_pool_name: str + :param attached_database_configuration_name: The name of the attached database configuration. + Required. + :type attached_database_configuration_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: The database parameters supplied to the CreateOrUpdate operation. Required. + :type parameters: ~azure.mgmt.synapse.models.AttachedDatabaseConfiguration + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AttachedDatabaseConfiguration or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.AttachedDatabaseConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + workspace_name: str, + kusto_pool_name: str, + attached_database_configuration_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AttachedDatabaseConfiguration]: + """Creates or updates an attached database configuration. + + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param kusto_pool_name: The name of the Kusto pool. Required. + :type kusto_pool_name: str + :param attached_database_configuration_name: The name of the attached database configuration. + Required. + :type attached_database_configuration_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: The database parameters supplied to the CreateOrUpdate operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either AttachedDatabaseConfiguration or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.AttachedDatabaseConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -447,24 +544,27 @@ def begin_create_or_update( kusto_pool_name: str, attached_database_configuration_name: str, resource_group_name: str, - parameters: "_models.AttachedDatabaseConfiguration", + parameters: Union[_models.AttachedDatabaseConfiguration, IO], **kwargs: Any - ) -> LROPoller["_models.AttachedDatabaseConfiguration"]: + ) -> LROPoller[_models.AttachedDatabaseConfiguration]: """Creates or updates an attached database configuration. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str :param attached_database_configuration_name: The name of the attached database configuration. + Required. :type attached_database_configuration_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param parameters: The database parameters supplied to the CreateOrUpdate operation. - :type parameters: ~azure.mgmt.synapse.models.AttachedDatabaseConfiguration - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: 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 @@ -476,19 +576,19 @@ def begin_create_or_update( :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] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AttachedDatabaseConfiguration"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AttachedDatabaseConfiguration] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, attached_database_configuration_name=attached_database_configuration_name, @@ -496,32 +596,35 @@ def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('AttachedDatabaseConfiguration', pipeline_response) + deserialized = self._deserialize("AttachedDatabaseConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -531,46 +634,52 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( + request = build_delete_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, attached_database_configuration_name=attached_database_configuration_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements + def begin_delete( self, workspace_name: str, kusto_pool_name: str, @@ -580,17 +689,16 @@ def begin_delete( # pylint: disable=inconsistent-return-statements ) -> LROPoller[None]: """Deletes the attached database configuration with the given name. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str :param attached_database_configuration_name: The name of the attached database configuration. + Required. :type attached_database_configuration_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -601,43 +709,47 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, attached_database_configuration_name=attached_database_configuration_name, resource_group_name=resource_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/attachedDatabaseConfigurations/{attachedDatabaseConfigurationName}"} # 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 002c24223e87..c9d7c8e2449b 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 @@ -6,149 +6,224 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_check_name_availability_request( - workspace_name: str, - kusto_pool_name: str, - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + workspace_name: str, kusto_pool_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/checkNameAvailability") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/checkNameAvailability", + ) # pylint: disable=line-too-long path_format_arguments = { - "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), - "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, 'str'), - "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"), + "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - -class KustoPoolChildResourceOperations(object): - """KustoPoolChildResourceOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class KustoPoolChildResourceOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`kusto_pool_child_resource` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def check_name_availability( self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, - resource_name: "_models.DatabaseCheckNameRequest", + resource_name: _models.DatabaseCheckNameRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CheckNameResult": + ) -> _models.CheckNameResult: """Checks that the Kusto Pool child resource name is valid and is not already in use. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str :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. + :param resource_name: The name of the Kusto Pool child resource. Required. :type resource_name: ~azure.mgmt.synapse.models.DatabaseCheckNameRequest - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameResult, or the result of cls(response) + :return: CheckNameResult or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.CheckNameResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, + workspace_name: str, + kusto_pool_name: str, + resource_group_name: str, + resource_name: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the Kusto Pool child resource name is valid and is not already in use. + + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param kusto_pool_name: The name of the Kusto pool. Required. + :type kusto_pool_name: str + :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. Required. + :type resource_name: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, + workspace_name: str, + kusto_pool_name: str, + resource_group_name: str, + resource_name: Union[_models.DatabaseCheckNameRequest, IO], + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the Kusto Pool child resource name is valid and is not already in use. + + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param kusto_pool_name: The name of the Kusto pool. Required. + :type kusto_pool_name: str + :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 + :return: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameResult] - _json = self._serialize.body(resource_name, 'DatabaseCheckNameRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource_name, (IO, bytes)): + _content = resource_name + else: + _json = self._serialize.body(resource_name, "DatabaseCheckNameRequest") request = build_check_name_availability_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -156,12 +231,11 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/checkNameAvailability"} # 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 644d7ccc874a..fcf6e50bbccc 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,430 +6,500 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_check_name_availability_request( - subscription_id: str, resource_group_name: str, workspace_name: str, kusto_pool_name: str, database_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/checkNameAvailability") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/checkNameAvailability", + ) # 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'), - "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, 'str'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "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"), + "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_data_connection_validation_request_initial( - subscription_id: str, +def build_data_connection_validation_request( resource_group_name: str, workspace_name: str, kusto_pool_name: str, database_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnectionValidation") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnectionValidation", + ) # 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'), - "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, 'str'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "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"), + "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_database_request( - subscription_id: str, resource_group_name: str, workspace_name: str, kusto_pool_name: str, database_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections", + ) # 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'), - "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, 'str'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "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"), + "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, resource_group_name: str, workspace_name: str, kusto_pool_name: str, database_name: str, data_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}", + ) # 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'), - "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, 'str'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), - "dataConnectionName": _SERIALIZER.url("data_connection_name", data_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", 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"), + "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "dataConnectionName": _SERIALIZER.url("data_connection_name", data_connection_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, +def build_create_or_update_request( resource_group_name: str, workspace_name: str, kusto_pool_name: str, database_name: str, data_connection_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}", + ) # 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'), - "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, 'str'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), - "dataConnectionName": _SERIALIZER.url("data_connection_name", data_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", 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"), + "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "dataConnectionName": _SERIALIZER.url("data_connection_name", data_connection_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( - subscription_id: str, +def build_update_request( resource_group_name: str, workspace_name: str, kusto_pool_name: str, database_name: str, data_connection_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}", + ) # 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'), - "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, 'str'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), - "dataConnectionName": _SERIALIZER.url("data_connection_name", data_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", 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"), + "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "dataConnectionName": _SERIALIZER.url("data_connection_name", data_connection_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, +def build_delete_request( resource_group_name: str, workspace_name: str, kusto_pool_name: str, database_name: str, data_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}", + ) # 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'), - "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, 'str'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), - "dataConnectionName": _SERIALIZER.url("data_connection_name", data_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", 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"), + "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "dataConnectionName": _SERIALIZER.url("data_connection_name", data_connection_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class KustoPoolDataConnectionsOperations(object): - """KustoPoolDataConnectionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class KustoPoolDataConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`kusto_pool_data_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def check_name_availability( self, resource_group_name: str, workspace_name: str, kusto_pool_name: str, database_name: str, - data_connection_name: "_models.DataConnectionCheckNameRequest", + data_connection_name: _models.DataConnectionCheckNameRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CheckNameResult": + ) -> _models.CheckNameResult: """Checks that the data connection name is valid and is not already in use. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :param database_name: The name of the database in the Kusto pool. + :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. + :param data_connection_name: The name of the data connection. Required. :type data_connection_name: ~azure.mgmt.synapse.models.DataConnectionCheckNameRequest - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, + resource_group_name: str, + workspace_name: str, + kusto_pool_name: str, + database_name: str, + data_connection_name: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the data connection name is valid and is not already in use. + + :param resource_group_name: The name of the resource group. 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 kusto_pool_name: The name of the Kusto pool. Required. + :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. Required. + :type data_connection_name: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, + resource_group_name: str, + workspace_name: str, + kusto_pool_name: str, + database_name: str, + data_connection_name: Union[_models.DataConnectionCheckNameRequest, IO], + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the data connection name is valid and is not already in use. + + :param resource_group_name: The name of the resource group. 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 kusto_pool_name: The name of the Kusto pool. Required. + :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 - :return: CheckNameResult, or the result of cls(response) + :return: CheckNameResult or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.CheckNameResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(data_connection_name, 'DataConnectionCheckNameRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(data_connection_name, (IO, bytes)): + _content = data_connection_name + else: + _json = self._serialize.body(data_connection_name, "DataConnectionCheckNameRequest") request = build_check_name_availability_request( - subscription_id=self._config.subscription_id, 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, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -437,15 +507,14 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/checkNameAvailability"} # type: ignore def _data_connection_validation_initial( self, @@ -453,82 +522,100 @@ def _data_connection_validation_initial( workspace_name: str, kusto_pool_name: str, database_name: str, - parameters: "_models.DataConnectionValidation", + parameters: Union[_models.DataConnectionValidation, IO], **kwargs: Any - ) -> Optional["_models.DataConnectionValidationListResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DataConnectionValidationListResult"]] + ) -> Optional[_models.DataConnectionValidationListResult]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'DataConnectionValidation') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DataConnectionValidationListResult]] - request = build_data_connection_validation_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataConnectionValidation") + + request = build_data_connection_validation_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, content_type=content_type, json=_json, - template_url=self._data_connection_validation_initial.metadata['url'], + content=_content, + template_url=self._data_connection_validation_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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 = self._deserialize("DataConnectionValidationListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _data_connection_validation_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnectionValidation"} # type: ignore - + _data_connection_validation_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnectionValidation"} # type: ignore - @distributed_trace + @overload def begin_data_connection_validation( self, resource_group_name: str, workspace_name: str, kusto_pool_name: str, database_name: str, - parameters: "_models.DataConnectionValidation", + parameters: _models.DataConnectionValidation, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DataConnectionValidationListResult"]: + ) -> LROPoller[_models.DataConnectionValidationListResult]: """Checks that the data connection parameters are valid. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :param database_name: The name of the database in the Kusto pool. + :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. + Required. :type parameters: ~azure.mgmt.synapse.models.DataConnectionValidation - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -541,19 +628,105 @@ def begin_data_connection_validation( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.DataConnectionValidationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataConnectionValidationListResult"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_data_connection_validation( + self, + resource_group_name: str, + workspace_name: str, + kusto_pool_name: str, + database_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DataConnectionValidationListResult]: + """Checks that the data connection parameters are valid. + + :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 kusto_pool_name: The name of the Kusto pool. Required. + :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 data connection parameters supplied to the CreateOrUpdate operation. + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DataConnectionValidationListResult or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.DataConnectionValidationListResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_data_connection_validation( + self, + resource_group_name: str, + workspace_name: str, + kusto_pool_name: str, + database_name: str, + parameters: Union[_models.DataConnectionValidation, IO], + **kwargs: Any + ) -> LROPoller[_models.DataConnectionValidationListResult]: + """Checks that the data connection parameters are valid. + + :param resource_group_name: The name of the resource group. 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 kusto_pool_name: The name of the Kusto pool. Required. + :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 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. + :return: An instance of LROPoller that returns either DataConnectionValidationListResult or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.DataConnectionValidationListResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataConnectionValidationListResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._data_connection_validation_initial( + raw_result = self._data_connection_validation_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, @@ -561,96 +734,93 @@ def begin_data_connection_validation( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DataConnectionValidationListResult', pipeline_response) + deserialized = self._deserialize("DataConnectionValidationListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_data_connection_validation.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnectionValidation"} # type: ignore + begin_data_connection_validation.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnectionValidation"} # type: ignore @distributed_trace def list_by_database( - self, - resource_group_name: str, - workspace_name: str, - kusto_pool_name: str, - database_name: str, - **kwargs: Any - ) -> Iterable["_models.DataConnectionListResult"]: + self, resource_group_name: str, workspace_name: str, kusto_pool_name: str, database_name: str, **kwargs: Any + ) -> Iterable["_models.DataConnection"]: """Returns the list of data connections of the given Kusto pool database. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :param database_name: The name of the database in the Kusto pool. + :param database_name: The name of the database in the Kusto pool. Required. :type database_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataConnectionListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.DataConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DataConnection or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.DataConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataConnectionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataConnectionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_database_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.list_by_database.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_database_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - kusto_pool_name=kusto_pool_name, - database_name=database_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -664,10 +834,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -678,11 +846,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_database.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections"} # type: ignore + list_by_database.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections"} # type: ignore @distributed_trace def get( @@ -693,54 +859,58 @@ def get( database_name: str, data_connection_name: str, **kwargs: Any - ) -> "_models.DataConnection": + ) -> _models.DataConnection: """Returns a data connection. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :param database_name: The name of the database in the Kusto pool. + :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. + :param data_connection_name: The name of the data connection. Required. :type data_connection_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataConnection, or the result of cls(response) + :return: DataConnection or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.DataConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataConnection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataConnection] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, database_name=database_name, data_connection_name=data_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -748,15 +918,14 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore def _create_or_update_initial( self, @@ -765,61 +934,75 @@ def _create_or_update_initial( kusto_pool_name: str, database_name: str, data_connection_name: str, - parameters: "_models.DataConnection", + parameters: Union[_models.DataConnection, IO], **kwargs: Any - ) -> "_models.DataConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataConnection"] + ) -> _models.DataConnection: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'DataConnection') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataConnection] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataConnection") + + request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, database_name=database_name, data_connection_name=data_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("DataConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DataConnection', pipeline_response) + deserialized = self._deserialize("DataConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, @@ -827,26 +1010,30 @@ def begin_create_or_update( kusto_pool_name: str, database_name: str, data_connection_name: str, - parameters: "_models.DataConnection", + parameters: _models.DataConnection, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DataConnection"]: + ) -> LROPoller[_models.DataConnection]: """Creates or updates a data connection. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :param database_name: The name of the database in the Kusto pool. + :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. + :param data_connection_name: The name of the data connection. Required. :type data_connection_name: str :param parameters: The data connection parameters supplied to the CreateOrUpdate operation. + Required. :type parameters: ~azure.mgmt.synapse.models.DataConnection - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -858,19 +1045,109 @@ def begin_create_or_update( :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] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + kusto_pool_name: str, + database_name: str, + data_connection_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DataConnection]: + """Creates or updates a data connection. + + :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 kusto_pool_name: The name of the Kusto pool. Required. + :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. Required. + :type data_connection_name: str + :param parameters: The data connection parameters supplied to the CreateOrUpdate operation. + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + kusto_pool_name: str, + database_name: str, + data_connection_name: str, + parameters: Union[_models.DataConnection, IO], + **kwargs: Any + ) -> LROPoller[_models.DataConnection]: + """Creates or updates a data connection. + + :param resource_group_name: The name of the resource group. 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 kusto_pool_name: The name of the Kusto pool. Required. + :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. 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. + :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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, @@ -879,32 +1156,35 @@ def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DataConnection', pipeline_response) + deserialized = self._deserialize("DataConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore def _update_initial( self, @@ -913,59 +1193,163 @@ def _update_initial( kusto_pool_name: str, database_name: str, data_connection_name: str, - parameters: "_models.DataConnection", + parameters: Union[_models.DataConnection, IO], **kwargs: Any - ) -> "_models.DataConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataConnection"] + ) -> _models.DataConnection: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'DataConnection') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataConnection] - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DataConnection") + + request = build_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, database_name=database_name, data_connection_name=data_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("DataConnection", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('DataConnection', pipeline_response) + deserialized = self._deserialize("DataConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + workspace_name: str, + kusto_pool_name: str, + database_name: str, + data_connection_name: str, + parameters: _models.DataConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DataConnection]: + """Updates a data connection. + :param resource_group_name: The name of the resource group. 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 kusto_pool_name: The name of the Kusto pool. Required. + :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. Required. + :type data_connection_name: str + :param parameters: The data connection parameters supplied to the Update operation. Required. + :type parameters: ~azure.mgmt.synapse.models.DataConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DataConnection or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.DataConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + workspace_name: str, + kusto_pool_name: str, + database_name: str, + data_connection_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DataConnection]: + """Updates a data connection. + + :param resource_group_name: The name of the resource group. 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 kusto_pool_name: The name of the Kusto pool. Required. + :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. Required. + :type data_connection_name: str + :param parameters: The data connection parameters supplied to the Update operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DataConnection or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.DataConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -975,26 +1359,28 @@ def begin_update( kusto_pool_name: str, database_name: str, data_connection_name: str, - parameters: "_models.DataConnection", + parameters: Union[_models.DataConnection, IO], **kwargs: Any - ) -> LROPoller["_models.DataConnection"]: + ) -> LROPoller[_models.DataConnection]: """Updates a data connection. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :param database_name: The name of the database in the Kusto pool. + :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. + :param data_connection_name: The name of the data connection. Required. :type data_connection_name: str - :param parameters: The data connection parameters supplied to the Update operation. - :type parameters: ~azure.mgmt.synapse.models.DataConnection - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: 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 @@ -1006,19 +1392,19 @@ def begin_update( :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] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, @@ -1027,32 +1413,35 @@ def begin_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DataConnection', pipeline_response) + deserialized = self._deserialize("DataConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -1063,47 +1452,53 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements data_connection_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, database_name=database_name, data_connection_name=data_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements + def begin_delete( self, resource_group_name: str, workspace_name: str, @@ -1115,18 +1510,16 @@ def begin_delete( # pylint: disable=inconsistent-return-statements """Deletes the data connection with the given name. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :param database_name: The name of the database in the Kusto pool. + :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. + :param data_connection_name: The name of the data connection. Required. :type data_connection_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1137,44 +1530,48 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, database_name=database_name, data_connection_name=data_connection_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/dataConnections/{dataConnectionName}"} # 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 d3852438a494..3c1b6b4b7670 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 @@ -6,115 +6,118 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_check_name_availability_request( workspace_name: str, kusto_pool_name: str, database_name: str, - subscription_id: str, resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/checkPrincipalAssignmentNameAvailability") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/checkPrincipalAssignmentNameAvailability", + ) # pylint: disable=line-too-long path_format_arguments = { - "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), - "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, 'str'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), - "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"), + "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( workspace_name: str, kusto_pool_name: str, database_name: str, - subscription_id: str, resource_group_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments", + ) # pylint: disable=line-too-long path_format_arguments = { - "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), - "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, 'str'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), - "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"), + "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -122,217 +125,295 @@ def build_get_request( kusto_pool_name: str, database_name: str, principal_assignment_name: str, - subscription_id: str, resource_group_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), - "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, 'str'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), - "principalAssignmentName": _SERIALIZER.url("principal_assignment_name", principal_assignment_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', 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"), + "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "principalAssignmentName": _SERIALIZER.url("principal_assignment_name", principal_assignment_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( +def build_create_or_update_request( workspace_name: str, kusto_pool_name: str, database_name: str, principal_assignment_name: str, - subscription_id: str, resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), - "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, 'str'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), - "principalAssignmentName": _SERIALIZER.url("principal_assignment_name", principal_assignment_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', 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"), + "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "principalAssignmentName": _SERIALIZER.url("principal_assignment_name", principal_assignment_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( +def build_delete_request( workspace_name: str, kusto_pool_name: str, database_name: str, principal_assignment_name: str, - subscription_id: str, resource_group_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), - "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, 'str'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), - "principalAssignmentName": _SERIALIZER.url("principal_assignment_name", principal_assignment_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', 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"), + "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), + "principalAssignmentName": _SERIALIZER.url("principal_assignment_name", principal_assignment_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class KustoPoolDatabasePrincipalAssignmentsOperations(object): - """KustoPoolDatabasePrincipalAssignmentsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class KustoPoolDatabasePrincipalAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`kusto_pool_database_principal_assignments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def check_name_availability( self, workspace_name: str, kusto_pool_name: str, database_name: str, resource_group_name: str, - principal_assignment_name: "_models.DatabasePrincipalAssignmentCheckNameRequest", + principal_assignment_name: _models.DatabasePrincipalAssignmentCheckNameRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CheckNameResult": + ) -> _models.CheckNameResult: """Checks that the database principal assignment is valid and is not already in use. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :param database_name: The name of the database in the Kusto pool. + :param database_name: The name of the database in the Kusto pool. Required. :type database_name: str :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. + :param principal_assignment_name: The name of the resource. Required. :type principal_assignment_name: ~azure.mgmt.synapse.models.DatabasePrincipalAssignmentCheckNameRequest - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, + workspace_name: str, + kusto_pool_name: str, + database_name: str, + resource_group_name: str, + principal_assignment_name: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the database principal assignment is valid and is not already in use. + + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param kusto_pool_name: The name of the Kusto pool. Required. + :type kusto_pool_name: str + :param database_name: The name of the database in the Kusto pool. Required. + :type database_name: str + :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. Required. + :type principal_assignment_name: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, + workspace_name: str, + kusto_pool_name: str, + database_name: str, + resource_group_name: str, + principal_assignment_name: Union[_models.DatabasePrincipalAssignmentCheckNameRequest, IO], + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the database principal assignment is valid and is not already in use. + + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param kusto_pool_name: The name of the Kusto pool. Required. + :type kusto_pool_name: str + :param database_name: The name of the database in the Kusto pool. Required. + :type database_name: str + :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. + :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 - :return: CheckNameResult, or the result of cls(response) + :return: CheckNameResult or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.CheckNameResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameResult] - _json = self._serialize.body(principal_assignment_name, 'DatabasePrincipalAssignmentCheckNameRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(principal_assignment_name, (IO, bytes)): + _content = principal_assignment_name + else: + _json = self._serialize.body(principal_assignment_name, "DatabasePrincipalAssignmentCheckNameRequest") request = build_check_name_availability_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, database_name=database_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -340,80 +421,71 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/checkPrincipalAssignmentNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/checkPrincipalAssignmentNameAvailability"} # type: ignore @distributed_trace def list( - self, - workspace_name: str, - kusto_pool_name: str, - database_name: str, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.DatabasePrincipalAssignmentListResult"]: + self, workspace_name: str, kusto_pool_name: str, database_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.DatabasePrincipalAssignment"]: """Lists all Kusto pool database principalAssignments. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :param database_name: The name of the database in the Kusto pool. + :param database_name: The name of the database in the Kusto pool. Required. :type database_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabasePrincipalAssignmentListResult or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.DatabasePrincipalAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DatabasePrincipalAssignment or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.DatabasePrincipalAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DatabasePrincipalAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabasePrincipalAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, database_name=database_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - workspace_name=workspace_name, - kusto_pool_name=kusto_pool_name, - database_name=database_name, - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -427,10 +499,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -441,11 +511,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments"} # type: ignore @distributed_trace def get( @@ -456,54 +524,58 @@ def get( principal_assignment_name: str, resource_group_name: str, **kwargs: Any - ) -> "_models.DatabasePrincipalAssignment": + ) -> _models.DatabasePrincipalAssignment: """Gets a Kusto pool database principalAssignment. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :param database_name: The name of the database in the Kusto pool. + :param database_name: The name of the database in the Kusto pool. Required. :type database_name: str - :param principal_assignment_name: The name of the Kusto principalAssignment. + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. :type principal_assignment_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DatabasePrincipalAssignment, or the result of cls(response) + :return: DatabasePrincipalAssignment or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.DatabasePrincipalAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabasePrincipalAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DatabasePrincipalAssignment] - request = build_get_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, database_name=database_name, principal_assignment_name=principal_assignment_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -511,15 +583,14 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}"} # type: ignore def _create_or_update_initial( self, @@ -528,61 +599,75 @@ def _create_or_update_initial( database_name: str, principal_assignment_name: str, resource_group_name: str, - parameters: "_models.DatabasePrincipalAssignment", + parameters: Union[_models.DatabasePrincipalAssignment, IO], **kwargs: Any - ) -> "_models.DatabasePrincipalAssignment": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabasePrincipalAssignment"] + ) -> _models.DatabasePrincipalAssignment: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'DatabasePrincipalAssignment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DatabasePrincipalAssignment] - request = build_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DatabasePrincipalAssignment") + + request = build_create_or_update_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, database_name=database_name, principal_assignment_name=principal_assignment_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("DatabasePrincipalAssignment", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('DatabasePrincipalAssignment', pipeline_response) + deserialized = self._deserialize("DatabasePrincipalAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update( self, workspace_name: str, @@ -590,26 +675,30 @@ def begin_create_or_update( database_name: str, principal_assignment_name: str, resource_group_name: str, - parameters: "_models.DatabasePrincipalAssignment", + parameters: _models.DatabasePrincipalAssignment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.DatabasePrincipalAssignment"]: + ) -> LROPoller[_models.DatabasePrincipalAssignment]: """Creates a Kusto pool database principalAssignment. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :param database_name: The name of the database in the Kusto pool. + :param database_name: The name of the database in the Kusto pool. Required. :type database_name: str - :param principal_assignment_name: The name of the Kusto principalAssignment. + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. :type principal_assignment_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param parameters: The Kusto principalAssignments parameters supplied for the operation. + Required. :type parameters: ~azure.mgmt.synapse.models.DatabasePrincipalAssignment - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -621,19 +710,109 @@ def begin_create_or_update( :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] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabasePrincipalAssignment"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + workspace_name: str, + kusto_pool_name: str, + database_name: str, + principal_assignment_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DatabasePrincipalAssignment]: + """Creates a Kusto pool database principalAssignment. + + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param kusto_pool_name: The name of the Kusto pool. Required. + :type kusto_pool_name: str + :param database_name: The name of the database in the Kusto pool. Required. + :type database_name: str + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. + :type principal_assignment_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: The Kusto principalAssignments parameters supplied for the operation. + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DatabasePrincipalAssignment or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.DatabasePrincipalAssignment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + workspace_name: str, + kusto_pool_name: str, + database_name: str, + principal_assignment_name: str, + resource_group_name: str, + parameters: Union[_models.DatabasePrincipalAssignment, IO], + **kwargs: Any + ) -> LROPoller[_models.DatabasePrincipalAssignment]: + """Creates a Kusto pool database principalAssignment. + + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param kusto_pool_name: The name of the Kusto pool. Required. + :type kusto_pool_name: str + :param database_name: The name of the database in the Kusto pool. Required. + :type database_name: str + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. + :type principal_assignment_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + 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. + :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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DatabasePrincipalAssignment] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, database_name=database_name, @@ -642,32 +821,35 @@ def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DatabasePrincipalAssignment', pipeline_response) + deserialized = self._deserialize("DatabasePrincipalAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -678,47 +860,53 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, database_name=database_name, principal_assignment_name=principal_assignment_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements + def begin_delete( self, workspace_name: str, kusto_pool_name: str, @@ -729,19 +917,17 @@ def begin_delete( # pylint: disable=inconsistent-return-statements ) -> LROPoller[None]: """Deletes a Kusto pool principalAssignment. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :param database_name: The name of the database in the Kusto pool. + :param database_name: The name of the database in the Kusto pool. Required. :type database_name: str - :param principal_assignment_name: The name of the Kusto principalAssignment. + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. :type principal_assignment_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -752,44 +938,48 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, database_name=database_name, principal_assignment_name=principal_assignment_name, resource_group_name=resource_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}/principalAssignments/{principalAssignmentName}"} # 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 70cf4bea0823..eeaf8561f062 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 @@ -6,321 +6,308 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_by_kusto_pool_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - kusto_pool_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, kusto_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases", + ) # 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'), - "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, 'str'), + "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"), + "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, resource_group_name: str, workspace_name: str, kusto_pool_name: str, database_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}", + ) # 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'), - "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, 'str'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "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"), + "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, +def build_create_or_update_request( resource_group_name: str, workspace_name: str, kusto_pool_name: str, database_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}", + ) # 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'), - "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, 'str'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "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"), + "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( - subscription_id: str, +def build_update_request( resource_group_name: str, workspace_name: str, kusto_pool_name: str, database_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}", + ) # 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'), - "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, 'str'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "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"), + "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, +def build_delete_request( resource_group_name: str, workspace_name: str, kusto_pool_name: str, database_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}", + ) # 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'), - "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, 'str'), - "databaseName": _SERIALIZER.url("database_name", database_name, 'str'), + "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"), + "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), + "databaseName": _SERIALIZER.url("database_name", database_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class KustoPoolDatabasesOperations(object): - """KustoPoolDatabasesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class KustoPoolDatabasesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`kusto_pool_databases` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_kusto_pool( - self, - resource_group_name: str, - workspace_name: str, - kusto_pool_name: str, - **kwargs: Any - ) -> Iterable["_models.DatabaseListResult"]: + self, resource_group_name: str, workspace_name: str, kusto_pool_name: str, **kwargs: Any + ) -> Iterable["_models.Database"]: """Returns the list of databases of the given Kusto 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatabaseListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.DatabaseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Database or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DatabaseListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DatabaseListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_kusto_pool_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore else: - - request = build_list_by_kusto_pool_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - kusto_pool_name=kusto_pool_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -334,10 +321,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -348,65 +333,62 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_kusto_pool.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases"} # type: ignore + list_by_kusto_pool.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - workspace_name: str, - kusto_pool_name: str, - database_name: str, - **kwargs: Any - ) -> "_models.Database": + self, resource_group_name: str, workspace_name: str, kusto_pool_name: str, database_name: str, **kwargs: Any + ) -> _models.Database: """Returns a database. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :param database_name: The name of the database in the Kusto pool. + :param database_name: The name of the database in the Kusto pool. Required. :type database_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Database, or the result of cls(response) + :return: Database or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.Database - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Database] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -414,15 +396,14 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}"} # type: ignore def _create_or_update_initial( self, @@ -430,58 +411,154 @@ def _create_or_update_initial( workspace_name: str, kusto_pool_name: str, database_name: str, - parameters: "_models.Database", + parameters: Union[_models.Database, IO], **kwargs: Any - ) -> "_models.Database": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] + ) -> _models.Database: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Database') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Database] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Database") + + request = build_create_or_update_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, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("Database", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Database', pipeline_response) + deserialized = self._deserialize("Database", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + kusto_pool_name: str, + database_name: str, + parameters: _models.Database, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Database]: + """Creates or updates a database. + + :param resource_group_name: The name of the resource group. 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 kusto_pool_name: The name of the Kusto pool. Required. + :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 CreateOrUpdate operation. Required. + :type parameters: ~azure.mgmt.synapse.models.Database + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + kusto_pool_name: str, + database_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Database]: + """Creates or updates a database. + + :param resource_group_name: The name of the resource group. 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 kusto_pool_name: The name of the Kusto pool. Required. + :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 CreateOrUpdate operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Database or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -490,24 +567,26 @@ def begin_create_or_update( workspace_name: str, kusto_pool_name: str, database_name: str, - parameters: "_models.Database", + parameters: Union[_models.Database, IO], **kwargs: Any - ) -> LROPoller["_models.Database"]: + ) -> LROPoller[_models.Database]: """Creates or updates a database. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :param database_name: The name of the database in the Kusto pool. + :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. - :type parameters: ~azure.mgmt.synapse.models.Database - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: 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 @@ -518,19 +597,19 @@ def begin_create_or_update( 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Database] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, @@ -538,32 +617,35 @@ def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('Database', pipeline_response) + deserialized = self._deserialize("Database", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}"} # type: ignore def _update_initial( self, @@ -571,58 +653,154 @@ def _update_initial( workspace_name: str, kusto_pool_name: str, database_name: str, - parameters: "_models.Database", + parameters: Union[_models.Database, IO], **kwargs: Any - ) -> "_models.Database": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] + ) -> _models.Database: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'Database') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Database] - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Database") + + request = build_update_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, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("Database", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('Database', pipeline_response) + deserialized = self._deserialize("Database", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + workspace_name: str, + kusto_pool_name: str, + database_name: str, + parameters: _models.Database, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Database]: + """Updates a database. + + :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 kusto_pool_name: The name of the Kusto pool. Required. + :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. Required. + :type parameters: ~azure.mgmt.synapse.models.Database + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + workspace_name: str, + kusto_pool_name: str, + database_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Database]: + """Updates a database. + + :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 kusto_pool_name: The name of the Kusto pool. Required. + :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. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Database or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.Database] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -631,24 +809,26 @@ def begin_update( workspace_name: str, kusto_pool_name: str, database_name: str, - parameters: "_models.Database", + parameters: Union[_models.Database, IO], **kwargs: Any - ) -> LROPoller["_models.Database"]: + ) -> LROPoller[_models.Database]: """Updates a database. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :param database_name: The name of the database in the Kusto pool. + :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. - :type parameters: ~azure.mgmt.synapse.models.Database - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: 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 @@ -659,19 +839,19 @@ def begin_update( 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Database"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Database] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, @@ -679,101 +859,98 @@ def begin_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('Database', pipeline_response) + deserialized = self._deserialize("Database", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - kusto_pool_name: str, - database_name: str, - **kwargs: Any + self, resource_group_name: str, workspace_name: str, kusto_pool_name: str, database_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + 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'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - kusto_pool_name: str, - database_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, workspace_name: str, kusto_pool_name: str, database_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes the database with the given name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :param database_name: The name of the database in the Kusto pool. + :param database_name: The name of the database in the Kusto pool. Required. :type database_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -784,43 +961,47 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, database_name=database_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/databases/{databaseName}"} # 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 04bf59fe1af4..55123c68e773 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 @@ -6,319 +6,386 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_check_name_availability_request( - workspace_name: str, - kusto_pool_name: str, - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + workspace_name: str, kusto_pool_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/checkPrincipalAssignmentNameAvailability") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/checkPrincipalAssignmentNameAvailability", + ) # pylint: disable=line-too-long path_format_arguments = { - "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), - "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, 'str'), - "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"), + "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( - workspace_name: str, - kusto_pool_name: str, - subscription_id: str, - resource_group_name: str, - **kwargs: Any + workspace_name: str, kusto_pool_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments", + ) # pylint: disable=line-too-long path_format_arguments = { - "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), - "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, 'str'), - "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"), + "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( workspace_name: str, kusto_pool_name: str, principal_assignment_name: str, - subscription_id: str, resource_group_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments/{principalAssignmentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments/{principalAssignmentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), - "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, 'str'), - "principalAssignmentName": _SERIALIZER.url("principal_assignment_name", principal_assignment_name, 'str'), - "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"), + "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), + "principalAssignmentName": _SERIALIZER.url("principal_assignment_name", principal_assignment_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( +def build_create_or_update_request( workspace_name: str, kusto_pool_name: str, principal_assignment_name: str, - subscription_id: str, resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments/{principalAssignmentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments/{principalAssignmentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), - "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, 'str'), - "principalAssignmentName": _SERIALIZER.url("principal_assignment_name", principal_assignment_name, 'str'), - "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"), + "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), + "principalAssignmentName": _SERIALIZER.url("principal_assignment_name", principal_assignment_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( +def build_delete_request( workspace_name: str, kusto_pool_name: str, principal_assignment_name: str, - subscription_id: str, resource_group_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments/{principalAssignmentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments/{principalAssignmentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), - "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, 'str'), - "principalAssignmentName": _SERIALIZER.url("principal_assignment_name", principal_assignment_name, 'str'), - "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"), + "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), + "principalAssignmentName": _SERIALIZER.url("principal_assignment_name", principal_assignment_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class KustoPoolPrincipalAssignmentsOperations(object): - """KustoPoolPrincipalAssignmentsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class KustoPoolPrincipalAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`kusto_pool_principal_assignments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def check_name_availability( self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, - principal_assignment_name: "_models.ClusterPrincipalAssignmentCheckNameRequest", + principal_assignment_name: _models.ClusterPrincipalAssignmentCheckNameRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CheckNameResult": + ) -> _models.CheckNameResult: """Checks that the principal assignment name is valid and is not already in use. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str :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. + :param principal_assignment_name: The name of the principal assignment. Required. :type principal_assignment_name: ~azure.mgmt.synapse.models.ClusterPrincipalAssignmentCheckNameRequest - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, + workspace_name: str, + kusto_pool_name: str, + resource_group_name: str, + principal_assignment_name: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the principal assignment name is valid and is not already in use. + + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param kusto_pool_name: The name of the Kusto pool. Required. + :type kusto_pool_name: str + :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. Required. + :type principal_assignment_name: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, + workspace_name: str, + kusto_pool_name: str, + resource_group_name: str, + principal_assignment_name: Union[_models.ClusterPrincipalAssignmentCheckNameRequest, IO], + **kwargs: Any + ) -> _models.CheckNameResult: + """Checks that the principal assignment name is valid and is not already in use. + + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param kusto_pool_name: The name of the Kusto pool. Required. + :type kusto_pool_name: str + :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. + :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 - :return: CheckNameResult, or the result of cls(response) + :return: CheckNameResult or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.CheckNameResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(principal_assignment_name, 'ClusterPrincipalAssignmentCheckNameRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(principal_assignment_name, (IO, bytes)): + _content = principal_assignment_name + else: + _json = self._serialize.body(principal_assignment_name, "ClusterPrincipalAssignmentCheckNameRequest") request = build_check_name_availability_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -326,75 +393,68 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/checkPrincipalAssignmentNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/checkPrincipalAssignmentNameAvailability"} # type: ignore @distributed_trace def list( - self, - workspace_name: str, - kusto_pool_name: str, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.ClusterPrincipalAssignmentListResult"]: + self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.ClusterPrincipalAssignment"]: """Lists all Kusto pool principalAssignments. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ClusterPrincipalAssignmentListResult or the result - of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.ClusterPrincipalAssignmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ClusterPrincipalAssignment or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.ClusterPrincipalAssignment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ClusterPrincipalAssignmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterPrincipalAssignmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - workspace_name=workspace_name, - kusto_pool_name=kusto_pool_name, - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -408,10 +468,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -422,11 +480,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments"} # type: ignore @distributed_trace def get( @@ -436,51 +492,55 @@ def get( principal_assignment_name: str, resource_group_name: str, **kwargs: Any - ) -> "_models.ClusterPrincipalAssignment": + ) -> _models.ClusterPrincipalAssignment: """Gets a Kusto pool principalAssignment. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :param principal_assignment_name: The name of the Kusto principalAssignment. + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. :type principal_assignment_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ClusterPrincipalAssignment, or the result of cls(response) + :return: ClusterPrincipalAssignment or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ClusterPrincipalAssignment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterPrincipalAssignment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ClusterPrincipalAssignment] - request = build_get_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, principal_assignment_name=principal_assignment_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -488,15 +548,14 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments/{principalAssignmentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments/{principalAssignmentName}"} # type: ignore def _create_or_update_initial( self, @@ -504,58 +563,158 @@ def _create_or_update_initial( kusto_pool_name: str, principal_assignment_name: str, resource_group_name: str, - parameters: "_models.ClusterPrincipalAssignment", + parameters: Union[_models.ClusterPrincipalAssignment, IO], **kwargs: Any - ) -> "_models.ClusterPrincipalAssignment": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterPrincipalAssignment"] + ) -> _models.ClusterPrincipalAssignment: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ClusterPrincipalAssignment') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ClusterPrincipalAssignment] - request = build_create_or_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ClusterPrincipalAssignment") + + request = build_create_or_update_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, principal_assignment_name=principal_assignment_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("ClusterPrincipalAssignment", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ClusterPrincipalAssignment', pipeline_response) + deserialized = self._deserialize("ClusterPrincipalAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments/{principalAssignmentName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments/{principalAssignmentName}"} # type: ignore + @overload + def begin_create_or_update( + self, + workspace_name: str, + kusto_pool_name: str, + principal_assignment_name: str, + resource_group_name: str, + parameters: _models.ClusterPrincipalAssignment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ClusterPrincipalAssignment]: + """Create a Kusto pool principalAssignment. + + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param kusto_pool_name: The name of the Kusto pool. Required. + :type kusto_pool_name: str + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. + :type principal_assignment_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: The Kusto pool principalAssignment's parameters supplied for the operation. + Required. + :type parameters: ~azure.mgmt.synapse.models.ClusterPrincipalAssignment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ClusterPrincipalAssignment or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.ClusterPrincipalAssignment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + workspace_name: str, + kusto_pool_name: str, + principal_assignment_name: str, + resource_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ClusterPrincipalAssignment]: + """Create a Kusto pool principalAssignment. + + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param kusto_pool_name: The name of the Kusto pool. Required. + :type kusto_pool_name: str + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. + :type principal_assignment_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: The Kusto pool principalAssignment's parameters supplied for the operation. + Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ClusterPrincipalAssignment or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.ClusterPrincipalAssignment] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -564,24 +723,26 @@ def begin_create_or_update( kusto_pool_name: str, principal_assignment_name: str, resource_group_name: str, - parameters: "_models.ClusterPrincipalAssignment", + parameters: Union[_models.ClusterPrincipalAssignment, IO], **kwargs: Any - ) -> LROPoller["_models.ClusterPrincipalAssignment"]: + ) -> LROPoller[_models.ClusterPrincipalAssignment]: """Create a Kusto pool principalAssignment. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :param principal_assignment_name: The name of the Kusto principalAssignment. + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. :type principal_assignment_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param parameters: The Kusto pool principalAssignment's parameters supplied for the operation. - :type parameters: ~azure.mgmt.synapse.models.ClusterPrincipalAssignment - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + 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 @@ -593,19 +754,19 @@ def begin_create_or_update( :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] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterPrincipalAssignment"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ClusterPrincipalAssignment] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, principal_assignment_name=principal_assignment_name, @@ -613,32 +774,35 @@ def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ClusterPrincipalAssignment', pipeline_response) + deserialized = self._deserialize("ClusterPrincipalAssignment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments/{principalAssignmentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments/{principalAssignmentName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -648,46 +812,52 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, principal_assignment_name=principal_assignment_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments/{principalAssignmentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments/{principalAssignmentName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements + def begin_delete( self, workspace_name: str, kusto_pool_name: str, @@ -697,17 +867,15 @@ def begin_delete( # pylint: disable=inconsistent-return-statements ) -> LROPoller[None]: """Deletes a Kusto pool principalAssignment. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :param principal_assignment_name: The name of the Kusto principalAssignment. + :param principal_assignment_name: The name of the Kusto principalAssignment. Required. :type principal_assignment_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -718,43 +886,47 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, principal_assignment_name=principal_assignment_name, resource_group_name=resource_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments/{principalAssignmentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/principalAssignments/{principalAssignmentName}"} # type: ignore 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 b443b49f1751..f64a8607ec0a 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,707 +6,626 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_skus_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - accept = "application/json" +def build_list_skus_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Synapse/skus") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_check_name_availability_request( - subscription_id: str, - location: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] +def build_check_name_availability_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Synapse/locations/{location}/kustoPoolCheckNameAvailability") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Synapse/locations/{location}/kustoPoolCheckNameAvailability", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "location": _SERIALIZER.url("location", location, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_workspace_request( - resource_group_name: str, - subscription_id: str, - workspace_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - workspace_name: str, - kusto_pool_name: str, - subscription_id: str, - resource_group_name: str, - **kwargs: Any + workspace_name: str, kusto_pool_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), - "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, 'str'), - "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"), + "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( +def build_create_or_update_request( workspace_name: str, resource_group_name: str, kusto_pool_name: str, subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - _header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if if_none_match is not None: - _header_parameters['If-None-Match'] = _SERIALIZER.header("if_none_match", if_none_match, 'str') + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( +def build_update_request( workspace_name: str, resource_group_name: str, kusto_pool_name: str, subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - _header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - workspace_name: str, - resource_group_name: str, - kusto_pool_name: str, - subscription_id: str, - **kwargs: Any +def build_delete_request( + workspace_name: str, resource_group_name: str, kusto_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_stop_request_initial( - workspace_name: str, - kusto_pool_name: str, - subscription_id: str, - resource_group_name: str, - **kwargs: Any +def build_stop_request( + workspace_name: str, kusto_pool_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/stop") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/stop", + ) # pylint: disable=line-too-long path_format_arguments = { - "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), - "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, 'str'), - "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"), + "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_start_request_initial( - workspace_name: str, - kusto_pool_name: str, - subscription_id: str, - resource_group_name: str, - **kwargs: Any +def build_start_request( + workspace_name: str, kusto_pool_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/start") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/start", + ) # pylint: disable=line-too-long path_format_arguments = { - "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), - "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, 'str'), - "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"), + "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_skus_by_resource_request( - workspace_name: str, - kusto_pool_name: str, - subscription_id: str, - resource_group_name: str, - **kwargs: Any + workspace_name: str, kusto_pool_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/skus") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/skus", + ) # pylint: disable=line-too-long path_format_arguments = { - "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), - "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, 'str'), - "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"), + "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_language_extensions_request( - workspace_name: str, - kusto_pool_name: str, - subscription_id: str, - resource_group_name: str, - **kwargs: Any + workspace_name: str, kusto_pool_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/listLanguageExtensions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/listLanguageExtensions", + ) # pylint: disable=line-too-long path_format_arguments = { - "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), - "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, 'str'), - "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"), + "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_add_language_extensions_request_initial( - workspace_name: str, - kusto_pool_name: str, - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_add_language_extensions_request( + workspace_name: str, kusto_pool_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/addLanguageExtensions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/addLanguageExtensions", + ) # pylint: disable=line-too-long path_format_arguments = { - "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), - "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, 'str'), - "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"), + "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_remove_language_extensions_request_initial( - workspace_name: str, - kusto_pool_name: str, - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_remove_language_extensions_request( + workspace_name: str, kusto_pool_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/removeLanguageExtensions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/removeLanguageExtensions", + ) # pylint: disable=line-too-long path_format_arguments = { - "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), - "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, 'str'), - "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"), + "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_follower_databases_request( - workspace_name: str, - kusto_pool_name: str, - subscription_id: str, - resource_group_name: str, - **kwargs: Any + workspace_name: str, kusto_pool_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/listFollowerDatabases") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/listFollowerDatabases", + ) # pylint: disable=line-too-long path_format_arguments = { - "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), - "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, 'str'), - "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"), + "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_detach_follower_databases_request_initial( - workspace_name: str, - kusto_pool_name: str, - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_detach_follower_databases_request( + workspace_name: str, kusto_pool_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/detachFollowerDatabases") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/detachFollowerDatabases", + ) # pylint: disable=line-too-long path_format_arguments = { - "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), - "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, 'str'), - "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"), + "kustoPoolName": _SERIALIZER.url("kusto_pool_name", kusto_pool_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - -class KustoPoolsOperations(object): # pylint: disable=too-many-public-methods - """KustoPoolsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class KustoPoolsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`kusto_pools` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_skus( - self, - **kwargs: Any - ) -> Iterable["_models.SkuDescriptionList"]: + def list_skus(self, **kwargs: Any) -> Iterable["_models.SkuDescription"]: """Lists eligible SKUs for Kusto Pool resource. - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SkuDescriptionList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.SkuDescriptionList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SkuDescription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.SkuDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SkuDescriptionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SkuDescriptionList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_skus_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_skus.metadata['url'], + template_url=self.list_skus.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_skus_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -720,10 +639,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -734,60 +651,112 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_skus.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Synapse/skus"} # type: ignore + list_skus.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Synapse/skus"} # type: ignore - @distributed_trace + @overload def check_name_availability( self, location: str, - kusto_pool_name: "_models.KustoPoolCheckNameRequest", + kusto_pool_name: _models.KustoPoolCheckNameRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CheckNameResult": + ) -> _models.CheckNameResult: """Checks that the kusto pool name is valid and is not already in use. - :param location: The name of Azure region. + :param location: The name of Azure region. Required. :type location: str - :param kusto_pool_name: The name of the cluster. + :param kusto_pool_name: The name of the cluster. Required. :type kusto_pool_name: ~azure.mgmt.synapse.models.KustoPoolCheckNameRequest - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameResult or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.CheckNameResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, location: str, kusto_pool_name: IO, *, 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: + """ + + @distributed_trace + def check_name_availability( + self, location: str, kusto_pool_name: Union[_models.KustoPoolCheckNameRequest, IO], **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 - :return: CheckNameResult, or the result of cls(response) + :return: CheckNameResult or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.CheckNameResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameResult] - _json = self._serialize.body(kusto_pool_name, 'KustoPoolCheckNameRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(kusto_pool_name, (IO, bytes)): + _content = kusto_pool_name + else: + _json = self._serialize.body(kusto_pool_name, "KustoPoolCheckNameRequest") request = build_check_name_availability_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -795,63 +764,63 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Synapse/locations/{location}/kustoPoolCheckNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Synapse/locations/{location}/kustoPoolCheckNameAvailability"} # type: ignore @distributed_trace def list_by_workspace( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> "_models.KustoPoolListResult": + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> _models.KustoPoolListResult: """List Kusto pools. List all Kusto pools. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: KustoPoolListResult, or the result of cls(response) + :return: KustoPoolListResult or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.KustoPoolListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.KustoPoolListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.KustoPoolListResult] - request = build_list_by_workspace_request( resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, workspace_name=workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_workspace.metadata['url'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -859,65 +828,64 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_workspace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools"} # type: ignore - + list_by_workspace.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools"} # type: ignore @distributed_trace def get( - self, - workspace_name: str, - kusto_pool_name: str, - resource_group_name: str, - **kwargs: Any - ) -> "_models.KustoPool": + self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.KustoPool: """Gets a Kusto pool. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: KustoPool, or the result of cls(response) + :return: KustoPool or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.KustoPool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.KustoPool"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.KustoPool] - request = build_get_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -925,97 +893,114 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}"} # type: ignore def _create_or_update_initial( self, workspace_name: str, resource_group_name: str, kusto_pool_name: str, - parameters: "_models.KustoPool", + parameters: Union[_models.KustoPool, IO], if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any - ) -> "_models.KustoPool": - cls = kwargs.pop('cls', None) # type: ClsType["_models.KustoPool"] + ) -> _models.KustoPool: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.KustoPool] - _json = self._serialize.body(parameters, 'KustoPool') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "KustoPool") - request = build_create_or_update_request_initial( + request = build_create_or_update_request( workspace_name=workspace_name, resource_group_name=resource_group_name, kusto_pool_name=kusto_pool_name, subscription_id=self._config.subscription_id, + if_match=if_match, + if_none_match=if_none_match, api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - if_none_match=if_none_match, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("KustoPool", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('KustoPool', pipeline_response) + deserialized = self._deserialize("KustoPool", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update( self, workspace_name: str, resource_group_name: str, kusto_pool_name: str, - parameters: "_models.KustoPool", + parameters: _models.KustoPool, if_match: Optional[str] = None, if_none_match: Optional[str] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.KustoPool"]: + ) -> LROPoller[_models.KustoPool]: """Create or update a Kusto pool. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param kusto_pool_name: The name of the Kusto pool. + :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. + Required. :type parameters: ~azure.mgmt.synapse.models.KustoPool :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 @@ -1025,9 +1010,9 @@ 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 api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1038,19 +1023,115 @@ def begin_create_or_update( 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.KustoPool"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + workspace_name: str, + resource_group_name: str, + kusto_pool_name: str, + parameters: IO, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.KustoPool]: + """Create or update a Kusto pool. + + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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. + Required. + :type parameters: IO + :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 + :param if_none_match: Set to '*' to allow a new Kusto Pool to be created, but to prevent + 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. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: + """ + + @distributed_trace + def begin_create_or_update( + self, + workspace_name: str, + resource_group_name: str, + kusto_pool_name: str, + parameters: Union[_models.KustoPool, IO], + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[_models.KustoPool]: + """Create or update a Kusto pool. + + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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 + :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 + :param if_none_match: Set to '*' to allow a new Kusto Pool to be created, but to prevent + 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: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.KustoPool] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore workspace_name=workspace_name, resource_group_name=resource_group_name, kusto_pool_name=kusto_pool_name, @@ -1059,119 +1140,139 @@ def begin_create_or_update( if_none_match=if_none_match, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('KustoPool', pipeline_response) + deserialized = self._deserialize("KustoPool", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}"} # type: ignore def _update_initial( self, workspace_name: str, resource_group_name: str, kusto_pool_name: str, - parameters: "_models.KustoPoolUpdate", + parameters: Union[_models.KustoPoolUpdate, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.KustoPool": - cls = kwargs.pop('cls', None) # type: ClsType["_models.KustoPool"] + ) -> _models.KustoPool: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'KustoPoolUpdate') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.KustoPool] - request = build_update_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "KustoPoolUpdate") + + request = build_update_request( workspace_name=workspace_name, resource_group_name=resource_group_name, kusto_pool_name=kusto_pool_name, subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("KustoPool", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('KustoPool', pipeline_response) + deserialized = self._deserialize("KustoPool", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}"} # type: ignore - - @distributed_trace + @overload def begin_update( self, workspace_name: str, resource_group_name: str, kusto_pool_name: str, - parameters: "_models.KustoPoolUpdate", + parameters: _models.KustoPoolUpdate, if_match: Optional[str] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.KustoPool"]: + ) -> LROPoller[_models.KustoPool]: """Update a Kusto Kusto Pool. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param kusto_pool_name: The name of the Kusto pool. + :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. + :param parameters: The Kusto pool parameters supplied to the Update operation. Required. :type parameters: ~azure.mgmt.synapse.models.KustoPoolUpdate :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 api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1182,116 +1283,200 @@ def begin_update( 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.KustoPool"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._update_initial( - workspace_name=workspace_name, - resource_group_name=resource_group_name, - kusto_pool_name=kusto_pool_name, - parameters=parameters, - if_match=if_match, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - **kwargs - ) - kwargs.pop('error_map', None) - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('KustoPool', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized + @overload + def begin_update( + self, + workspace_name: str, + resource_group_name: str, + kusto_pool_name: str, + parameters: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.KustoPool]: + """Update a Kusto Kusto Pool. + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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 + :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. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: + """ - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + @distributed_trace + def begin_update( + self, + workspace_name: str, + resource_group_name: str, + kusto_pool_name: str, + parameters: Union[_models.KustoPoolUpdate, IO], + if_match: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[_models.KustoPool]: + """Update a Kusto Kusto Pool. + + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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 + :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: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.KustoPool] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( # type: ignore + workspace_name=workspace_name, + resource_group_name=resource_group_name, + kusto_pool_name=kusto_pool_name, + parameters=parameters, + if_match=if_match, + api_version=api_version, + content_type=content_type, + 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("KustoPool", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - workspace_name: str, - resource_group_name: str, - kusto_pool_name: str, - **kwargs: Any + self, workspace_name: str, resource_group_name: str, kusto_pool_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( + 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'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - workspace_name: str, - resource_group_name: str, - kusto_pool_name: str, - **kwargs: Any + def begin_delete( + self, workspace_name: str, resource_group_name: str, kusto_pool_name: str, **kwargs: Any ) -> LROPoller[None]: """Deletes a Kusto pool. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1302,109 +1487,109 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore workspace_name=workspace_name, resource_group_name=resource_group_name, kusto_pool_name=kusto_pool_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}"} # type: ignore def _stop_initial( # pylint: disable=inconsistent-return-statements - self, - workspace_name: str, - kusto_pool_name: str, - resource_group_name: str, - **kwargs: Any + self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_stop_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_stop_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._stop_initial.metadata['url'], + template_url=self._stop_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/stop"} # type: ignore - + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/stop"} # type: ignore @distributed_trace - def begin_stop( # pylint: disable=inconsistent-return-statements - self, - workspace_name: str, - kusto_pool_name: str, - resource_group_name: str, - **kwargs: Any + def begin_stop( + self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, **kwargs: Any ) -> LROPoller[None]: """Stops a Kusto pool. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1415,109 +1600,109 @@ def begin_stop( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._stop_initial( + raw_result = self._stop_initial( # type: ignore workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/stop"} # type: ignore + begin_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/stop"} # type: ignore def _start_initial( # pylint: disable=inconsistent-return-statements - self, - workspace_name: str, - kusto_pool_name: str, - resource_group_name: str, - **kwargs: Any + self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_start_request_initial( + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_start_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata['url'], + template_url=self._start_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/start"} # type: ignore - + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/start"} # type: ignore @distributed_trace - def begin_start( # pylint: disable=inconsistent-return-statements - self, - workspace_name: str, - kusto_pool_name: str, - resource_group_name: str, - **kwargs: Any + def begin_start( + self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, **kwargs: Any ) -> LROPoller[None]: """Starts a Kusto pool. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1528,104 +1713,102 @@ def begin_start( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._start_initial( + raw_result = self._start_initial( # type: ignore workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/start"} # type: ignore + begin_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/start"} # type: ignore @distributed_trace def list_skus_by_resource( - self, - workspace_name: str, - kusto_pool_name: str, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.ListResourceSkusResult"]: + self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.AzureResourceSku"]: """Returns the SKUs available for the provided resource. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListResourceSkusResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.ListResourceSkusResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either AzureResourceSku or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.AzureResourceSku] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListResourceSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListResourceSkusResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_skus_by_resource_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, - subscription_id=self._config.subscription_id, 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'], + template_url=self.list_skus_by_resource.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_skus_by_resource_request( - workspace_name=workspace_name, - kusto_pool_name=kusto_pool_name, - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1639,10 +1822,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1653,70 +1834,62 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_skus_by_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/skus"} # type: ignore + list_skus_by_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/skus"} # type: ignore @distributed_trace def list_language_extensions( - self, - workspace_name: str, - kusto_pool_name: str, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.LanguageExtensionsList"]: + self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.LanguageExtension"]: """Returns a list of language extensions that can run within KQL queries. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LanguageExtensionsList or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.LanguageExtensionsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either LanguageExtension or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.LanguageExtension] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LanguageExtensionsList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LanguageExtensionsList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_language_extensions_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_language_extensions.metadata['url'], + template_url=self.list_language_extensions.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_language_extensions_request( - workspace_name=workspace_name, - kusto_pool_name=kusto_pool_name, - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1730,10 +1903,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1744,83 +1915,173 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_language_extensions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/listLanguageExtensions"} # type: ignore + list_language_extensions.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/listLanguageExtensions"} # type: ignore def _add_language_extensions_initial( # pylint: disable=inconsistent-return-statements self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, - language_extensions_to_add: "_models.LanguageExtensionsList", + language_extensions_to_add: Union[_models.LanguageExtensionsList, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(language_extensions_to_add, 'LanguageExtensionsList') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_add_language_extensions_request_initial( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(language_extensions_to_add, (IO, bytes)): + _content = language_extensions_to_add + else: + _json = self._serialize.body(language_extensions_to_add, "LanguageExtensionsList") + + request = build_add_language_extensions_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._add_language_extensions_initial.metadata['url'], + content=_content, + template_url=self._add_language_extensions_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _add_language_extensions_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/addLanguageExtensions"} # type: ignore + _add_language_extensions_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/addLanguageExtensions"} # type: ignore + @overload + def begin_add_language_extensions( + self, + workspace_name: str, + kusto_pool_name: str, + resource_group_name: str, + language_extensions_to_add: _models.LanguageExtensionsList, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Add a list of language extensions that can run within KQL queries. + + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param kusto_pool_name: The name of the Kusto pool. Required. + :type kusto_pool_name: str + :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. Required. + :type language_extensions_to_add: ~azure.mgmt.synapse.models.LanguageExtensionsList + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_add_language_extensions( + self, + workspace_name: str, + kusto_pool_name: str, + resource_group_name: str, + language_extensions_to_add: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Add a list of language extensions that can run within KQL queries. + + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param kusto_pool_name: The name of the Kusto pool. Required. + :type kusto_pool_name: str + :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. Required. + :type language_extensions_to_add: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace - def begin_add_language_extensions( # pylint: disable=inconsistent-return-statements + def begin_add_language_extensions( self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, - language_extensions_to_add: "_models.LanguageExtensionsList", + language_extensions_to_add: Union[_models.LanguageExtensionsList, IO], **kwargs: Any ) -> LROPoller[None]: """Add a list of language extensions that can run within KQL queries. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str :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. - :type language_extensions_to_add: ~azure.mgmt.synapse.models.LanguageExtensionsList - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: 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 @@ -1831,120 +2092,216 @@ def begin_add_language_extensions( # pylint: disable=inconsistent-return-statem Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._add_language_extensions_initial( + raw_result = self._add_language_extensions_initial( # type: ignore workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_name, language_extensions_to_add=language_extensions_to_add, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_add_language_extensions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/addLanguageExtensions"} # type: ignore + begin_add_language_extensions.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/addLanguageExtensions"} # type: ignore def _remove_language_extensions_initial( # pylint: disable=inconsistent-return-statements self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, - language_extensions_to_remove: "_models.LanguageExtensionsList", + language_extensions_to_remove: Union[_models.LanguageExtensionsList, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(language_extensions_to_remove, 'LanguageExtensionsList') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(language_extensions_to_remove, (IO, bytes)): + _content = language_extensions_to_remove + else: + _json = self._serialize.body(language_extensions_to_remove, "LanguageExtensionsList") - request = build_remove_language_extensions_request_initial( + request = build_remove_language_extensions_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._remove_language_extensions_initial.metadata['url'], + content=_content, + template_url=self._remove_language_extensions_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _remove_language_extensions_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/removeLanguageExtensions"} # type: ignore + _remove_language_extensions_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/removeLanguageExtensions"} # type: ignore + + @overload + def begin_remove_language_extensions( + self, + workspace_name: str, + kusto_pool_name: str, + resource_group_name: str, + language_extensions_to_remove: _models.LanguageExtensionsList, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Remove a list of language extensions that can run within KQL queries. + + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param kusto_pool_name: The name of the Kusto pool. Required. + :type kusto_pool_name: str + :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. Required. + :type language_extensions_to_remove: ~azure.mgmt.synapse.models.LanguageExtensionsList + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def begin_remove_language_extensions( + self, + workspace_name: str, + kusto_pool_name: str, + resource_group_name: str, + language_extensions_to_remove: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Remove a list of language extensions that can run within KQL queries. + + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param kusto_pool_name: The name of the Kusto pool. Required. + :type kusto_pool_name: str + :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. Required. + :type language_extensions_to_remove: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace - def begin_remove_language_extensions( # pylint: disable=inconsistent-return-statements + def begin_remove_language_extensions( self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, - language_extensions_to_remove: "_models.LanguageExtensionsList", + language_extensions_to_remove: Union[_models.LanguageExtensionsList, IO], **kwargs: Any ) -> LROPoller[None]: """Remove a list of language extensions that can run within KQL queries. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str :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. - :type language_extensions_to_remove: ~azure.mgmt.synapse.models.LanguageExtensionsList - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: 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 @@ -1955,108 +2312,107 @@ def begin_remove_language_extensions( # pylint: disable=inconsistent-return-sta Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._remove_language_extensions_initial( + raw_result = self._remove_language_extensions_initial( # type: ignore workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_name, language_extensions_to_remove=language_extensions_to_remove, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_remove_language_extensions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/removeLanguageExtensions"} # type: ignore + begin_remove_language_extensions.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/removeLanguageExtensions"} # type: ignore @distributed_trace def list_follower_databases( - self, - workspace_name: str, - kusto_pool_name: str, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.FollowerDatabaseListResult"]: + self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.FollowerDatabaseDefinition"]: """Returns a list of databases that are owned by this Kusto Pool and were followed by another Kusto Pool. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FollowerDatabaseListResult or the result of + :return: An iterator like instance of either FollowerDatabaseDefinition or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.FollowerDatabaseListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.FollowerDatabaseDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.FollowerDatabaseListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.FollowerDatabaseListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_follower_databases_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_follower_databases.metadata['url'], + template_url=self.list_follower_databases.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_follower_databases_request( - workspace_name=workspace_name, - kusto_pool_name=kusto_pool_name, - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2070,10 +2426,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2084,83 +2438,173 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_follower_databases.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/listFollowerDatabases"} # type: ignore + list_follower_databases.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/listFollowerDatabases"} # type: ignore def _detach_follower_databases_initial( # pylint: disable=inconsistent-return-statements self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, - follower_database_to_remove: "_models.FollowerDatabaseDefinition", + follower_database_to_remove: Union[_models.FollowerDatabaseDefinition, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(follower_database_to_remove, 'FollowerDatabaseDefinition') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(follower_database_to_remove, (IO, bytes)): + _content = follower_database_to_remove + else: + _json = self._serialize.body(follower_database_to_remove, "FollowerDatabaseDefinition") - request = build_detach_follower_databases_request_initial( + request = build_detach_follower_databases_request( workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._detach_follower_databases_initial.metadata['url'], + content=_content, + template_url=self._detach_follower_databases_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _detach_follower_databases_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/detachFollowerDatabases"} # type: ignore + _detach_follower_databases_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/detachFollowerDatabases"} # type: ignore + + @overload + def begin_detach_follower_databases( + self, + workspace_name: str, + kusto_pool_name: str, + resource_group_name: str, + follower_database_to_remove: _models.FollowerDatabaseDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Detaches all followers of a database owned by this Kusto Pool. + + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param kusto_pool_name: The name of the Kusto pool. Required. + :type kusto_pool_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param follower_database_to_remove: The follower databases properties to remove. Required. + :type follower_database_to_remove: ~azure.mgmt.synapse.models.FollowerDatabaseDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_detach_follower_databases( + self, + workspace_name: str, + kusto_pool_name: str, + resource_group_name: str, + follower_database_to_remove: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Detaches all followers of a database owned by this Kusto Pool. + :param workspace_name: The name of the workspace. Required. + :type workspace_name: str + :param kusto_pool_name: The name of the Kusto pool. Required. + :type kusto_pool_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param follower_database_to_remove: The follower databases properties to remove. Required. + :type follower_database_to_remove: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace - def begin_detach_follower_databases( # pylint: disable=inconsistent-return-statements + def begin_detach_follower_databases( self, workspace_name: str, kusto_pool_name: str, resource_group_name: str, - follower_database_to_remove: "_models.FollowerDatabaseDefinition", + follower_database_to_remove: Union[_models.FollowerDatabaseDefinition, IO], **kwargs: Any ) -> LROPoller[None]: """Detaches all followers of a database owned by this Kusto Pool. - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param kusto_pool_name: The name of the Kusto pool. + :param kusto_pool_name: The name of the Kusto pool. Required. :type kusto_pool_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param follower_database_to_remove: The follower databases properties to remove. - :type follower_database_to_remove: ~azure.mgmt.synapse.models.FollowerDatabaseDefinition - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: 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 @@ -2171,45 +2615,49 @@ def begin_detach_follower_databases( # pylint: disable=inconsistent-return-stat Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._detach_follower_databases_initial( + raw_result = self._detach_follower_databases_initial( # type: ignore workspace_name=workspace_name, kusto_pool_name=kusto_pool_name, resource_group_name=resource_group_name, follower_database_to_remove=follower_database_to_remove, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_detach_follower_databases.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/detachFollowerDatabases"} # type: ignore + begin_detach_follower_databases.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/kustoPools/{kustoPoolName}/detachFollowerDatabases"} # 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 ba0230eb6130..0e82fcfb0792 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 @@ -8,135 +8,136 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_by_workspace_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/libraries") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/libraries", + ) # 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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class LibrariesOperations(object): - """LibrariesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class LibrariesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`libraries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_workspace( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> Iterable["_models.LibraryListResponse"]: + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> Iterable["_models.LibraryResource"]: """List the libraries in a workspace. List libraries in a workspace. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LibraryListResponse or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.LibraryListResponse] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LibraryListResponse] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LibraryListResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore else: - - request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -150,10 +151,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -164,8 +163,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_workspace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/libraries"} # type: ignore + list_by_workspace.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/libraries"} # type: ignore 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 32a04e3f036c..5a1a11aff21b 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 @@ -8,133 +8,136 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - library_name: str, - workspace_name: str, - **kwargs: Any + resource_group_name: str, library_name: str, workspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/libraries/{libraryName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/libraries/{libraryName}", + ) # 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), - "libraryName": _SERIALIZER.url("library_name", library_name, 'str'), - "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), + "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 + ), + "libraryName": _SERIALIZER.url("library_name", library_name, "str"), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class LibraryOperations(object): - """LibraryOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class LibraryOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`library` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - library_name: str, - workspace_name: str, - **kwargs: Any - ) -> "_models.LibraryResource": + self, resource_group_name: str, library_name: str, workspace_name: str, **kwargs: Any + ) -> _models.LibraryResource: """Get library by name. Get library by name in a workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param library_name: Library name. + :param library_name: Library name. Required. :type library_name: str - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LibraryResource, or the result of cls(response) + :return: LibraryResource or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.LibraryResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LibraryResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.LibraryResource] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -142,12 +145,11 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/libraries/{libraryName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/libraries/{libraryName}"} # 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 e03b21a60d07..969cddf2362d 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 @@ -6,228 +6,260 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, List, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_check_name_availability_request( - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Synapse/checkNameAvailability") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Synapse/checkNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/json") -def build_list_request( - **kwargs: Any -) -> HttpRequest: - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Synapse/operations") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) def build_get_location_header_result_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - operation_id: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, operation_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/operationResults/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/operationResults/{operationId}", + ) # 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'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), + "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"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_azure_async_header_result_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - operation_id: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, operation_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/operationStatuses/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/operationStatuses/{operationId}", + ) # 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'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), + "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"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class Operations(object): - """Operations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def check_name_availability( - self, - request: "_models.CheckNameAvailabilityRequest", - **kwargs: Any - ) -> "_models.CheckNameAvailabilityResponse": + self, request: _models.CheckNameAvailabilityRequest, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResponse: """Check name availability. Check whether a workspace name is available. - :param request: The check request. + :param request: The check request. Required. :type request: ~azure.mgmt.synapse.models.CheckNameAvailabilityRequest - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: + """ + + @overload + def check_name_availability( + self, request: IO, *, 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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) + :return: CheckNameAvailabilityResponse or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.CheckNameAvailabilityResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, request: Union[_models.CheckNameAvailabilityRequest, IO], **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 + :return: CheckNameAvailabilityResponse or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.CheckNameAvailabilityResponse + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(request, 'CheckNameAvailabilityRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(request, (IO, bytes)): + _content = request + else: + _json = self._serialize.body(request, "CheckNameAvailabilityRequest") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -235,48 +267,51 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Synapse/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Synapse/checkNameAvailability"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> List["_models.AvailableRpOperation"]: + def list(self, **kwargs: Any) -> List[_models.AvailableRpOperation]: """All operations. 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) + :return: list of AvailableRpOperation or the result of cls(response) :rtype: list[~azure.mgmt.synapse.models.AvailableRpOperation] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.AvailableRpOperation"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls = kwargs.pop("cls", None) # type: ClsType[List[_models.AvailableRpOperation]] - request = build_list_request( - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -284,67 +319,66 @@ def list( 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/providers/Microsoft.Synapse/operations"} # type: ignore - + list.metadata = {"url": "/providers/Microsoft.Synapse/operations"} # type: ignore @distributed_trace def get_location_header_result( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - operation_id: str, - **kwargs: Any + self, resource_group_name: str, workspace_name: str, operation_id: str, **kwargs: Any ) -> None: """Get operation result. Get the result of an 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param operation_id: Operation ID. + :param operation_id: Operation ID. Required. :type operation_id: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_get_location_header_result_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202, 204]: @@ -355,60 +389,59 @@ def get_location_header_result( # pylint: disable=inconsistent-return-statement if cls: return cls(pipeline_response, None, {}) - get_location_header_result.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/operationResults/{operationId}"} # type: ignore - + get_location_header_result.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/operationResults/{operationId}"} # type: ignore @distributed_trace def get_azure_async_header_result( - self, - resource_group_name: str, - workspace_name: str, - operation_id: str, - **kwargs: Any - ) -> Optional["_models.OperationResource"]: + self, resource_group_name: str, workspace_name: str, operation_id: str, **kwargs: Any + ) -> Optional[_models.OperationResource]: """Get operation status. Get the status of an 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param operation_id: Operation ID. + :param operation_id: Operation ID. Required. :type operation_id: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationResource, or the result of cls(response) + :return: OperationResource or None or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.OperationResource or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationResource"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.OperationResource]] - request = build_get_azure_async_header_result_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 404]: @@ -418,12 +451,11 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_azure_async_header_result.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/operationStatuses/{operationId}"} # type: ignore - + get_azure_async_header_result.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/operationStatuses/{operationId}"} # type: ignore diff --git a/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_patch.py b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/synapse/azure-mgmt-synapse/azure/mgmt/synapse/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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 3b342426913f..3e2cac113a21 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 @@ -6,257 +6,261 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, workspace_name: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # 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'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "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"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, +def build_create_request( resource_group_name: str, workspace_name: str, private_endpoint_connection_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # 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'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "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"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, +def build_delete_request( resource_group_name: str, workspace_name: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # 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'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "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"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateEndpointConnections") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateEndpointConnections", + ) # 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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class PrivateEndpointConnectionsOperations(object): - """PrivateEndpointConnectionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - workspace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + self, resource_group_name: str, workspace_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: """Gets a private endpoint connection. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -264,72 +268,163 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore def _create_initial( self, resource_group_name: str, workspace_name: str, private_endpoint_connection_name: str, - request: "_models.PrivateEndpointConnection", + request: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + ) -> _models.PrivateEndpointConnection: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(request, 'PrivateEndpointConnection') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(request, (IO, bytes)): + _content = request + else: + _json = self._serialize.body(request, "PrivateEndpointConnection") + + request = build_create_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, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + workspace_name: str, + private_endpoint_connection_name: str, + request: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection. + + :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 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: ~azure.mgmt.synapse.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + workspace_name: str, + private_endpoint_connection_name: str, + request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection. + :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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -337,22 +432,24 @@ def begin_create( resource_group_name: str, workspace_name: str, private_endpoint_connection_name: str, - request: "_models.PrivateEndpointConnection", + request: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> LROPoller["_models.PrivateEndpointConnection"]: + ) -> LROPoller[_models.PrivateEndpointConnection]: """Approve or reject a private endpoint connection. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :param request: Request body of private endpoint connection to create. - :type request: ~azure.mgmt.synapse.models.PrivateEndpointConnection - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 @@ -364,121 +461,122 @@ def begin_create( :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] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, private_endpoint_connection_name=private_endpoint_connection_name, request=request, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore def _delete_initial( - self, - resource_group_name: str, - workspace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> Optional["_models.OperationResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationResource"]] + self, resource_group_name: str, workspace_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> Optional[_models.OperationResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.OperationResource]] + + 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'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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 = self._deserialize("OperationResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace def begin_delete( - self, - resource_group_name: str, - workspace_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> LROPoller["_models.OperationResource"]: + self, resource_group_name: str, workspace_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> LROPoller[None]: """Delete a private endpoint connection. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -490,102 +588,102 @@ def begin_delete( :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] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('OperationResource', pipeline_response) + deserialized = self._deserialize("OperationResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnectionList"]: + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: """Lists private endpoint connection in workspace. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionList or the result of + :return: An iterator like instance of either PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.PrivateEndpointConnectionList] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -599,10 +697,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -613,8 +709,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateEndpointConnections"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateEndpointConnections"} # type: ignore 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 8b08362057ca..22ce7613b922 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 @@ -8,179 +8,185 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - private_link_hub_name: str, - **kwargs: Any + resource_group_name: str, private_link_hub_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}/privateEndpointConnections") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}/privateEndpointConnections", + ) # 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), - "privateLinkHubName": _SERIALIZER.url("private_link_hub_name", private_link_hub_name, 'str'), + "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 + ), + "privateLinkHubName": _SERIALIZER.url("private_link_hub_name", private_link_hub_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, resource_group_name: str, private_link_hub_name: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # 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), - "privateLinkHubName": _SERIALIZER.url("private_link_hub_name", private_link_hub_name, 'str'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "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 + ), + "privateLinkHubName": _SERIALIZER.url("private_link_hub_name", private_link_hub_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class PrivateEndpointConnectionsPrivateLinkHubOperations(object): - """PrivateEndpointConnectionsPrivateLinkHubOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class PrivateEndpointConnectionsPrivateLinkHubOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`private_endpoint_connections_private_link_hub` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - private_link_hub_name: str, - **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnectionForPrivateLinkHubResourceCollectionResponse"]: + self, resource_group_name: str, private_link_hub_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnectionForPrivateLinkHub"]: """Get all PrivateEndpointConnections in the PrivateLinkHub. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_link_hub_name: Name of the privateLinkHub. + :param private_link_hub_name: Name of the privateLinkHub. Required. :type private_link_hub_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either - PrivateEndpointConnectionForPrivateLinkHubResourceCollectionResponse or the result of - cls(response) + :return: An iterator like instance of either PrivateEndpointConnectionForPrivateLinkHub or the + result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.PrivateEndpointConnectionForPrivateLinkHubResourceCollectionResponse] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.PrivateEndpointConnectionForPrivateLinkHub] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop( + "cls", None + ) # type: ClsType[_models.PrivateEndpointConnectionForPrivateLinkHubResourceCollectionResponse] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionForPrivateLinkHubResourceCollectionResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, private_link_hub_name=private_link_hub_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - private_link_hub_name=private_link_hub_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnectionForPrivateLinkHubResourceCollectionResponse", pipeline_response) + deserialized = self._deserialize( + "PrivateEndpointConnectionForPrivateLinkHubResourceCollectionResponse", pipeline_response + ) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -189,10 +195,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -203,61 +207,59 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}/privateEndpointConnections"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}/privateEndpointConnections"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - private_link_hub_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> "_models.PrivateEndpointConnectionForPrivateLinkHub": + self, resource_group_name: str, private_link_hub_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnectionForPrivateLinkHub: """Get all PrivateEndpointConnection in the PrivateLinkHub by name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_link_hub_name: Name of the privateLinkHub. + :param private_link_hub_name: Name of the privateLinkHub. Required. :type private_link_hub_name: str - :param private_endpoint_connection_name: Name of the privateEndpointConnection. + :param private_endpoint_connection_name: Name of the privateEndpointConnection. Required. :type private_endpoint_connection_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnectionForPrivateLinkHub, or the result of cls(response) + :return: PrivateEndpointConnectionForPrivateLinkHub or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.PrivateEndpointConnectionForPrivateLinkHub - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionForPrivateLinkHub"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionForPrivateLinkHub] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -265,12 +267,11 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}/privateEndpointConnections/{privateEndpointConnectionName}"} # 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 7598953b5c1b..8a84c75cd57d 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 @@ -8,174 +8,174 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - private_link_hub_name: str, - **kwargs: Any + resource_group_name: str, private_link_hub_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}/privateLinkResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}/privateLinkResources", + ) # 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), - "privateLinkHubName": _SERIALIZER.url("private_link_hub_name", private_link_hub_name, 'str'), + "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 + ), + "privateLinkHubName": _SERIALIZER.url("private_link_hub_name", private_link_hub_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, resource_group_name: str, private_link_hub_name: str, private_link_resource_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}/privateLinkResources/{privateLinkResourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}/privateLinkResources/{privateLinkResourceName}", + ) # 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), - "privateLinkHubName": _SERIALIZER.url("private_link_hub_name", private_link_hub_name, 'str'), - "privateLinkResourceName": _SERIALIZER.url("private_link_resource_name", private_link_resource_name, 'str'), + "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 + ), + "privateLinkHubName": _SERIALIZER.url("private_link_hub_name", private_link_hub_name, "str"), + "privateLinkResourceName": _SERIALIZER.url("private_link_resource_name", private_link_resource_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class PrivateLinkHubPrivateLinkResourcesOperations(object): - """PrivateLinkHubPrivateLinkResourcesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class PrivateLinkHubPrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`private_link_hub_private_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - private_link_hub_name: str, - **kwargs: Any - ) -> Iterable["_models.PrivateLinkResourceListResult"]: + self, resource_group_name: str, private_link_hub_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateLinkResource"]: """Private Link Resources. Get all private link resources for a private link hub. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_link_hub_name: The name of the private link hub. + :param private_link_hub_name: The name of the private link hub. Required. :type private_link_hub_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkResourceListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.PrivateLinkResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, private_link_hub_name=private_link_hub_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - private_link_hub_name=private_link_hub_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -189,10 +189,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -203,63 +201,61 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}/privateLinkResources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}/privateLinkResources"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - private_link_hub_name: str, - private_link_resource_name: str, - **kwargs: Any - ) -> "_models.PrivateLinkResource": + self, resource_group_name: str, private_link_hub_name: str, private_link_resource_name: str, **kwargs: Any + ) -> _models.PrivateLinkResource: """Get Private Link Hub Private Link Resource. Get private link resource in private link hub. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_link_hub_name: The name of the private link hub. + :param private_link_hub_name: The name of the private link hub. Required. :type private_link_hub_name: str - :param private_link_resource_name: The name of the private link resource. + :param private_link_resource_name: The name of the private link resource. Required. :type private_link_resource_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResource, or the result of cls(response) + :return: PrivateLinkResource or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.PrivateLinkResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -267,12 +263,11 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}/privateLinkResources/{privateLinkResourceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}/privateLinkResources/{privateLinkResourceName}"} # 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 f6fcf1014d1e..2ceacd383d39 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 @@ -6,324 +6,292 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - accept = "application/json" +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs", + ) # 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), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - private_link_hub_name: str, - **kwargs: Any + resource_group_name: str, private_link_hub_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}", + ) # 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), - "privateLinkHubName": _SERIALIZER.url("private_link_hub_name", private_link_hub_name, 'str'), + "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 + ), + "privateLinkHubName": _SERIALIZER.url("private_link_hub_name", private_link_hub_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - subscription_id: str, - resource_group_name: str, - private_link_hub_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, private_link_hub_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}", + ) # 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), - "privateLinkHubName": _SERIALIZER.url("private_link_hub_name", private_link_hub_name, 'str'), + "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 + ), + "privateLinkHubName": _SERIALIZER.url("private_link_hub_name", private_link_hub_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, - resource_group_name: str, - private_link_hub_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, private_link_hub_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}", + ) # 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), - "privateLinkHubName": _SERIALIZER.url("private_link_hub_name", private_link_hub_name, 'str'), + "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 + ), + "privateLinkHubName": _SERIALIZER.url("private_link_hub_name", private_link_hub_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - private_link_hub_name: str, - **kwargs: Any + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, private_link_hub_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}", + ) # 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), - "privateLinkHubName": _SERIALIZER.url("private_link_hub_name", private_link_hub_name, 'str'), + "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 + ), + "privateLinkHubName": _SERIALIZER.url("private_link_hub_name", private_link_hub_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Synapse/privateLinkHubs") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class PrivateLinkHubsOperations(object): - """PrivateLinkHubsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class PrivateLinkHubsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`private_link_hubs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.PrivateLinkHubInfoListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.PrivateLinkHub"]: """Returns a list of privateLinkHubs in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkHubInfoListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.PrivateLinkHubInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkHubInfoListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkHubInfoListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -337,10 +305,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -351,57 +317,54 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - private_link_hub_name: str, - **kwargs: Any - ) -> "_models.PrivateLinkHub": + def get(self, resource_group_name: str, private_link_hub_name: str, **kwargs: Any) -> _models.PrivateLinkHub: """Gets a privateLinkHub. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_link_hub_name: Name of the privateLinkHub. + :param private_link_hub_name: Name of the privateLinkHub. Required. :type private_link_hub_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkHub, or the result of cls(response) + :return: PrivateLinkHub or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.PrivateLinkHub - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkHub"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkHub] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -409,68 +372,139 @@ def get( 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}"} # type: ignore + + @overload + def update( + self, + resource_group_name: str, + private_link_hub_name: str, + private_link_hub_patch_info: _models.PrivateLinkHubPatchInfo, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateLinkHub: + """Updates a privateLinkHub. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :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. Required. + :type private_link_hub_patch_info: ~azure.mgmt.synapse.models.PrivateLinkHubPatchInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: + """ + + @overload + def update( + self, + resource_group_name: str, + private_link_hub_name: str, + private_link_hub_patch_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateLinkHub: + """Updates a privateLinkHub. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :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. Required. + :type private_link_hub_patch_info: 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: PrivateLinkHub or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.PrivateLinkHub + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( self, resource_group_name: str, private_link_hub_name: str, - private_link_hub_patch_info: "_models.PrivateLinkHubPatchInfo", + private_link_hub_patch_info: Union[_models.PrivateLinkHubPatchInfo, IO], **kwargs: Any - ) -> "_models.PrivateLinkHub": + ) -> _models.PrivateLinkHub: """Updates a privateLinkHub. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_link_hub_name: Name of the privateLinkHub. + :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. - :type private_link_hub_patch_info: ~azure.mgmt.synapse.models.PrivateLinkHubPatchInfo - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 - :return: PrivateLinkHub, or the result of cls(response) + :return: PrivateLinkHub or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.PrivateLinkHub - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkHub"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(private_link_hub_patch_info, 'PrivateLinkHubPatchInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkHub] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_link_hub_patch_info, (IO, bytes)): + _content = private_link_hub_patch_info + else: + _json = self._serialize.body(private_link_hub_patch_info, "PrivateLinkHubPatchInfo") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, private_link_hub_name=private_link_hub_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -479,71 +513,142 @@ def update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateLinkHub', pipeline_response) + deserialized = self._deserialize("PrivateLinkHub", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateLinkHub', pipeline_response) + deserialized = self._deserialize("PrivateLinkHub", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}"} # type: ignore + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}"} # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + private_link_hub_name: str, + private_link_hub_info: _models.PrivateLinkHub, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateLinkHub: + """Creates or updates a privateLinkHub. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :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_info: PrivateLinkHub create or update request properties. Required. + :type private_link_hub_info: ~azure.mgmt.synapse.models.PrivateLinkHub + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + private_link_hub_name: str, + private_link_hub_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateLinkHub: + """Creates or updates a privateLinkHub. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :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_info: PrivateLinkHub create or update request properties. Required. + :type private_link_hub_info: 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: PrivateLinkHub or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.PrivateLinkHub + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update( self, resource_group_name: str, private_link_hub_name: str, - private_link_hub_info: "_models.PrivateLinkHub", + private_link_hub_info: Union[_models.PrivateLinkHub, IO], **kwargs: Any - ) -> "_models.PrivateLinkHub": + ) -> _models.PrivateLinkHub: """Creates or updates a privateLinkHub. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_link_hub_name: Name of the privateLinkHub. + :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. - :type private_link_hub_info: ~azure.mgmt.synapse.models.PrivateLinkHub - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 - :return: PrivateLinkHub, or the result of cls(response) + :return: PrivateLinkHub or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.PrivateLinkHub - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkHub"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkHub] - _json = self._serialize.body(private_link_hub_info, 'PrivateLinkHub') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_link_hub_info, (IO, bytes)): + _content = private_link_hub_info + else: + _json = self._serialize.body(private_link_hub_info, "PrivateLinkHub") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, private_link_hub_name=private_link_hub_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -552,77 +657,72 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateLinkHub', pipeline_response) + deserialized = self._deserialize("PrivateLinkHub", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateLinkHub', pipeline_response) + deserialized = self._deserialize("PrivateLinkHub", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - private_link_hub_name: str, - **kwargs: Any + self, resource_group_name: str, private_link_hub_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + 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'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - private_link_hub_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, private_link_hub_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a privateLinkHub. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_link_hub_name: Name of the privateLinkHub. + :param private_link_hub_name: Name of the privateLinkHub. Required. :type private_link_hub_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -633,88 +733,89 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, private_link_hub_name=private_link_hub_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/privateLinkHubs/{privateLinkHubName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.PrivateLinkHubInfoListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.PrivateLinkHub"]: """Returns a list of privateLinkHubs in a subscription. - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkHubInfoListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.PrivateLinkHubInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkHubInfoListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkHubInfoListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -728,10 +829,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -742,8 +841,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Synapse/privateLinkHubs"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Synapse/privateLinkHubs"} # type: ignore 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 3447b67139f4..086e17cff063 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 @@ -8,174 +8,170 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateLinkResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateLinkResources", + ) # 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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - private_link_resource_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, private_link_resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateLinkResources/{privateLinkResourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateLinkResources/{privateLinkResourceName}", + ) # 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'), - "privateLinkResourceName": _SERIALIZER.url("private_link_resource_name", private_link_resource_name, 'str'), + "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"), + "privateLinkResourceName": _SERIALIZER.url("private_link_resource_name", private_link_resource_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class PrivateLinkResourcesOperations(object): - """PrivateLinkResourcesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`private_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> Iterable["_models.PrivateLinkResourceListResult"]: + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateLinkResource"]: """Private Link Resources. Get all private link resources for a workspaces. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkResourceListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.PrivateLinkResourceListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -189,10 +185,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -203,63 +197,61 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateLinkResources"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateLinkResources"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - workspace_name: str, - private_link_resource_name: str, - **kwargs: Any - ) -> "_models.PrivateLinkResource": + self, resource_group_name: str, workspace_name: str, private_link_resource_name: str, **kwargs: Any + ) -> _models.PrivateLinkResource: """Get Private Link Resource. Get private link resource in workspace. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param private_link_resource_name: The name of the private link resource. + :param private_link_resource_name: The name of the private link resource. Required. :type private_link_resource_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResource, or the result of cls(response) + :return: PrivateLinkResource or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.PrivateLinkResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -267,12 +259,11 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateLinkResources/{privateLinkResourceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/privateLinkResources/{privateLinkResourceName}"} # 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 e15ee2667b7f..67aa93fe3ba8 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 @@ -8,169 +8,175 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, workspace_name: str, restorable_dropped_sql_pool_id: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/restorableDroppedSqlPools/{restorableDroppedSqlPoolId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/restorableDroppedSqlPools/{restorableDroppedSqlPoolId}", + ) # 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'), - "restorableDroppedSqlPoolId": _SERIALIZER.url("restorable_dropped_sql_pool_id", restorable_dropped_sql_pool_id, 'str'), + "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"), + "restorableDroppedSqlPoolId": _SERIALIZER.url( + "restorable_dropped_sql_pool_id", restorable_dropped_sql_pool_id, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_workspace_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/restorableDroppedSqlPools") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/restorableDroppedSqlPools", + ) # 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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class RestorableDroppedSqlPoolsOperations(object): - """RestorableDroppedSqlPoolsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class RestorableDroppedSqlPoolsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`restorable_dropped_sql_pools` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - workspace_name: str, - restorable_dropped_sql_pool_id: str, - **kwargs: Any - ) -> "_models.RestorableDroppedSqlPool": + self, resource_group_name: str, workspace_name: str, restorable_dropped_sql_pool_id: str, **kwargs: Any + ) -> _models.RestorableDroppedSqlPool: """Gets a deleted sql pool that can be restored. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str :param restorable_dropped_sql_pool_id: The id of the deleted Sql Pool in the form of - sqlPoolName,deletionTimeInFileTimeFormat. + sqlPoolName,deletionTimeInFileTimeFormat. Required. :type restorable_dropped_sql_pool_id: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RestorableDroppedSqlPool, or the result of cls(response) + :return: RestorableDroppedSqlPool or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.RestorableDroppedSqlPool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorableDroppedSqlPool"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RestorableDroppedSqlPool] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -178,70 +184,65 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/restorableDroppedSqlPools/{restorableDroppedSqlPoolId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/restorableDroppedSqlPools/{restorableDroppedSqlPoolId}"} # type: ignore @distributed_trace def list_by_workspace( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> Iterable["_models.RestorableDroppedSqlPoolListResult"]: + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> Iterable["_models.RestorableDroppedSqlPool"]: """Gets a list of deleted Sql pools that can be restored. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RestorableDroppedSqlPoolListResult or the result - of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.RestorableDroppedSqlPoolListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either RestorableDroppedSqlPool or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.RestorableDroppedSqlPool] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RestorableDroppedSqlPoolListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorableDroppedSqlPoolListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore else: - - request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -255,10 +256,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -269,8 +268,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_workspace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/restorableDroppedSqlPools"} # type: ignore + list_by_workspace.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/restorableDroppedSqlPools"} # type: ignore 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 d9159765466c..1c52e6c77302 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 @@ -8,133 +8,136 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - spark_configuration_name: str, - workspace_name: str, - **kwargs: Any + resource_group_name: str, spark_configuration_name: str, workspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sparkconfigurations/{sparkConfigurationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sparkconfigurations/{sparkConfigurationName}", + ) # 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), - "sparkConfigurationName": _SERIALIZER.url("spark_configuration_name", spark_configuration_name, 'str'), - "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), + "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 + ), + "sparkConfigurationName": _SERIALIZER.url("spark_configuration_name", spark_configuration_name, "str"), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class SparkConfigurationOperations(object): - """SparkConfigurationOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SparkConfigurationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`spark_configuration` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - spark_configuration_name: str, - workspace_name: str, - **kwargs: Any - ) -> "_models.SparkConfigurationResource": + self, resource_group_name: str, spark_configuration_name: str, workspace_name: str, **kwargs: Any + ) -> _models.SparkConfigurationResource: """Get SparkConfiguration by name. Get SparkConfiguration by name in a workspace. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param spark_configuration_name: SparkConfiguration name. + :param spark_configuration_name: SparkConfiguration name. Required. :type spark_configuration_name: str - :param workspace_name: The name of the workspace. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SparkConfigurationResource, or the result of cls(response) + :return: SparkConfigurationResource or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SparkConfigurationResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SparkConfigurationResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SparkConfigurationResource] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -142,12 +145,11 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sparkconfigurations/{sparkConfigurationName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sparkconfigurations/{sparkConfigurationName}"} # 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 51df56483aae..f34b790cce9c 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 @@ -8,136 +8,137 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_by_workspace_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sparkconfigurations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sparkconfigurations", + ) # 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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class SparkConfigurationsOperations(object): - """SparkConfigurationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SparkConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`spark_configurations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_workspace( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> Iterable["_models.SparkConfigurationListResponse"]: + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> Iterable["_models.SparkConfigurationResource"]: """List the sparkConfigurations in a workspace. List sparkConfigurations in a workspace. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SparkConfigurationListResponse or the result of + :return: An iterator like instance of either SparkConfigurationResource or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.SparkConfigurationListResponse] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.SparkConfigurationResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01-preview")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SparkConfigurationListResponse] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SparkConfigurationListResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore else: - - request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -151,10 +152,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -165,8 +164,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_workspace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sparkconfigurations"} # type: ignore + list_by_workspace.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sparkconfigurations"} # type: ignore 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 caf7f34b4dc7..1dd7a1ecb048 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 @@ -6,245 +6,305 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, sql_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - blob_auditing_policy_name = kwargs.pop('blob_auditing_policy_name', "default") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + blob_auditing_policy_name = kwargs.pop("blob_auditing_policy_name", "default") # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/auditingSettings/{blobAuditingPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/auditingSettings/{blobAuditingPolicyName}", + ) # 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'), - "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, 'str'), + "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"), + "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, workspace_name: str, sql_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - blob_auditing_policy_name = kwargs.pop('blob_auditing_policy_name', "default") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + blob_auditing_policy_name = kwargs.pop("blob_auditing_policy_name", "default") # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/auditingSettings/{blobAuditingPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/auditingSettings/{blobAuditingPolicyName}", + ) # 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'), - "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, 'str'), + "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"), + "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_sql_pool_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, sql_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/auditingSettings") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/auditingSettings", + ) # 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'), + "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 = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class SqlPoolBlobAuditingPoliciesOperations(object): - """SqlPoolBlobAuditingPoliciesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SqlPoolBlobAuditingPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`sql_pool_blob_auditing_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> "_models.SqlPoolBlobAuditingPolicy": + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> _models.SqlPoolBlobAuditingPolicy: """Get a SQL pool's blob auditing policy. Get a SQL pool's blob auditing policy. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword 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) + :return: SqlPoolBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolBlobAuditingPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolBlobAuditingPolicy"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - blob_auditing_policy_name = kwargs.pop('blob_auditing_policy_name', "default") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + blob_auditing_policy_name = kwargs.pop("blob_auditing_policy_name", "default") # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolBlobAuditingPolicy] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/auditingSettings/{blobAuditingPolicyName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/auditingSettings/{blobAuditingPolicyName}"} # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + parameters: _models.SqlPoolBlobAuditingPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SqlPoolBlobAuditingPolicy: + """Creates or updates a SQL pool's blob auditing policy. + + Creates or updates a SQL pool's blob auditing policy. + :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 database blob auditing policy. Required. + :type parameters: ~azure.mgmt.synapse.models.SqlPoolBlobAuditingPolicy + :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: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SqlPoolBlobAuditingPolicy: + """Creates or updates a SQL pool's blob auditing policy. + + Creates or updates a SQL pool's blob auditing policy. + + :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 database blob auditing policy. 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 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: + """ @distributed_trace def create_or_update( @@ -252,63 +312,79 @@ def create_or_update( resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: "_models.SqlPoolBlobAuditingPolicy", + parameters: Union[_models.SqlPoolBlobAuditingPolicy, IO], **kwargs: Any - ) -> "_models.SqlPoolBlobAuditingPolicy": + ) -> _models.SqlPoolBlobAuditingPolicy: """Creates or updates a SQL pool's blob auditing policy. Creates or updates a SQL pool's blob auditing policy. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param parameters: The database blob auditing policy. - :type parameters: ~azure.mgmt.synapse.models.SqlPoolBlobAuditingPolicy - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 - :return: SqlPoolBlobAuditingPolicy, or the result of cls(response) + :return: SqlPoolBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolBlobAuditingPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolBlobAuditingPolicy"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - blob_auditing_policy_name = kwargs.pop('blob_auditing_policy_name', "default") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'SqlPoolBlobAuditingPolicy') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + blob_auditing_policy_name = kwargs.pop("blob_auditing_policy_name", "default") # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolBlobAuditingPolicy] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SqlPoolBlobAuditingPolicy") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, 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, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -316,78 +392,71 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('SqlPoolBlobAuditingPolicy', pipeline_response) + deserialized = self._deserialize("SqlPoolBlobAuditingPolicy", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SqlPoolBlobAuditingPolicy', pipeline_response) + deserialized = self._deserialize("SqlPoolBlobAuditingPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/auditingSettings/{blobAuditingPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/auditingSettings/{blobAuditingPolicyName}"} # type: ignore @distributed_trace def list_by_sql_pool( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> Iterable["_models.SqlPoolBlobAuditingPolicyListResult"]: + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> Iterable["_models.SqlPoolBlobAuditingPolicy"]: """Lists auditing settings of 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SqlPoolBlobAuditingPolicyListResult or the result - of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.SqlPoolBlobAuditingPolicyListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SqlPoolBlobAuditingPolicy or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.SqlPoolBlobAuditingPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolBlobAuditingPolicyListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolBlobAuditingPolicyListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_sql_pool_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore else: - - request = build_list_by_sql_pool_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -401,10 +470,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -414,8 +481,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_sql_pool.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/auditingSettings"} # type: ignore + list_by_sql_pool.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/auditingSettings"} # type: ignore 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 540a0d7fe75e..bcf6247091b5 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 @@ -8,87 +8,94 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, schema_name: str, table_name: str, column_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}", + ) # 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'), - "schemaName": _SERIALIZER.url("schema_name", schema_name, 'str'), - "tableName": _SERIALIZER.url("table_name", table_name, 'str'), - "columnName": _SERIALIZER.url("column_name", column_name, 'str'), + "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"), + "schemaName": _SERIALIZER.url("schema_name", schema_name, "str"), + "tableName": _SERIALIZER.url("table_name", table_name, "str"), + "columnName": _SERIALIZER.url("column_name", column_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class SqlPoolColumnsOperations(object): - """SqlPoolColumnsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SqlPoolColumnsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`sql_pool_columns` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( @@ -100,69 +107,72 @@ def get( table_name: str, column_name: str, **kwargs: Any - ) -> "_models.SqlPoolColumn": + ) -> _models.SqlPoolColumn: """Get Sql pool column. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param schema_name: The name of the schema. + :param schema_name: The name of the schema. Required. :type schema_name: str - :param table_name: The name of the table. + :param table_name: The name of the table. Required. :type table_name: str - :param column_name: The name of the column. + :param column_name: The name of the column. Required. :type column_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SqlPoolColumn, or the result of cls(response) + :return: SqlPoolColumn or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolColumn - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolColumn"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolColumn] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, schema_name=schema_name, table_name=table_name, column_name=column_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}"} # 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 886ba3fcd4ee..5bf43f5187dc 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 @@ -8,83 +8,90 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar, Union -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, connection_policy_name: Union[str, "_models.ConnectionPolicyName"], + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/connectionPolicies/{connectionPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/connectionPolicies/{connectionPolicyName}", + ) # 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'), - "connectionPolicyName": _SERIALIZER.url("connection_policy_name", connection_policy_name, 'str'), + "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"), + "connectionPolicyName": _SERIALIZER.url("connection_policy_name", connection_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class SqlPoolConnectionPoliciesOperations(object): - """SqlPoolConnectionPoliciesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SqlPoolConnectionPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`sql_pool_connection_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( @@ -94,53 +101,57 @@ def get( sql_pool_name: str, connection_policy_name: Union[str, "_models.ConnectionPolicyName"], **kwargs: Any - ) -> "_models.SqlPoolConnectionPolicy": + ) -> _models.SqlPoolConnectionPolicy: """Get a Sql pool's connection policy, which is used with table auditing. Get a Sql pool's connection policy, which is used with table auditing. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param connection_policy_name: The name of the connection policy. + :param connection_policy_name: The name of the connection policy. "default" Required. :type connection_policy_name: str or ~azure.mgmt.synapse.models.ConnectionPolicyName - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SqlPoolConnectionPolicy, or the result of cls(response) + :return: SqlPoolConnectionPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolConnectionPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolConnectionPolicy"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolConnectionPolicy] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -148,12 +159,11 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/connectionPolicies/{connectionPolicyName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/connectionPolicies/{connectionPolicyName}"} # 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 c62b83edb211..da2d77f6f24b 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 @@ -8,83 +8,92 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar, Union -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, data_warehouse_user_activity_name: Union[str, "_models.DataWarehouseUserActivityName"], + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataWarehouseUserActivities/{dataWarehouseUserActivityName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataWarehouseUserActivities/{dataWarehouseUserActivityName}", + ) # 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'), - "dataWarehouseUserActivityName": _SERIALIZER.url("data_warehouse_user_activity_name", data_warehouse_user_activity_name, 'str'), + "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"), + "dataWarehouseUserActivityName": _SERIALIZER.url( + "data_warehouse_user_activity_name", data_warehouse_user_activity_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class SqlPoolDataWarehouseUserActivitiesOperations(object): - """SqlPoolDataWarehouseUserActivitiesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SqlPoolDataWarehouseUserActivitiesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`sql_pool_data_warehouse_user_activities` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( @@ -94,66 +103,70 @@ def get( sql_pool_name: str, data_warehouse_user_activity_name: Union[str, "_models.DataWarehouseUserActivityName"], **kwargs: Any - ) -> "_models.DataWarehouseUserActivities": + ) -> _models.DataWarehouseUserActivities: """Get SQL pool user activities. Gets the user activities of a SQL pool which includes running and suspended queries. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param data_warehouse_user_activity_name: The activity name of the Sql pool. + :param data_warehouse_user_activity_name: The activity name of the Sql pool. "current" + Required. :type data_warehouse_user_activity_name: str or ~azure.mgmt.synapse.models.DataWarehouseUserActivityName - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DataWarehouseUserActivities, or the result of cls(response) + :return: DataWarehouseUserActivities or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.DataWarehouseUserActivities - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DataWarehouseUserActivities"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataWarehouseUserActivities] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataWarehouseUserActivities/{dataWarehouseUserActivityName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/dataWarehouseUserActivities/{dataWarehouseUserActivityName}"} # 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 50ddfb6c5629..c62e10630446 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 @@ -6,234 +6,225 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, sql_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/geoBackupPolicies") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/geoBackupPolicies", + ) # 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'), + "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 = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, geo_backup_policy_name: Union[str, "_models.GeoBackupPolicyName"], - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/geoBackupPolicies/{geoBackupPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/geoBackupPolicies/{geoBackupPolicyName}", + ) # 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'), - "geoBackupPolicyName": _SERIALIZER.url("geo_backup_policy_name", geo_backup_policy_name, 'str'), + "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"), + "geoBackupPolicyName": _SERIALIZER.url("geo_backup_policy_name", geo_backup_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, geo_backup_policy_name: Union[str, "_models.GeoBackupPolicyName"], + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/geoBackupPolicies/{geoBackupPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/geoBackupPolicies/{geoBackupPolicyName}", + ) # 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'), - "geoBackupPolicyName": _SERIALIZER.url("geo_backup_policy_name", geo_backup_policy_name, 'str'), + "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"), + "geoBackupPolicyName": _SERIALIZER.url("geo_backup_policy_name", geo_backup_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class SqlPoolGeoBackupPoliciesOperations(object): - """SqlPoolGeoBackupPoliciesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SqlPoolGeoBackupPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`sql_pool_geo_backup_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> Iterable["_models.GeoBackupPolicyListResult"]: + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> Iterable["_models.GeoBackupPolicy"]: """List SQL pool geo backup policies. Get list of SQL pool geo backup policies. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GeoBackupPolicyListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.GeoBackupPolicyListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GeoBackupPolicyListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GeoBackupPolicyListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, 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'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -247,10 +238,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -261,72 +250,156 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/geoBackupPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/geoBackupPolicies"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, geo_backup_policy_name: Union[str, "_models.GeoBackupPolicyName"], - parameters: "_models.GeoBackupPolicy", + parameters: _models.GeoBackupPolicy, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.GeoBackupPolicy": + ) -> _models.GeoBackupPolicy: """Updates a SQL Pool geo backup policy. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param geo_backup_policy_name: The name of the geo backup policy. + :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. + Required. :type parameters: ~azure.mgmt.synapse.models.GeoBackupPolicy - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + geo_backup_policy_name: Union[str, "_models.GeoBackupPolicyName"], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GeoBackupPolicy: + """Updates a SQL Pool geo backup policy. + + :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 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. + 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: GeoBackupPolicy or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.GeoBackupPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + geo_backup_policy_name: Union[str, "_models.GeoBackupPolicyName"], + parameters: Union[_models.GeoBackupPolicy, IO], + **kwargs: Any + ) -> _models.GeoBackupPolicy: + """Updates a SQL Pool geo backup policy. + + :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 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 - :return: GeoBackupPolicy, or the result of cls(response) + :return: GeoBackupPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.GeoBackupPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GeoBackupPolicy"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GeoBackupPolicy] - _json = self._serialize.body(parameters, 'GeoBackupPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "GeoBackupPolicy") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, 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, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -335,18 +408,17 @@ def create_or_update( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('GeoBackupPolicy', pipeline_response) + deserialized = self._deserialize("GeoBackupPolicy", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GeoBackupPolicy', pipeline_response) + deserialized = self._deserialize("GeoBackupPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/geoBackupPolicies/{geoBackupPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/geoBackupPolicies/{geoBackupPolicyName}"} # type: ignore @distributed_trace def get( @@ -356,53 +428,57 @@ def get( sql_pool_name: str, geo_backup_policy_name: Union[str, "_models.GeoBackupPolicyName"], **kwargs: Any - ) -> "_models.GeoBackupPolicy": + ) -> _models.GeoBackupPolicy: """Get a SQL pool geo backup policy. Get the specified SQL pool geo backup policy. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param geo_backup_policy_name: The name of the geo backup policy. + :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 api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GeoBackupPolicy, or the result of cls(response) + :return: GeoBackupPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.GeoBackupPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GeoBackupPolicy"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GeoBackupPolicy] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -410,12 +486,11 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/geoBackupPolicies/{geoBackupPolicyName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/geoBackupPolicies/{geoBackupPolicyName}"} # 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 c7c958143ba8..d0c7e46ce1da 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 @@ -8,84 +8,93 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, + subscription_id: str, *, maintenance_window_options_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/maintenanceWindowOptions/current") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/maintenanceWindowOptions/current", + ) # 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'), + "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 = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - _query_parameters['maintenanceWindowOptionsName'] = _SERIALIZER.query("maintenance_window_options_name", maintenance_window_options_name, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["maintenanceWindowOptionsName"] = _SERIALIZER.query( + "maintenance_window_options_name", maintenance_window_options_name, "str" + ) # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class SqlPoolMaintenanceWindowOptionsOperations(object): - """SqlPoolMaintenanceWindowOptionsOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class SqlPoolMaintenanceWindowOptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`sql_pool_maintenance_window_options` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( @@ -95,65 +104,68 @@ def get( sql_pool_name: str, maintenance_window_options_name: str, **kwargs: Any - ) -> "_models.MaintenanceWindowOptions": + ) -> _models.MaintenanceWindowOptions: """SQL pool's available maintenance windows. Get list of SQL pool's available maintenance windows. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param maintenance_window_options_name: Maintenance window options name. + :param maintenance_window_options_name: Maintenance window options name. Required. :type maintenance_window_options_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MaintenanceWindowOptions, or the result of cls(response) + :return: MaintenanceWindowOptions or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.MaintenanceWindowOptions - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MaintenanceWindowOptions"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MaintenanceWindowOptions] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, - api_version=api_version, + subscription_id=self._config.subscription_id, maintenance_window_options_name=maintenance_window_options_name, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/maintenanceWindowOptions/current"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/maintenanceWindowOptions/current"} # 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 c7c2fc6ba3c3..0f91b10f0fb2 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 @@ -6,133 +6,134 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, + subscription_id: str, *, maintenance_window_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/maintenancewindows/current") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/maintenancewindows/current", + ) # 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'), + "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 = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - _query_parameters['maintenanceWindowName'] = _SERIALIZER.query("maintenance_window_name", maintenance_window_name, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["maintenanceWindowName"] = _SERIALIZER.query("maintenance_window_name", maintenance_window_name, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, + subscription_id: str, *, maintenance_window_name: str, - json: JSONType = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/maintenancewindows/current") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/maintenancewindows/current", + ) # 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'), + "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 = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - _query_parameters['maintenanceWindowName'] = _SERIALIZER.query("maintenance_window_name", maintenance_window_name, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["maintenanceWindowName"] = _SERIALIZER.query("maintenance_window_name", maintenance_window_name, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - -class SqlPoolMaintenanceWindowsOperations(object): - """SqlPoolMaintenanceWindowsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +class SqlPoolMaintenanceWindowsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`sql_pool_maintenance_windows` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( @@ -142,53 +143,57 @@ def get( sql_pool_name: str, maintenance_window_name: str, **kwargs: Any - ) -> "_models.MaintenanceWindows": + ) -> _models.MaintenanceWindows: """Get a SQL pool's Maintenance Windows. Get a SQL pool's Maintenance Windows. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param maintenance_window_name: Maintenance window name. + :param maintenance_window_name: Maintenance window name. Required. :type maintenance_window_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MaintenanceWindows, or the result of cls(response) + :return: MaintenanceWindows or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.MaintenanceWindows - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MaintenanceWindows"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MaintenanceWindows] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, - api_version=api_version, + subscription_id=self._config.subscription_id, maintenance_window_name=maintenance_window_name, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -196,15 +201,88 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/maintenancewindows/current"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/maintenancewindows/current"} # type: ignore + + @overload + def create_or_update( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + maintenance_window_name: str, + parameters: _models.MaintenanceWindows, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Creates or updates a Sql pool's maintenance windows settings. + + Creates or updates a Sql pool's maintenance windows settings. + + :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 maintenance_window_name: Maintenance window name. Required. + :type maintenance_window_name: str + :param parameters: The required parameters for creating or updating Maintenance Windows + settings. Required. + :type parameters: ~azure.mgmt.synapse.models.MaintenanceWindows + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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 + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + maintenance_window_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Creates or updates a Sql pool's maintenance windows settings. + + Creates or updates a Sql pool's maintenance windows settings. + :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 maintenance_window_name: Maintenance window name. Required. + :type maintenance_window_name: str + :param parameters: The required parameters for creating or updating Maintenance Windows + settings. 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 create_or_update( # pylint: disable=inconsistent-return-statements @@ -213,7 +291,7 @@ def create_or_update( # pylint: disable=inconsistent-return-statements workspace_name: str, sql_pool_name: str, maintenance_window_name: str, - parameters: "_models.MaintenanceWindows", + parameters: Union[_models.MaintenanceWindows, IO], **kwargs: Any ) -> None: """Creates or updates a Sql pool's maintenance windows settings. @@ -221,54 +299,69 @@ def create_or_update( # pylint: disable=inconsistent-return-statements Creates or updates a Sql pool's maintenance windows settings. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param maintenance_window_name: Maintenance window name. + :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. - :type parameters: ~azure.mgmt.synapse.models.MaintenanceWindows - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + 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 - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'MaintenanceWindows') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "MaintenanceWindows") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, 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, content_type=content_type, - maintenance_window_name=maintenance_window_name, json=_json, - template_url=self.create_or_update.metadata['url'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -278,5 +371,4 @@ def create_or_update( # pylint: disable=inconsistent-return-statements 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"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/maintenancewindows/current"} # 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 9bb9d3f9bdd2..6f3fc18881d1 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 @@ -6,200 +6,256 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, sql_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/metadataSync/config") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/metadataSync/config", + ) # 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'), + "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 = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, workspace_name: str, sql_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/metadataSync/config") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/metadataSync/config", + ) # 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'), + "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 = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - -class SqlPoolMetadataSyncConfigsOperations(object): - """SqlPoolMetadataSyncConfigsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +class SqlPoolMetadataSyncConfigsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`sql_pool_metadata_sync_configs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> Optional["_models.MetadataSyncConfig"]: + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> _models.MetadataSyncConfig: """Get SQL pool metadata sync config. Get the metadata sync configuration for 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword 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 or None - :raises: ~azure.core.exceptions.HttpResponseError + :return: MetadataSyncConfig or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.MetadataSyncConfig + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.MetadataSyncConfig"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetadataSyncConfig] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response - if response.status_code not in [200, 404]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('MetadataSyncConfig', pipeline_response) + deserialized = self._deserialize("MetadataSyncConfig", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/metadataSync/config"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/metadataSync/config"} # type: ignore + + @overload + def create( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + metadata_sync_configuration: _models.MetadataSyncConfig, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MetadataSyncConfig: + """Set SQL pool metadata sync config. + + Set the metadata sync configuration for 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 metadata_sync_configuration: Metadata sync configuration. Required. + :type metadata_sync_configuration: ~azure.mgmt.synapse.models.MetadataSyncConfig + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: + """ + + @overload + def create( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + metadata_sync_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.MetadataSyncConfig: + """Set SQL pool metadata sync config. + + Set the metadata sync configuration for 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 metadata_sync_configuration: Metadata sync configuration. Required. + :type metadata_sync_configuration: 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: MetadataSyncConfig or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.MetadataSyncConfig + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create( @@ -207,73 +263,86 @@ def create( resource_group_name: str, workspace_name: str, sql_pool_name: str, - metadata_sync_configuration: "_models.MetadataSyncConfig", + metadata_sync_configuration: Union[_models.MetadataSyncConfig, IO], **kwargs: Any - ) -> Optional["_models.MetadataSyncConfig"]: + ) -> _models.MetadataSyncConfig: """Set SQL pool metadata sync config. Set the metadata sync configuration for 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param metadata_sync_configuration: Metadata sync configuration. - :type metadata_sync_configuration: ~azure.mgmt.synapse.models.MetadataSyncConfig - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 - :return: MetadataSyncConfig, or the result of cls(response) - :rtype: ~azure.mgmt.synapse.models.MetadataSyncConfig or None - :raises: ~azure.core.exceptions.HttpResponseError + :return: MetadataSyncConfig or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.MetadataSyncConfig + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.MetadataSyncConfig"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(metadata_sync_configuration, 'MetadataSyncConfig') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MetadataSyncConfig] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(metadata_sync_configuration, (IO, bytes)): + _content = metadata_sync_configuration + else: + _json = self._serialize.body(metadata_sync_configuration, "MetadataSyncConfig") request = build_create_request( - subscription_id=self._config.subscription_id, 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, - template_url=self.create.metadata['url'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response - if response.status_code not in [200, 404]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('MetadataSyncConfig', pipeline_response) + deserialized = self._deserialize("MetadataSyncConfig", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/metadataSync/config"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/metadataSync/config"} # 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 04e983609000..73d25be5a536 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 @@ -6,141 +6,153 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_location_header_result_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, operation_id: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/operationResults/{operationId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/operationResults/{operationId}", + ) # 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'), - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), + "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"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class SqlPoolOperationResultsOperations(object): - """SqlPoolOperationResultsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SqlPoolOperationResultsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`sql_pool_operation_results` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get_location_header_result( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - operation_id: str, - **kwargs: Any - ) -> Any: + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, operation_id: str, **kwargs: Any + ) -> JSON: """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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param operation_id: Operation ID. + :param operation_id: Operation ID. Required. :type operation_id: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: any, or the result of cls(response) - :rtype: any - :raises: ~azure.core.exceptions.HttpResponseError + :return: JSON or the result of cls(response) + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Any] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[JSON] - request = build_get_location_header_result_request( - subscription_id=self._config.subscription_id, 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.metadata['url'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -149,15 +161,14 @@ def get_location_header_result( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('object', pipeline_response) + deserialized = self._deserialize("object", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('object', pipeline_response) + deserialized = self._deserialize("object", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_location_header_result.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/operationResults/{operationId}"} # type: ignore - + get_location_header_result.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/operationResults/{operationId}"} # type: ignore 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 b108ddc56000..da1c1d86bf5b 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 @@ -8,144 +8,140 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, sql_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/operations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/operations", + ) # 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'), + "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 = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class SqlPoolOperationsOperations(object): - """SqlPoolOperationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SqlPoolOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`sql_pool_operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> Iterable["_models.SqlPoolBlobAuditingPolicySqlPoolOperationListResult"]: + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> Iterable["_models.SqlPoolOperation"]: """Gets a list of operations performed on the SQL pool. Gets a list of operations performed on the 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either - SqlPoolBlobAuditingPolicySqlPoolOperationListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.SqlPoolBlobAuditingPolicySqlPoolOperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolBlobAuditingPolicySqlPoolOperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolBlobAuditingPolicySqlPoolOperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, 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'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -159,10 +155,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -172,8 +166,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/operations"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/operations"} # type: ignore 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 dcfb8ee87398..b06ee5584333 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 @@ -6,147 +6,220 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_update_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, workspace_name: str, sql_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/recommendedSensitivityLabels") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/recommendedSensitivityLabels", + ) # 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'), + "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 = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - -class SqlPoolRecommendedSensitivityLabelsOperations(object): - """SqlPoolRecommendedSensitivityLabelsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +class SqlPoolRecommendedSensitivityLabelsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`sql_pool_recommended_sensitivity_labels` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def update( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: "_models.RecommendedSensitivityLabelUpdateList", + parameters: _models.RecommendedSensitivityLabelUpdateList, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Update recommended sensitivity labels states of a given SQL Pool using an operations batch. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param parameters: + :param parameters: Required. :type parameters: ~azure.mgmt.synapse.models.RecommendedSensitivityLabelUpdateList - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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 + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update recommended sensitivity labels states of a given SQL Pool using an operations batch. + + :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: 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + parameters: Union[_models.RecommendedSensitivityLabelUpdateList, IO], + **kwargs: Any + ) -> None: + """Update recommended sensitivity labels states of a given SQL Pool using an operations batch. + + :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: 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 + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'RecommendedSensitivityLabelUpdateList') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RecommendedSensitivityLabelUpdateList") request = build_update_request( - subscription_id=self._config.subscription_id, 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, - template_url=self.update.metadata['url'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -156,5 +229,4 @@ def update( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/recommendedSensitivityLabels"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/recommendedSensitivityLabels"} # 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 d5cd7791a78f..d1c8ef75a99f 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 @@ -8,183 +8,175 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, sql_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/replicationLinks") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/replicationLinks", + ) # 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'), + "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 = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_by_name_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - link_id: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, sql_pool_name: str, link_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/replicationLinks/{linkId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/replicationLinks/{linkId}", + ) # 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'), - "linkId": _SERIALIZER.url("link_id", link_id, 'str'), + "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"), + "linkId": _SERIALIZER.url("link_id", link_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class SqlPoolReplicationLinksOperations(object): - """SqlPoolReplicationLinksOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SqlPoolReplicationLinksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`sql_pool_replication_links` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> Iterable["_models.ReplicationLinkListResult"]: + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> Iterable["_models.ReplicationLink"]: """Get SQL pool replication links. Lists a Sql pool's replication links. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReplicationLinkListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.ReplicationLinkListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ReplicationLinkListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReplicationLinkListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, 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'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -198,10 +190,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -212,67 +202,64 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/replicationLinks"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/replicationLinks"} # type: ignore @distributed_trace def get_by_name( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - link_id: str, - **kwargs: Any - ) -> "_models.ReplicationLink": + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, link_id: str, **kwargs: Any + ) -> _models.ReplicationLink: """Get SQL pool replication link by name. Get SQL pool replication link by name. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param link_id: The ID of the replication link. + :param link_id: The ID of the replication link. Required. :type link_id: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ReplicationLink, or the result of cls(response) + :return: ReplicationLink or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ReplicationLink - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReplicationLink"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ReplicationLink] - request = build_get_by_name_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -280,12 +267,11 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_by_name.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/replicationLinks/{linkId}"} # type: ignore - + get_by_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/replicationLinks/{linkId}"} # 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 da8f2a7d2fc0..35a05c42dce8 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 @@ -6,268 +6,255 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, sql_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints", + ) # 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'), + "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 = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_request( + resource_group_name: str, workspace_name: str, sql_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints", + ) # 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'), + "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 = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, restore_point_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints/{restorePointName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints/{restorePointName}", + ) # 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'), - "restorePointName": _SERIALIZER.url("restore_point_name", restore_point_name, 'str'), + "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"), + "restorePointName": _SERIALIZER.url("restore_point_name", restore_point_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, restore_point_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints/{restorePointName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints/{restorePointName}", + ) # 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'), - "restorePointName": _SERIALIZER.url("restore_point_name", restore_point_name, 'str'), + "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"), + "restorePointName": _SERIALIZER.url("restore_point_name", restore_point_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) - -class SqlPoolRestorePointsOperations(object): - """SqlPoolRestorePointsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +class SqlPoolRestorePointsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`sql_pool_restore_points` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> Iterable["_models.RestorePointListResult"]: + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> Iterable["_models.RestorePoint"]: """Get SQL pool backup. Get SQL pool backup information. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RestorePointListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.RestorePointListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RestorePointListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, 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'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -281,10 +268,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -295,49 +280,61 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints"} # type: ignore def _create_initial( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: "_models.CreateSqlPoolRestorePointDefinition", + parameters: Union[_models.CreateSqlPoolRestorePointDefinition, IO], **kwargs: Any - ) -> Optional["_models.RestorePoint"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RestorePoint"]] + ) -> Optional[_models.RestorePoint]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'CreateSqlPoolRestorePointDefinition') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.RestorePoint]] - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CreateSqlPoolRestorePointDefinition") + + request = build_create_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, - template_url=self._create_initial.metadata['url'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -346,18 +343,95 @@ def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('RestorePoint', pipeline_response) + deserialized = self._deserialize("RestorePoint", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('RestorePoint', pipeline_response) + deserialized = self._deserialize("RestorePoint", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints"} # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + parameters: _models.CreateSqlPoolRestorePointDefinition, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.RestorePoint]: + """Creates a restore point for a data warehouse. + + :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 definition for creating the restore point of this Sql pool. Required. + :type parameters: ~azure.mgmt.synapse.models.CreateSqlPoolRestorePointDefinition + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.RestorePoint]: + """Creates a restore point for a data warehouse. + :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 definition for creating the restore point of 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 + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -365,22 +439,24 @@ def begin_create( resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: "_models.CreateSqlPoolRestorePointDefinition", + parameters: Union[_models.CreateSqlPoolRestorePointDefinition, IO], **kwargs: Any - ) -> LROPoller["_models.RestorePoint"]: + ) -> LROPoller[_models.RestorePoint]: """Creates a restore point for a data warehouse. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :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. - :type parameters: ~azure.mgmt.synapse.models.CreateSqlPoolRestorePointDefinition - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 @@ -392,174 +468,176 @@ def begin_create( :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] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePoint"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.RestorePoint] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('RestorePoint', pipeline_response) + deserialized = self._deserialize("RestorePoint", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - restore_point_name: str, - **kwargs: Any - ) -> "_models.RestorePoint": + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, restore_point_name: str, **kwargs: Any + ) -> _models.RestorePoint: """Gets a restore point. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param restore_point_name: The name of the restore point. + :param restore_point_name: The name of the restore point. Required. :type restore_point_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RestorePoint, or the result of cls(response) + :return: RestorePoint or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.RestorePoint - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePoint"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RestorePoint] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints/{restorePointName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints/{restorePointName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - restore_point_name: str, - **kwargs: Any + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, restore_point_name: str, **kwargs: Any ) -> None: """Deletes a restore point. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param restore_point_name: The name of the restore point. + :param restore_point_name: The name of the restore point. Required. :type restore_point_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -569,5 +647,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints/{restorePointName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/restorePoints/{restorePointName}"} # 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 0116149e5ff9..950b0ffd4bcb 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 @@ -8,126 +8,133 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, + subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas", + ) # 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'), + "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 = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, schema_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}", + ) # 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'), - "schemaName": _SERIALIZER.url("schema_name", schema_name, 'str'), + "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"), + "schemaName": _SERIALIZER.url("schema_name", schema_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class SqlPoolSchemasOperations(object): - """SqlPoolSchemasOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SqlPoolSchemasOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`sql_pool_schemas` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( @@ -137,64 +144,61 @@ def list( sql_pool_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.SqlPoolSchemaListResult"]: + ) -> Iterable["_models.SqlPoolSchema"]: """Gets schemas of a given SQL pool. Gets schemas of a given 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str :param filter: An OData filter expression that filters elements in the collection. Default value is None. :type filter: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SqlPoolSchemaListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.SqlPoolSchemaListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolSchemaListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolSchemaListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - api_version=api_version, - filter=filter, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -208,10 +212,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -221,77 +223,73 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - schema_name: str, - **kwargs: Any - ) -> "_models.SqlPoolSchema": + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, schema_name: str, **kwargs: Any + ) -> _models.SqlPoolSchema: """Get Sql Pool schema. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param schema_name: The name of the schema. + :param schema_name: The name of the schema. Required. :type schema_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SqlPoolSchema, or the result of cls(response) + :return: SqlPoolSchema or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolSchema - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolSchema"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolSchema] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}"} # 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 8684f6b0b5c3..d2fffca24462 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 @@ -6,235 +6,226 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, sql_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/securityAlertPolicies") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/securityAlertPolicies", + ) # 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'), + "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 = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyName"], + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/securityAlertPolicies/{securityAlertPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/securityAlertPolicies/{securityAlertPolicyName}", + ) # 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'), - "securityAlertPolicyName": _SERIALIZER.url("security_alert_policy_name", security_alert_policy_name, 'str'), + "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"), + "securityAlertPolicyName": _SERIALIZER.url("security_alert_policy_name", security_alert_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyName"], - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/securityAlertPolicies/{securityAlertPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/securityAlertPolicies/{securityAlertPolicyName}", + ) # 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'), - "securityAlertPolicyName": _SERIALIZER.url("security_alert_policy_name", security_alert_policy_name, 'str'), + "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"), + "securityAlertPolicyName": _SERIALIZER.url("security_alert_policy_name", security_alert_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - -class SqlPoolSecurityAlertPoliciesOperations(object): - """SqlPoolSecurityAlertPoliciesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +class SqlPoolSecurityAlertPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`sql_pool_security_alert_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> Iterable["_models.ListSqlPoolSecurityAlertPolicies"]: + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> Iterable["_models.SqlPoolSecurityAlertPolicy"]: """List Sql pool's security alert policies. Get a list of Sql pool's security alert policies. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListSqlPoolSecurityAlertPolicies or the result of + :return: An iterator like instance of either SqlPoolSecurityAlertPolicy or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.ListSqlPoolSecurityAlertPolicies] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.SqlPoolSecurityAlertPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListSqlPoolSecurityAlertPolicies] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListSqlPoolSecurityAlertPolicies"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, 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'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -248,10 +239,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -261,11 +250,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/securityAlertPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/securityAlertPolicies"} # type: ignore @distributed_trace def get( @@ -275,68 +262,143 @@ def get( sql_pool_name: str, security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyName"], **kwargs: Any - ) -> "_models.SqlPoolSecurityAlertPolicy": + ) -> _models.SqlPoolSecurityAlertPolicy: """Get a Sql pool's security alert policy. Get a Sql pool's security alert policy. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param security_alert_policy_name: The name of the security alert policy. + :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 api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SqlPoolSecurityAlertPolicy, or the result of cls(response) + :return: SqlPoolSecurityAlertPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolSecurityAlertPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolSecurityAlertPolicy"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolSecurityAlertPolicy] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/securityAlertPolicies/{securityAlertPolicyName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/securityAlertPolicies/{securityAlertPolicyName}"} # type: ignore + @overload + def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyName"], + parameters: _models.SqlPoolSecurityAlertPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SqlPoolSecurityAlertPolicy: + """Create or update a Sql pool's security alert policy. + + Create or update a Sql pool's security alert policy. + + :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 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: ~azure.mgmt.synapse.models.SqlPoolSecurityAlertPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyName"], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SqlPoolSecurityAlertPolicy: + """Create or update a Sql pool's security alert policy. + + Create or update a Sql pool's security alert policy. + + :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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: + """ @distributed_trace def create_or_update( @@ -345,61 +407,77 @@ def create_or_update( workspace_name: str, sql_pool_name: str, security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyName"], - parameters: "_models.SqlPoolSecurityAlertPolicy", + parameters: Union[_models.SqlPoolSecurityAlertPolicy, IO], **kwargs: Any - ) -> "_models.SqlPoolSecurityAlertPolicy": + ) -> _models.SqlPoolSecurityAlertPolicy: """Create or update a Sql pool's security alert policy. Create or update a Sql pool's security alert policy. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param security_alert_policy_name: The name of the security alert policy. + :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. - :type parameters: ~azure.mgmt.synapse.models.SqlPoolSecurityAlertPolicy - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 - :return: SqlPoolSecurityAlertPolicy, or the result of cls(response) + :return: SqlPoolSecurityAlertPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolSecurityAlertPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolSecurityAlertPolicy"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'SqlPoolSecurityAlertPolicy') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolSecurityAlertPolicy] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SqlPoolSecurityAlertPolicy") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, 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, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -407,15 +485,14 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('SqlPoolSecurityAlertPolicy', pipeline_response) + deserialized = self._deserialize("SqlPoolSecurityAlertPolicy", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SqlPoolSecurityAlertPolicy', pipeline_response) + deserialized = self._deserialize("SqlPoolSecurityAlertPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/securityAlertPolicies/{securityAlertPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/securityAlertPolicies/{securityAlertPolicyName}"} # type: ignore 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 6e689da4a8d9..22a0deda6b70 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,257 +6,251 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_current_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, + subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/currentSensitivityLabels") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/currentSensitivityLabels", + ) # 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'), + "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 = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, workspace_name: str, sql_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/currentSensitivityLabels") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/currentSensitivityLabels", + ) # 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'), + "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 = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_list_recommended_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, + subscription_id: str, *, include_disabled_recommendations: Optional[bool] = None, skip_token: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/recommendedSensitivityLabels") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/recommendedSensitivityLabels", + ) # 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'), + "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 = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if include_disabled_recommendations is not None: - _query_parameters['includeDisabledRecommendations'] = _SERIALIZER.query("include_disabled_recommendations", include_disabled_recommendations, 'bool') + _params["includeDisabledRecommendations"] = _SERIALIZER.query( + "include_disabled_recommendations", include_disabled_recommendations, "bool" + ) if skip_token is not None: - _query_parameters['$skipToken'] = _SERIALIZER.query("skip_token", skip_token, 'str') + _params["$skipToken"] = _SERIALIZER.query("skip_token", skip_token, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, schema_name: str, table_name: str, column_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - sensitivity_label_source = kwargs.pop('sensitivity_label_source', "current") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + sensitivity_label_source = kwargs.pop("sensitivity_label_source", "current") # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}", + ) # 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'), - "schemaName": _SERIALIZER.url("schema_name", schema_name, 'str'), - "tableName": _SERIALIZER.url("table_name", table_name, 'str'), - "columnName": _SERIALIZER.url("column_name", column_name, 'str'), - "sensitivityLabelSource": _SERIALIZER.url("sensitivity_label_source", sensitivity_label_source, 'str'), + "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"), + "schemaName": _SERIALIZER.url("schema_name", schema_name, "str"), + "tableName": _SERIALIZER.url("table_name", table_name, "str"), + "columnName": _SERIALIZER.url("column_name", column_name, "str"), + "sensitivityLabelSource": _SERIALIZER.url("sensitivity_label_source", sensitivity_label_source, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, schema_name: str, table_name: str, column_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - sensitivity_label_source = kwargs.pop('sensitivity_label_source', "current") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + sensitivity_label_source = kwargs.pop("sensitivity_label_source", "current") # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}", + ) # 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'), - "schemaName": _SERIALIZER.url("schema_name", schema_name, 'str'), - "tableName": _SERIALIZER.url("table_name", table_name, 'str'), - "columnName": _SERIALIZER.url("column_name", column_name, 'str'), - "sensitivityLabelSource": _SERIALIZER.url("sensitivity_label_source", sensitivity_label_source, 'str'), + "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"), + "schemaName": _SERIALIZER.url("schema_name", schema_name, "str"), + "tableName": _SERIALIZER.url("table_name", table_name, "str"), + "columnName": _SERIALIZER.url("column_name", column_name, "str"), + "sensitivityLabelSource": _SERIALIZER.url("sensitivity_label_source", sensitivity_label_source, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, @@ -264,143 +258,142 @@ def build_get_request( table_name: str, column_name: str, sensitivity_label_source: Union[str, "_models.SensitivityLabelSource"], + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}", + ) # 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'), - "schemaName": _SERIALIZER.url("schema_name", schema_name, 'str'), - "tableName": _SERIALIZER.url("table_name", table_name, 'str'), - "columnName": _SERIALIZER.url("column_name", column_name, 'str'), - "sensitivityLabelSource": _SERIALIZER.url("sensitivity_label_source", sensitivity_label_source, 'str'), + "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"), + "schemaName": _SERIALIZER.url("schema_name", schema_name, "str"), + "tableName": _SERIALIZER.url("table_name", table_name, "str"), + "columnName": _SERIALIZER.url("column_name", column_name, "str"), + "sensitivityLabelSource": _SERIALIZER.url("sensitivity_label_source", sensitivity_label_source, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_enable_recommendation_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, schema_name: str, table_name: str, column_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - sensitivity_label_source = kwargs.pop('sensitivity_label_source', "recommended") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + sensitivity_label_source = kwargs.pop("sensitivity_label_source", "recommended") # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/enable") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/enable", + ) # 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'), - "schemaName": _SERIALIZER.url("schema_name", schema_name, 'str'), - "tableName": _SERIALIZER.url("table_name", table_name, 'str'), - "columnName": _SERIALIZER.url("column_name", column_name, 'str'), - "sensitivityLabelSource": _SERIALIZER.url("sensitivity_label_source", sensitivity_label_source, 'str'), + "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"), + "schemaName": _SERIALIZER.url("schema_name", schema_name, "str"), + "tableName": _SERIALIZER.url("table_name", table_name, "str"), + "columnName": _SERIALIZER.url("column_name", column_name, "str"), + "sensitivityLabelSource": _SERIALIZER.url("sensitivity_label_source", sensitivity_label_source, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) def build_disable_recommendation_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, schema_name: str, table_name: str, column_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - sensitivity_label_source = kwargs.pop('sensitivity_label_source', "recommended") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + sensitivity_label_source = kwargs.pop("sensitivity_label_source", "recommended") # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/disable") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/disable", + ) # 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'), - "schemaName": _SERIALIZER.url("schema_name", schema_name, 'str'), - "tableName": _SERIALIZER.url("table_name", table_name, 'str'), - "columnName": _SERIALIZER.url("column_name", column_name, 'str'), - "sensitivityLabelSource": _SERIALIZER.url("sensitivity_label_source", sensitivity_label_source, 'str'), + "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"), + "schemaName": _SERIALIZER.url("schema_name", schema_name, "str"), + "tableName": _SERIALIZER.url("table_name", table_name, "str"), + "columnName": _SERIALIZER.url("column_name", column_name, "str"), + "sensitivityLabelSource": _SERIALIZER.url("sensitivity_label_source", sensitivity_label_source, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - **kwargs - ) - -class SqlPoolSensitivityLabelsOperations(object): - """SqlPoolSensitivityLabelsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +class SqlPoolSensitivityLabelsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`sql_pool_sensitivity_labels` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_current( @@ -410,64 +403,61 @@ def list_current( sql_pool_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.SensitivityLabelListResult"]: + ) -> Iterable["_models.SensitivityLabel"]: """Gets SQL pool sensitivity labels. Gets SQL pool sensitivity labels. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str :param filter: An OData filter expression that filters elements in the collection. Default value is None. :type filter: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SensitivityLabelListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.SensitivityLabelListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SensitivityLabelListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SensitivityLabelListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_current_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_current.metadata['url'], + 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) # type: ignore else: - - request = build_list_current_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - api_version=api_version, - filter=filter, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -481,10 +471,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -495,68 +483,143 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_current.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/currentSensitivityLabels"} # type: ignore + list_current.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/currentSensitivityLabels"} # type: ignore - @distributed_trace + @overload def update( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: "_models.SensitivityLabelUpdateList", + parameters: _models.SensitivityLabelUpdateList, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Update sensitivity labels of a given SQL Pool using an operations batch. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param parameters: + :param parameters: Required. :type parameters: ~azure.mgmt.synapse.models.SensitivityLabelUpdateList - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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 + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update sensitivity labels of a given SQL Pool using an operations batch. + + :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: 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + parameters: Union[_models.SensitivityLabelUpdateList, IO], + **kwargs: Any + ) -> None: + """Update sensitivity labels of a given SQL Pool using an operations batch. + + :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: 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 + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'SensitivityLabelUpdateList') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SensitivityLabelUpdateList") request = build_update_request( - subscription_id=self._config.subscription_id, 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, - template_url=self.update.metadata['url'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -566,8 +629,7 @@ def update( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/currentSensitivityLabels"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/currentSensitivityLabels"} # type: ignore @distributed_trace def list_recommended( @@ -579,16 +641,17 @@ def list_recommended( skip_token: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.SensitivityLabelListResult"]: + ) -> Iterable["_models.SensitivityLabel"]: """Gets sensitivity labels of a given SQL pool. Gets sensitivity labels of a given 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str :param include_disabled_recommendations: Specifies whether to include disabled recommendations or not. Default value is None. @@ -599,54 +662,48 @@ def list_recommended( :param filter: An OData filter expression that filters elements in the collection. Default value is None. :type filter: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SensitivityLabelListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.SensitivityLabelListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SensitivityLabelListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SensitivityLabelListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_recommended_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, - api_version=api_version, + subscription_id=self._config.subscription_id, include_disabled_recommendations=include_disabled_recommendations, skip_token=skip_token, filter=filter, - template_url=self.list_recommended.metadata['url'], + 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) # type: ignore else: - - request = build_list_recommended_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - api_version=api_version, - include_disabled_recommendations=include_disabled_recommendations, - skip_token=skip_token, - filter=filter, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -660,10 +717,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -673,13 +728,11 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_recommended.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/recommendedSensitivityLabels"} # type: ignore + list_recommended.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/recommendedSensitivityLabels"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, @@ -688,70 +741,172 @@ def create_or_update( schema_name: str, table_name: str, column_name: str, - parameters: "_models.SensitivityLabel", + parameters: _models.SensitivityLabel, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.SensitivityLabel": + ) -> _models.SensitivityLabel: """Creates or updates the sensitivity label of a given column in 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param schema_name: The name of the schema. + :param schema_name: The name of the schema. Required. :type schema_name: str - :param table_name: The name of the table. + :param table_name: The name of the table. Required. :type table_name: str - :param column_name: The name of the column. + :param column_name: The name of the column. Required. :type column_name: str - :param parameters: The column sensitivity label resource. + :param parameters: The column sensitivity label resource. Required. :type parameters: ~azure.mgmt.synapse.models.SensitivityLabel - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword 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) + :return: SensitivityLabel or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SensitivityLabel - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + schema_name: str, + table_name: str, + column_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SensitivityLabel: + """Creates or updates the sensitivity label of a given column in 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 schema_name: The name of the schema. Required. + :type schema_name: str + :param table_name: The name of the table. Required. + :type table_name: str + :param column_name: The name of the column. Required. + :type column_name: str + :param parameters: The column sensitivity label resource. 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 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: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + schema_name: str, + table_name: str, + column_name: str, + parameters: Union[_models.SensitivityLabel, IO], + **kwargs: Any + ) -> _models.SensitivityLabel: + """Creates or updates the sensitivity label of a given column in 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 schema_name: The name of the schema. Required. + :type schema_name: str + :param table_name: The name of the table. Required. + :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 + :return: SensitivityLabel or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.SensitivityLabel + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SensitivityLabel"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - sensitivity_label_source = kwargs.pop('sensitivity_label_source', "current") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'SensitivityLabel') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + sensitivity_label_source = kwargs.pop("sensitivity_label_source", "current") # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SensitivityLabel] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SensitivityLabel") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, schema_name=schema_name, table_name=table_name, column_name=column_name, + subscription_id=self._config.subscription_id, api_version=api_version, sensitivity_label_source=sensitivity_label_source, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -759,18 +914,17 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('SensitivityLabel', pipeline_response) + deserialized = self._deserialize("SensitivityLabel", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SensitivityLabel', pipeline_response) + deserialized = self._deserialize("SensitivityLabel", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}"} # 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}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -786,58 +940,62 @@ def delete( # pylint: disable=inconsistent-return-statements """Deletes the sensitivity label of a given column in 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param schema_name: The name of the schema. + :param schema_name: The name of the schema. Required. :type schema_name: str - :param table_name: The name of the table. + :param table_name: The name of the table. Required. :type table_name: str - :param column_name: The name of the column. + :param column_name: The name of the column. Required. :type column_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - sensitivity_label_source = kwargs.pop('sensitivity_label_source', "current") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + sensitivity_label_source = kwargs.pop("sensitivity_label_source", "current") # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, schema_name=schema_name, table_name=table_name, column_name=column_name, + subscription_id=self._config.subscription_id, api_version=api_version, sensitivity_label_source=sensitivity_label_source, - template_url=self.delete.metadata['url'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -847,8 +1005,7 @@ def delete( # pylint: disable=inconsistent-return-statements 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}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}"} # type: ignore @distributed_trace def get( @@ -861,42 +1018,45 @@ def get( column_name: str, sensitivity_label_source: Union[str, "_models.SensitivityLabelSource"], **kwargs: Any - ) -> "_models.SensitivityLabel": + ) -> _models.SensitivityLabel: """Gets the sensitivity label of a given column. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param schema_name: The name of the schema. + :param schema_name: The name of the schema. Required. :type schema_name: str - :param table_name: The name of the table. + :param table_name: The name of the table. Required. :type table_name: str - :param column_name: The name of the column. + :param column_name: The name of the column. Required. :type column_name: str - :param sensitivity_label_source: The source of the sensitivity label. + :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 api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SensitivityLabel, or the result of cls(response) + :return: SensitivityLabel or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SensitivityLabel - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SensitivityLabel"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SensitivityLabel] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -904,32 +1064,33 @@ def get( table_name=table_name, column_name=column_name, sensitivity_label_source=sensitivity_label_source, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}"} # type: ignore @distributed_trace def enable_recommendation( # pylint: disable=inconsistent-return-statements @@ -946,58 +1107,62 @@ def enable_recommendation( # pylint: disable=inconsistent-return-statements on all columns). :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param schema_name: The name of the schema. + :param schema_name: The name of the schema. Required. :type schema_name: str - :param table_name: The name of the table. + :param table_name: The name of the table. Required. :type table_name: str - :param column_name: The name of the column. + :param column_name: The name of the column. Required. :type column_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - sensitivity_label_source = kwargs.pop('sensitivity_label_source', "recommended") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + sensitivity_label_source = kwargs.pop("sensitivity_label_source", "recommended") # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_enable_recommendation_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, schema_name=schema_name, table_name=table_name, column_name=column_name, + subscription_id=self._config.subscription_id, api_version=api_version, sensitivity_label_source=sensitivity_label_source, - template_url=self.enable_recommendation.metadata['url'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1007,8 +1172,7 @@ def enable_recommendation( # pylint: disable=inconsistent-return-statements 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"} # type: ignore - + enable_recommendation.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/enable"} # type: ignore @distributed_trace def disable_recommendation( # pylint: disable=inconsistent-return-statements @@ -1024,58 +1188,62 @@ def disable_recommendation( # pylint: disable=inconsistent-return-statements """Disables sensitivity recommendations on a given column. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param schema_name: The name of the schema. + :param schema_name: The name of the schema. Required. :type schema_name: str - :param table_name: The name of the table. + :param table_name: The name of the table. Required. :type table_name: str - :param column_name: The name of the column. + :param column_name: The name of the column. Required. :type column_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - sensitivity_label_source = kwargs.pop('sensitivity_label_source', "recommended") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + sensitivity_label_source = kwargs.pop("sensitivity_label_source", "recommended") # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_disable_recommendation_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, schema_name=schema_name, table_name=table_name, column_name=column_name, + subscription_id=self._config.subscription_id, api_version=api_version, sensitivity_label_source=sensitivity_label_source, - template_url=self.disable_recommendation.metadata['url'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1085,5 +1253,4 @@ def disable_recommendation( # pylint: disable=inconsistent-return-statements 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"} # type: ignore - + disable_recommendation.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/disable"} # 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 b7c0db7dec8c..35df7e7e4f39 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 @@ -8,90 +8,97 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_by_table_name_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, schema_name: str, table_name: str, + subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns", + ) # 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'), - "schemaName": _SERIALIZER.url("schema_name", schema_name, 'str'), - "tableName": _SERIALIZER.url("table_name", table_name, 'str'), + "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"), + "schemaName": _SERIALIZER.url("schema_name", schema_name, "str"), + "tableName": _SERIALIZER.url("table_name", table_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class SqlPoolTableColumnsOperations(object): - """SqlPoolTableColumnsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SqlPoolTableColumnsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`sql_pool_table_columns` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_table_name( @@ -103,72 +110,67 @@ def list_by_table_name( table_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.SqlPoolColumnListResult"]: + ) -> Iterable["_models.SqlPoolColumn"]: """Gets columns in a given table in a SQL pool. Gets columns in a given table in 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param schema_name: The name of the schema. + :param schema_name: The name of the schema. Required. :type schema_name: str - :param table_name: The name of the table. + :param table_name: The name of the table. Required. :type table_name: str :param filter: An OData filter expression that filters elements in the collection. Default value is None. :type filter: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SqlPoolColumnListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.SqlPoolColumnListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolColumnListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolColumnListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_table_name_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, schema_name=schema_name, table_name=table_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_by_table_name.metadata['url'], + 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) # type: ignore else: - - request = build_list_by_table_name_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - schema_name=schema_name, - table_name=table_name, - api_version=api_version, - filter=filter, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -182,10 +184,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -195,8 +195,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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"} # type: ignore + list_by_table_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}/columns"} # type: ignore 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 582c8416596a..e6a0d72b3c06 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 @@ -8,130 +8,137 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_by_schema_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, schema_name: str, + subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables", + ) # 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'), - "schemaName": _SERIALIZER.url("schema_name", schema_name, 'str'), + "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"), + "schemaName": _SERIALIZER.url("schema_name", schema_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, schema_name: str, table_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}", + ) # 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'), - "schemaName": _SERIALIZER.url("schema_name", schema_name, 'str'), - "tableName": _SERIALIZER.url("table_name", table_name, 'str'), + "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"), + "schemaName": _SERIALIZER.url("schema_name", schema_name, "str"), + "tableName": _SERIALIZER.url("table_name", table_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class SqlPoolTablesOperations(object): - """SqlPoolTablesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SqlPoolTablesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`sql_pool_tables` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_schema( @@ -142,68 +149,64 @@ def list_by_schema( schema_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.SqlPoolTableListResult"]: + ) -> Iterable["_models.SqlPoolTable"]: """Gets tables of a given schema in a SQL pool. Gets tables of a given schema in 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param schema_name: The name of the schema. + :param schema_name: The name of the schema. Required. :type schema_name: str :param filter: An OData filter expression that filters elements in the collection. Default value is None. :type filter: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SqlPoolTableListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.SqlPoolTableListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolTableListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolTableListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_schema_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, schema_name=schema_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_by_schema.metadata['url'], + 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) # type: ignore else: - - request = build_list_by_schema_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - schema_name=schema_name, - api_version=api_version, - filter=filter, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -217,10 +220,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -230,11 +231,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - 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"} # type: ignore + list_by_schema.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables"} # type: ignore @distributed_trace def get( @@ -245,66 +244,69 @@ def get( schema_name: str, table_name: str, **kwargs: Any - ) -> "_models.SqlPoolTable": + ) -> _models.SqlPoolTable: """Get Sql pool table. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param schema_name: The name of the schema. + :param schema_name: The name of the schema. Required. :type schema_name: str - :param table_name: The name of the table. + :param table_name: The name of the table. Required. :type table_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SqlPoolTable, or the result of cls(response) + :return: SqlPoolTable or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolTable - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolTable"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolTable] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, schema_name=schema_name, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/schemas/{schemaName}/tables/{tableName}"} # 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 e2f8acba49de..9479ff3336a5 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 @@ -6,173 +6,174 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, transparent_data_encryption_name: Union[str, "_models.TransparentDataEncryptionName"], + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/transparentDataEncryption/{transparentDataEncryptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/transparentDataEncryption/{transparentDataEncryptionName}", + ) # 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'), - "transparentDataEncryptionName": _SERIALIZER.url("transparent_data_encryption_name", transparent_data_encryption_name, 'str'), + "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"), + "transparentDataEncryptionName": _SERIALIZER.url( + "transparent_data_encryption_name", transparent_data_encryption_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, transparent_data_encryption_name: Union[str, "_models.TransparentDataEncryptionName"], - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/transparentDataEncryption/{transparentDataEncryptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/transparentDataEncryption/{transparentDataEncryptionName}", + ) # 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'), - "transparentDataEncryptionName": _SERIALIZER.url("transparent_data_encryption_name", transparent_data_encryption_name, 'str'), + "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"), + "transparentDataEncryptionName": _SERIALIZER.url( + "transparent_data_encryption_name", transparent_data_encryption_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, sql_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/transparentDataEncryption") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/transparentDataEncryption", + ) # 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'), + "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 = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class SqlPoolTransparentDataEncryptionsOperations(object): - """SqlPoolTransparentDataEncryptionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SqlPoolTransparentDataEncryptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`sql_pool_transparent_data_encryptions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( @@ -182,55 +183,59 @@ def get( sql_pool_name: str, transparent_data_encryption_name: Union[str, "_models.TransparentDataEncryptionName"], **kwargs: Any - ) -> "_models.TransparentDataEncryption": + ) -> _models.TransparentDataEncryption: """Get a SQL pool's transparent data encryption configuration. Get a SQL pool's transparent data encryption configuration. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str :param transparent_data_encryption_name: The name of the transparent data encryption - configuration. + configuration. "current" Required. :type transparent_data_encryption_name: str or ~azure.mgmt.synapse.models.TransparentDataEncryptionName - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TransparentDataEncryption, or the result of cls(response) + :return: TransparentDataEncryption or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.TransparentDataEncryption - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TransparentDataEncryption"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TransparentDataEncryption] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -238,15 +243,92 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TransparentDataEncryption', pipeline_response) + deserialized = self._deserialize("TransparentDataEncryption", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/transparentDataEncryption/{transparentDataEncryptionName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/transparentDataEncryption/{transparentDataEncryptionName}"} # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + transparent_data_encryption_name: Union[str, "_models.TransparentDataEncryptionName"], + parameters: _models.TransparentDataEncryption, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TransparentDataEncryption: + """Creates or updates a Sql pool's transparent data encryption configuration. + + Creates or updates a Sql pool's transparent data encryption configuration. + + :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 transparent_data_encryption_name: The name of the transparent data encryption + configuration. "current" Required. + :type transparent_data_encryption_name: str or + ~azure.mgmt.synapse.models.TransparentDataEncryptionName + :param parameters: The required parameters for creating or updating transparent data + encryption. Required. + :type parameters: ~azure.mgmt.synapse.models.TransparentDataEncryption + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + transparent_data_encryption_name: Union[str, "_models.TransparentDataEncryptionName"], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TransparentDataEncryption: + """Creates or updates a Sql pool's transparent data encryption configuration. + + Creates or updates a Sql pool's transparent data encryption configuration. + :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 transparent_data_encryption_name: The name of the transparent data encryption + configuration. "current" Required. + :type transparent_data_encryption_name: str or + ~azure.mgmt.synapse.models.TransparentDataEncryptionName + :param parameters: The required parameters for creating or updating transparent data + encryption. 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: TransparentDataEncryption or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.TransparentDataEncryption + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update( @@ -255,146 +337,154 @@ def create_or_update( workspace_name: str, sql_pool_name: str, transparent_data_encryption_name: Union[str, "_models.TransparentDataEncryptionName"], - parameters: "_models.TransparentDataEncryption", + parameters: Union[_models.TransparentDataEncryption, IO], **kwargs: Any - ) -> "_models.TransparentDataEncryption": + ) -> _models.TransparentDataEncryption: """Creates or updates a Sql pool's transparent data encryption configuration. Creates or updates a Sql pool's transparent data encryption configuration. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str :param transparent_data_encryption_name: The name of the transparent data encryption - configuration. + configuration. "current" Required. :type transparent_data_encryption_name: str or ~azure.mgmt.synapse.models.TransparentDataEncryptionName :param parameters: The required parameters for creating or updating transparent data - encryption. - :type parameters: ~azure.mgmt.synapse.models.TransparentDataEncryption - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + 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 - :return: TransparentDataEncryption, or the result of cls(response) + :return: TransparentDataEncryption or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.TransparentDataEncryption - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TransparentDataEncryption"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'TransparentDataEncryption') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TransparentDataEncryption] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TransparentDataEncryption") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, 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, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('TransparentDataEncryption', pipeline_response) + deserialized = self._deserialize("TransparentDataEncryption", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('TransparentDataEncryption', pipeline_response) + deserialized = self._deserialize("TransparentDataEncryption", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/transparentDataEncryption/{transparentDataEncryptionName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/transparentDataEncryption/{transparentDataEncryptionName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> Iterable["_models.TransparentDataEncryptionListResult"]: + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> Iterable["_models.TransparentDataEncryption"]: """SQL pool's transparent data encryption configurations. Get list of SQL pool's transparent data encryption configurations. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TransparentDataEncryptionListResult or the result - of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.TransparentDataEncryptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either TransparentDataEncryption or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.TransparentDataEncryption] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TransparentDataEncryptionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TransparentDataEncryptionListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, 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'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -408,10 +498,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -421,8 +509,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/transparentDataEncryption"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/transparentDataEncryption"} # type: ignore 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 eacaac7e1158..e90cda56dbfc 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 @@ -8,143 +8,140 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, sql_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/usages") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/usages", + ) # 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'), + "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 = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class SqlPoolUsagesOperations(object): - """SqlPoolUsagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SqlPoolUsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`sql_pool_usages` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> Iterable["_models.SqlPoolUsageListResult"]: + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> Iterable["_models.SqlPoolUsage"]: """Gets SQL pool usages. Gets SQL pool usages. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SqlPoolUsageListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.SqlPoolUsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolUsageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolUsageListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, 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'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -158,10 +155,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -172,8 +167,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/usages"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/usages"} # type: ignore 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 086a93c07ec6..0adbb65ab107 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 @@ -6,182 +6,189 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_create_or_update_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], rule_id: str, baseline_name: Union[str, "_models.VulnerabilityAssessmentPolicyBaselineName"], - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}", + ) # 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'), - "vulnerabilityAssessmentName": _SERIALIZER.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - "ruleId": _SERIALIZER.url("rule_id", rule_id, 'str'), - "baselineName": _SERIALIZER.url("baseline_name", baseline_name, 'str'), + "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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), + "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], rule_id: str, baseline_name: Union[str, "_models.VulnerabilityAssessmentPolicyBaselineName"], + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}", + ) # 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'), - "vulnerabilityAssessmentName": _SERIALIZER.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - "ruleId": _SERIALIZER.url("rule_id", rule_id, 'str'), - "baselineName": _SERIALIZER.url("baseline_name", baseline_name, 'str'), + "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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), + "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], rule_id: str, baseline_name: Union[str, "_models.VulnerabilityAssessmentPolicyBaselineName"], + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}", + ) # 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'), - "vulnerabilityAssessmentName": _SERIALIZER.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - "ruleId": _SERIALIZER.url("rule_id", rule_id, 'str'), - "baselineName": _SERIALIZER.url("baseline_name", baseline_name, 'str'), + "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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), + "baselineName": _SERIALIZER.url("baseline_name", baseline_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class SqlPoolVulnerabilityAssessmentRuleBaselinesOperations(object): - """SqlPoolVulnerabilityAssessmentRuleBaselinesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SqlPoolVulnerabilityAssessmentRuleBaselinesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`sql_pool_vulnerability_assessment_rule_baselines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, @@ -190,83 +197,190 @@ def create_or_update( vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], rule_id: str, baseline_name: Union[str, "_models.VulnerabilityAssessmentPolicyBaselineName"], - parameters: "_models.SqlPoolVulnerabilityAssessmentRuleBaseline", + parameters: _models.SqlPoolVulnerabilityAssessmentRuleBaseline, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.SqlPoolVulnerabilityAssessmentRuleBaseline": + ) -> _models.SqlPoolVulnerabilityAssessmentRuleBaseline: """Creates or updates a Sql pool's vulnerability assessment rule baseline. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param vulnerability_assessment_name: The name of the vulnerability assessment. + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :param rule_id: The vulnerability assessment rule ID. + :param rule_id: The vulnerability assessment rule ID. Required. :type rule_id: str :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a - baseline on a Sql pool level rule and master for workspace level rule). + baseline on a Sql pool level rule and master for workspace level rule). Known values are: + "master" and "default". Required. :type baseline_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentPolicyBaselineName - :param parameters: The requested rule baseline resource. + :param parameters: The requested rule baseline resource. Required. :type parameters: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessmentRuleBaseline - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + rule_id: str, + baseline_name: Union[str, "_models.VulnerabilityAssessmentPolicyBaselineName"], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SqlPoolVulnerabilityAssessmentRuleBaseline: + """Creates or updates a Sql pool's vulnerability assessment rule baseline. + + :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 vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. + :type vulnerability_assessment_name: str or + ~azure.mgmt.synapse.models.VulnerabilityAssessmentName + :param rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a + baseline on a Sql pool level rule and master for workspace level rule). Known values are: + "master" and "default". Required. + :type baseline_name: str or + ~azure.mgmt.synapse.models.VulnerabilityAssessmentPolicyBaselineName + :param parameters: The requested rule baseline resource. 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: SqlPoolVulnerabilityAssessmentRuleBaseline or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessmentRuleBaseline + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + rule_id: str, + baseline_name: Union[str, "_models.VulnerabilityAssessmentPolicyBaselineName"], + parameters: Union[_models.SqlPoolVulnerabilityAssessmentRuleBaseline, IO], + **kwargs: Any + ) -> _models.SqlPoolVulnerabilityAssessmentRuleBaseline: + """Creates or updates a Sql pool's vulnerability assessment rule baseline. + + :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 vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. + :type vulnerability_assessment_name: str or + ~azure.mgmt.synapse.models.VulnerabilityAssessmentName + :param rule_id: The vulnerability assessment rule ID. Required. + :type rule_id: str + :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a + baseline on a Sql pool level rule and master for workspace level rule). Known values are: + "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 - :return: SqlPoolVulnerabilityAssessmentRuleBaseline, or the result of cls(response) + :return: SqlPoolVulnerabilityAssessmentRuleBaseline or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessmentRuleBaseline - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolVulnerabilityAssessmentRuleBaseline"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'SqlPoolVulnerabilityAssessmentRuleBaseline') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolVulnerabilityAssessmentRuleBaseline] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SqlPoolVulnerabilityAssessmentRuleBaseline") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, vulnerability_assessment_name=vulnerability_assessment_name, rule_id=rule_id, baseline_name=baseline_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -282,56 +396,62 @@ def delete( # pylint: disable=inconsistent-return-statements """Removes the database's vulnerability assessment rule baseline. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param vulnerability_assessment_name: The name of the vulnerability assessment. + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :param rule_id: The vulnerability assessment rule ID. + :param rule_id: The vulnerability assessment rule ID. Required. :type rule_id: str :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a - baseline on a Sql pool level rule and master for workspace level rule). + baseline on a Sql pool level rule and master for workspace level rule). Known values are: + "master" and "default". Required. :type baseline_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentPolicyBaselineName - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, vulnerability_assessment_name=vulnerability_assessment_name, rule_id=rule_id, baseline_name=baseline_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -341,8 +461,7 @@ def delete( # pylint: disable=inconsistent-return-statements 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}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}"} # type: ignore @distributed_trace def get( @@ -354,72 +473,77 @@ def get( rule_id: str, baseline_name: Union[str, "_models.VulnerabilityAssessmentPolicyBaselineName"], **kwargs: Any - ) -> "_models.SqlPoolVulnerabilityAssessmentRuleBaseline": + ) -> _models.SqlPoolVulnerabilityAssessmentRuleBaseline: """Gets a SqlPool's vulnerability assessment rule baseline. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param vulnerability_assessment_name: The name of the vulnerability assessment. + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :param rule_id: The vulnerability assessment rule ID. + :param rule_id: The vulnerability assessment rule ID. Required. :type rule_id: str :param baseline_name: The name of the vulnerability assessment rule baseline (default implies a - baseline on a Sql pool level rule and master for server level rule). + baseline on a Sql pool level rule and master for server level rule). Known values are: "master" + and "default". Required. :type baseline_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentPolicyBaselineName - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SqlPoolVulnerabilityAssessmentRuleBaseline, or the result of cls(response) + :return: SqlPoolVulnerabilityAssessmentRuleBaseline or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessmentRuleBaseline - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolVulnerabilityAssessmentRuleBaseline"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolVulnerabilityAssessmentRuleBaseline] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, vulnerability_assessment_name=vulnerability_assessment_name, rule_id=rule_id, baseline_name=baseline_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/rules/{ruleId}/baselines/{baselineName}"} # 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 7128af44394e..398f5c535dfb 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 @@ -6,208 +6,223 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans", + ) # 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'), - "vulnerabilityAssessmentName": _SERIALIZER.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), + "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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_initiate_scan_request_initial( - subscription_id: str, +def build_initiate_scan_request( resource_group_name: str, workspace_name: str, sql_pool_name: str, vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], scan_id: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan", + ) # 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'), - "vulnerabilityAssessmentName": _SERIALIZER.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - "scanId": _SERIALIZER.url("scan_id", scan_id, 'str'), + "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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + "scanId": _SERIALIZER.url("scan_id", scan_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) def build_export_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], scan_id: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/export") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/export", + ) # 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'), - "vulnerabilityAssessmentName": _SERIALIZER.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - "scanId": _SERIALIZER.url("scan_id", scan_id, 'str'), + "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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + "scanId": _SERIALIZER.url("scan_id", scan_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], scan_id: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}", + ) # 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'), - "vulnerabilityAssessmentName": _SERIALIZER.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), - "scanId": _SERIALIZER.url("scan_id", scan_id, 'str'), + "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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), + "scanId": _SERIALIZER.url("scan_id", scan_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class SqlPoolVulnerabilityAssessmentScansOperations(object): - """SqlPoolVulnerabilityAssessmentScansOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SqlPoolVulnerabilityAssessmentScansOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`sql_pool_vulnerability_assessment_scans` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( @@ -217,65 +232,64 @@ def list( sql_pool_name: str, vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], **kwargs: Any - ) -> Iterable["_models.VulnerabilityAssessmentScanRecordListResult"]: + ) -> Iterable["_models.VulnerabilityAssessmentScanRecord"]: """Lists the vulnerability assessment scans of a SQL pool. Lists the vulnerability assessment scans of 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param vulnerability_assessment_name: The name of the vulnerability assessment. + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VulnerabilityAssessmentScanRecordListResult or the - result of cls(response) + :return: An iterator like instance of either VulnerabilityAssessmentScanRecord or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.VulnerabilityAssessmentScanRecordListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.VulnerabilityAssessmentScanRecord] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VulnerabilityAssessmentScanRecordListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VulnerabilityAssessmentScanRecordListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, 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'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - vulnerability_assessment_name=vulnerability_assessment_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -289,10 +303,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -302,11 +314,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans"} # type: ignore def _initiate_scan_initial( # pylint: disable=inconsistent-return-statements self, @@ -317,33 +327,39 @@ def _initiate_scan_initial( # pylint: disable=inconsistent-return-statements scan_id: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_initiate_scan_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_initiate_scan_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, vulnerability_assessment_name=vulnerability_assessment_name, scan_id=scan_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._initiate_scan_initial.metadata['url'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -353,11 +369,10 @@ def _initiate_scan_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _initiate_scan_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan"} # type: ignore - + _initiate_scan_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan"} # type: ignore @distributed_trace - def begin_initiate_scan( # pylint: disable=inconsistent-return-statements + def begin_initiate_scan( self, resource_group_name: str, workspace_name: str, @@ -369,19 +384,18 @@ def begin_initiate_scan( # pylint: disable=inconsistent-return-statements """Executes a Vulnerability Assessment database scan. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param vulnerability_assessment_name: The name of the vulnerability assessment. + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :param scan_id: The vulnerability assessment scan Id of the scan to retrieve. + :param scan_id: The vulnerability assessment scan Id of the scan to retrieve. Required. :type scan_id: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -392,47 +406,51 @@ def begin_initiate_scan( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._initiate_scan_initial( + raw_result = self._initiate_scan_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, vulnerability_assessment_name=vulnerability_assessment_name, scan_id=scan_id, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_initiate_scan.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan"} # type: ignore + begin_initiate_scan.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/initiateScan"} # type: ignore @distributed_trace def export( @@ -443,55 +461,60 @@ def export( vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], scan_id: str, **kwargs: Any - ) -> "_models.SqlPoolVulnerabilityAssessmentScansExport": + ) -> _models.SqlPoolVulnerabilityAssessmentScansExport: """Convert an existing scan result to a human readable format. If already exists nothing happens. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param vulnerability_assessment_name: The name of the vulnerability assessment. + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :param scan_id: The vulnerability assessment scan Id of the scan to retrieve. + :param scan_id: The vulnerability assessment scan Id of the scan to retrieve. Required. :type scan_id: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SqlPoolVulnerabilityAssessmentScansExport, or the result of cls(response) + :return: SqlPoolVulnerabilityAssessmentScansExport or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessmentScansExport - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolVulnerabilityAssessmentScansExport"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolVulnerabilityAssessmentScansExport] - request = build_export_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, vulnerability_assessment_name=vulnerability_assessment_name, scan_id=scan_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.export.metadata['url'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -499,18 +522,17 @@ def export( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('SqlPoolVulnerabilityAssessmentScansExport', pipeline_response) + deserialized = self._deserialize("SqlPoolVulnerabilityAssessmentScansExport", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SqlPoolVulnerabilityAssessmentScansExport', pipeline_response) + deserialized = self._deserialize("SqlPoolVulnerabilityAssessmentScansExport", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - export.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/export"} # type: ignore - + export.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/export"} # type: ignore @distributed_trace def get( @@ -521,67 +543,71 @@ def get( vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], scan_id: str, **kwargs: Any - ) -> "_models.VulnerabilityAssessmentScanRecord": + ) -> _models.VulnerabilityAssessmentScanRecord: """Gets a vulnerability assessment scan record of 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param vulnerability_assessment_name: The name of the vulnerability assessment. + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :param scan_id: The vulnerability assessment scan Id of the scan to retrieve. + :param scan_id: The vulnerability assessment scan Id of the scan to retrieve. Required. :type scan_id: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: VulnerabilityAssessmentScanRecord, or the result of cls(response) + :return: VulnerabilityAssessmentScanRecord or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.VulnerabilityAssessmentScanRecord - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VulnerabilityAssessmentScanRecord"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VulnerabilityAssessmentScanRecord] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, vulnerability_assessment_name=vulnerability_assessment_name, scan_id=scan_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}"} # 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 a3604ce17cf2..2503055ab41b 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 @@ -6,269 +6,266 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, sql_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments", + ) # 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'), + "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 = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", + ) # 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'), - "vulnerabilityAssessmentName": _SERIALIZER.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), + "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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", + ) # 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'), - "vulnerabilityAssessmentName": _SERIALIZER.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), + "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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", + ) # 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'), - "vulnerabilityAssessmentName": _SERIALIZER.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), + "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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) - -class SqlPoolVulnerabilityAssessmentsOperations(object): - """SqlPoolVulnerabilityAssessmentsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +class SqlPoolVulnerabilityAssessmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`sql_pool_vulnerability_assessments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> Iterable["_models.SqlPoolVulnerabilityAssessmentListResult"]: + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> Iterable["_models.SqlPoolVulnerabilityAssessment"]: """Lists the vulnerability assessment policies associated with a SQL pool. Lists the vulnerability assessment policies associated with 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SqlPoolVulnerabilityAssessmentListResult or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SqlPoolVulnerabilityAssessment or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolVulnerabilityAssessmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolVulnerabilityAssessmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, 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'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -282,10 +279,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -295,11 +290,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments"} # type: ignore @distributed_trace def get( @@ -309,69 +302,149 @@ def get( sql_pool_name: str, vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], **kwargs: Any - ) -> "_models.SqlPoolVulnerabilityAssessment": + ) -> _models.SqlPoolVulnerabilityAssessment: """Gets the Sql pool's vulnerability assessment. Gets the Sql pool's vulnerability assessment. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param vulnerability_assessment_name: The name of the vulnerability assessment. + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SqlPoolVulnerabilityAssessment, or the result of cls(response) + :return: SqlPoolVulnerabilityAssessment or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolVulnerabilityAssessment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolVulnerabilityAssessment] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}"} # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + parameters: _models.SqlPoolVulnerabilityAssessment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SqlPoolVulnerabilityAssessment: + """Creates or updates the Sql pool vulnerability assessment. + + Creates or updates the Sql pool vulnerability assessment. + :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 vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. + :type vulnerability_assessment_name: str or + ~azure.mgmt.synapse.models.VulnerabilityAssessmentName + :param parameters: The requested resource. Required. + :type parameters: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SqlPoolVulnerabilityAssessment: + """Creates or updates the Sql pool vulnerability assessment. + + Creates or updates the Sql pool vulnerability assessment. + + :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 vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. + :type vulnerability_assessment_name: str or + ~azure.mgmt.synapse.models.VulnerabilityAssessmentName + :param parameters: The requested resource. 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: SqlPoolVulnerabilityAssessment or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update( @@ -380,62 +453,78 @@ def create_or_update( workspace_name: str, sql_pool_name: str, vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], - parameters: "_models.SqlPoolVulnerabilityAssessment", + parameters: Union[_models.SqlPoolVulnerabilityAssessment, IO], **kwargs: Any - ) -> "_models.SqlPoolVulnerabilityAssessment": + ) -> _models.SqlPoolVulnerabilityAssessment: """Creates or updates the Sql pool vulnerability assessment. Creates or updates the Sql pool vulnerability assessment. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param vulnerability_assessment_name: The name of the vulnerability assessment. + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :param parameters: The requested resource. - :type parameters: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessment - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 - :return: SqlPoolVulnerabilityAssessment, or the result of cls(response) + :return: SqlPoolVulnerabilityAssessment or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPoolVulnerabilityAssessment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolVulnerabilityAssessment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolVulnerabilityAssessment] - _json = self._serialize.body(parameters, 'SqlPoolVulnerabilityAssessment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SqlPoolVulnerabilityAssessment") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, 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, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -443,18 +532,17 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('SqlPoolVulnerabilityAssessment', pipeline_response) + deserialized = self._deserialize("SqlPoolVulnerabilityAssessment", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SqlPoolVulnerabilityAssessment', pipeline_response) + deserialized = self._deserialize("SqlPoolVulnerabilityAssessment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -470,48 +558,53 @@ def delete( # pylint: disable=inconsistent-return-statements Removes the database's vulnerability assessment. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param vulnerability_assessment_name: The name of the vulnerability assessment. + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -521,5 +614,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}"} # 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 88a9aaae6ab2..24639fc8442a 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 @@ -6,217 +6,218 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, workload_group_name: str, workload_classifier_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}", + ) # 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'), - "workloadGroupName": _SERIALIZER.url("workload_group_name", workload_group_name, 'str'), - "workloadClassifierName": _SERIALIZER.url("workload_classifier_name", workload_classifier_name, 'str'), + "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"), + "workloadGroupName": _SERIALIZER.url("workload_group_name", workload_group_name, "str"), + "workloadClassifierName": _SERIALIZER.url("workload_classifier_name", workload_classifier_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, +def build_create_or_update_request( resource_group_name: str, workspace_name: str, sql_pool_name: str, workload_group_name: str, workload_classifier_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}", + ) # 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'), - "workloadGroupName": _SERIALIZER.url("workload_group_name", workload_group_name, 'str'), - "workloadClassifierName": _SERIALIZER.url("workload_classifier_name", workload_classifier_name, 'str'), + "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"), + "workloadGroupName": _SERIALIZER.url("workload_group_name", workload_group_name, "str"), + "workloadClassifierName": _SERIALIZER.url("workload_classifier_name", workload_classifier_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, +def build_delete_request( resource_group_name: str, workspace_name: str, sql_pool_name: str, workload_group_name: str, workload_classifier_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}", + ) # 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'), - "workloadGroupName": _SERIALIZER.url("workload_group_name", workload_group_name, 'str'), - "workloadClassifierName": _SERIALIZER.url("workload_classifier_name", workload_classifier_name, 'str'), + "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"), + "workloadGroupName": _SERIALIZER.url("workload_group_name", workload_group_name, "str"), + "workloadClassifierName": _SERIALIZER.url("workload_classifier_name", workload_classifier_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_list_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, workload_group_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers", + ) # 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'), - "workloadGroupName": _SERIALIZER.url("workload_group_name", workload_group_name, 'str'), + "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"), + "workloadGroupName": _SERIALIZER.url("workload_group_name", workload_group_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class SqlPoolWorkloadClassifierOperations(object): - """SqlPoolWorkloadClassifierOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SqlPoolWorkloadClassifierOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`sql_pool_workload_classifier` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( @@ -227,71 +228,74 @@ def get( workload_group_name: str, workload_classifier_name: str, **kwargs: Any - ) -> "_models.WorkloadClassifier": + ) -> _models.WorkloadClassifier: """Get workload classifier. Get a workload classifier of Sql pool's workload group. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param workload_group_name: The name of the workload group. + :param workload_group_name: The name of the workload group. Required. :type workload_group_name: str - :param workload_classifier_name: The name of the workload classifier. + :param workload_classifier_name: The name of the workload classifier. Required. :type workload_classifier_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: WorkloadClassifier, or the result of cls(response) + :return: WorkloadClassifier or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.WorkloadClassifier - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadClassifier"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkloadClassifier] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, workload_group_name=workload_group_name, workload_classifier_name=workload_classifier_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}"} # type: ignore def _create_or_update_initial( self, @@ -300,40 +304,54 @@ def _create_or_update_initial( sql_pool_name: str, workload_group_name: str, workload_classifier_name: str, - parameters: "_models.WorkloadClassifier", + parameters: Union[_models.WorkloadClassifier, IO], **kwargs: Any - ) -> Optional["_models.WorkloadClassifier"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WorkloadClassifier"]] + ) -> Optional[_models.WorkloadClassifier]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'WorkloadClassifier') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WorkloadClassifier]] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "WorkloadClassifier") + + request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, workload_group_name=workload_group_name, workload_classifier_name=workload_classifier_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -342,18 +360,111 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('WorkloadClassifier', pipeline_response) + deserialized = self._deserialize("WorkloadClassifier", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('WorkloadClassifier', pipeline_response) + deserialized = self._deserialize("WorkloadClassifier", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + workload_group_name: str, + workload_classifier_name: str, + parameters: _models.WorkloadClassifier, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkloadClassifier]: + """Create Or Update workload classifier. + + Create Or Update workload classifier for a Sql pool's workload group. + + :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 workload_group_name: The name of the workload group. Required. + :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. Required. + :type parameters: ~azure.mgmt.synapse.models.WorkloadClassifier + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + workload_group_name: str, + workload_classifier_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkloadClassifier]: + """Create Or Update workload classifier. + + Create Or Update workload classifier for a Sql pool's workload group. + + :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 workload_group_name: The name of the workload group. Required. + :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. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WorkloadClassifier or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.WorkloadClassifier] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -363,28 +474,30 @@ def begin_create_or_update( sql_pool_name: str, workload_group_name: str, workload_classifier_name: str, - parameters: "_models.WorkloadClassifier", + parameters: Union[_models.WorkloadClassifier, IO], **kwargs: Any - ) -> LROPoller["_models.WorkloadClassifier"]: + ) -> LROPoller[_models.WorkloadClassifier]: """Create Or Update workload classifier. Create Or Update workload classifier for a Sql pool's workload group. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param workload_group_name: The name of the workload group. + :param workload_group_name: The name of the workload group. Required. :type workload_group_name: str - :param workload_classifier_name: The name of the workload classifier. + :param workload_classifier_name: The name of the workload classifier. Required. :type workload_classifier_name: str - :param parameters: The properties of the workload classifier. - :type parameters: ~azure.mgmt.synapse.models.WorkloadClassifier - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 @@ -396,19 +509,19 @@ def begin_create_or_update( :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] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadClassifier"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkloadClassifier] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -417,32 +530,35 @@ def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WorkloadClassifier', pipeline_response) + deserialized = self._deserialize("WorkloadClassifier", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -453,33 +569,39 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements workload_classifier_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + 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, workload_classifier_name=workload_classifier_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -489,11 +611,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements + def begin_delete( self, resource_group_name: str, workspace_name: str, @@ -507,18 +628,16 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Remove workload classifier of a Sql pool's workload group. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param workload_group_name: The name of the workload group. + :param workload_group_name: The name of the workload group. Required. :type workload_group_name: str - :param workload_classifier_name: The name of the workload classifier. + :param workload_classifier_name: The name of the workload classifier. Required. :type workload_classifier_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -529,113 +648,109 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, workload_group_name=workload_group_name, workload_classifier_name=workload_classifier_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - workload_group_name: str, - **kwargs: Any - ) -> Iterable["_models.WorkloadClassifierListResult"]: + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, workload_group_name: str, **kwargs: Any + ) -> Iterable["_models.WorkloadClassifier"]: """Sql pool's workload classifier. Get list of Sql pool's workload classifier for workload groups. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param workload_group_name: The name of the workload group. + :param workload_group_name: The name of the workload group. Required. :type workload_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkloadClassifierListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.WorkloadClassifierListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkloadClassifierListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadClassifierListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, 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'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - workload_group_name=workload_group_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -649,10 +764,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -662,8 +775,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}/workloadClassifiers"} # type: ignore 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 2e4ca875eac0..d89b4dae6c08 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 @@ -6,280 +6,275 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, workspace_name: str, sql_pool_name: str, workload_group_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}", + ) # 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'), - "workloadGroupName": _SERIALIZER.url("workload_group_name", workload_group_name, 'str'), + "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"), + "workloadGroupName": _SERIALIZER.url("workload_group_name", workload_group_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, +def build_create_or_update_request( resource_group_name: str, workspace_name: str, sql_pool_name: str, workload_group_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}", + ) # 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'), - "workloadGroupName": _SERIALIZER.url("workload_group_name", workload_group_name, 'str'), + "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"), + "workloadGroupName": _SERIALIZER.url("workload_group_name", workload_group_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, +def build_delete_request( resource_group_name: str, workspace_name: str, sql_pool_name: str, workload_group_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}", + ) # 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'), - "workloadGroupName": _SERIALIZER.url("workload_group_name", workload_group_name, 'str'), + "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"), + "workloadGroupName": _SERIALIZER.url("workload_group_name", workload_group_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_list_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, sql_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups", + ) # 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'), + "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 = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class SqlPoolWorkloadGroupOperations(object): - """SqlPoolWorkloadGroupOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SqlPoolWorkloadGroupOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`sql_pool_workload_group` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - workload_group_name: str, - **kwargs: Any - ) -> "_models.WorkloadGroup": + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, workload_group_name: str, **kwargs: Any + ) -> _models.WorkloadGroup: """Sql pool's workload group. Get a Sql pool's workload group. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param workload_group_name: The name of the workload group. + :param workload_group_name: The name of the workload group. Required. :type workload_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: WorkloadGroup, or the result of cls(response) + :return: WorkloadGroup or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.WorkloadGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkloadGroup] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}"} # type: ignore def _create_or_update_initial( self, @@ -287,39 +282,53 @@ def _create_or_update_initial( workspace_name: str, sql_pool_name: str, workload_group_name: str, - parameters: "_models.WorkloadGroup", + parameters: Union[_models.WorkloadGroup, IO], **kwargs: Any - ) -> Optional["_models.WorkloadGroup"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WorkloadGroup"]] + ) -> Optional[_models.WorkloadGroup]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'WorkloadGroup') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.WorkloadGroup]] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "WorkloadGroup") + + request = build_create_or_update_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, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: @@ -328,18 +337,105 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('WorkloadGroup', pipeline_response) + deserialized = self._deserialize("WorkloadGroup", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('WorkloadGroup', pipeline_response) + deserialized = self._deserialize("WorkloadGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + workload_group_name: str, + parameters: _models.WorkloadGroup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkloadGroup]: + """Create Or Update workload group. + + Create Or Update a Sql pool's workload group. + + :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 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: ~azure.mgmt.synapse.models.WorkloadGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + workload_group_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkloadGroup]: + """Create Or Update workload group. + + Create Or Update a Sql pool's workload group. + :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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -348,26 +444,28 @@ def begin_create_or_update( workspace_name: str, sql_pool_name: str, workload_group_name: str, - parameters: "_models.WorkloadGroup", + parameters: Union[_models.WorkloadGroup, IO], **kwargs: Any - ) -> LROPoller["_models.WorkloadGroup"]: + ) -> LROPoller[_models.WorkloadGroup]: """Create Or Update workload group. Create Or Update a Sql pool's workload group. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param workload_group_name: The name of the workload group. + :param workload_group_name: The name of the workload group. Required. :type workload_group_name: str - :param parameters: The requested workload group state. - :type parameters: ~azure.mgmt.synapse.models.WorkloadGroup - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 @@ -379,19 +477,19 @@ def begin_create_or_update( :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] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadGroup"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkloadGroup] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, @@ -399,67 +497,71 @@ def begin_create_or_update( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WorkloadGroup', pipeline_response) + deserialized = self._deserialize("WorkloadGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - workload_group_name: str, - **kwargs: Any + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, workload_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + 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'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -469,33 +571,25 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - workload_group_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, workload_group_name: str, **kwargs: Any ) -> LROPoller[None]: """Remove workload group. Remove Sql pool's workload group. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param workload_group_name: The name of the workload group. + :param workload_group_name: The name of the workload group. Required. :type workload_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -506,107 +600,105 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, workload_group_name=workload_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups/{workloadGroupName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> Iterable["_models.WorkloadGroupListResult"]: + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> Iterable["_models.WorkloadGroup"]: """Sql pool's workload groups. Get list of Sql pool's workload groups. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkloadGroupListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.WorkloadGroupListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkloadGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadGroupListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, 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'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - sql_pool_name=sql_pool_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -620,10 +712,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -633,8 +723,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/workloadGroups"} # type: ignore 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 6f6deb6a366e..f01c6b10ab1a 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,425 +6,388 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, sql_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}", + ) # 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'), + "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 = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, workspace_name: str, sql_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}", + ) # 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'), + "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 = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, workspace_name: str, sql_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}", + ) # 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'), + "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 = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, workspace_name: str, sql_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}", + ) # 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'), + "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 = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_workspace_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools", + ) # 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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_pause_request_initial( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_pause_request( + resource_group_name: str, workspace_name: str, sql_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/pause") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/pause", + ) # 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'), + "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 = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_resume_request_initial( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resume_request( + resource_group_name: str, workspace_name: str, sql_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/resume") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/resume", + ) # 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'), + "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 = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_rename_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, workspace_name: str, sql_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/move") # pylint: disable=line-too-long + _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'), + "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 = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - -class SqlPoolsOperations(object): - """SqlPoolsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class SqlPoolsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`sql_pools` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> "_models.SqlPool": + def get(self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any) -> _models.SqlPool: """Get SQL pool. Get SQL pool properties. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SqlPool, or the result of cls(response) + :return: SqlPool or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPool"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPool] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -432,15 +395,80 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}"} # type: ignore + @overload + def update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + sql_pool_info: _models.SqlPoolPatchInfo, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.SqlPool]: + """Update SQL pool. + + Apply a partial update to 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 sql_pool_info: The updated SQL pool properties. Required. + :type sql_pool_info: ~azure.mgmt.synapse.models.SqlPoolPatchInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: SqlPool or None or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.SqlPool or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + sql_pool_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.SqlPool]: + """Update SQL pool. + + Apply a partial update to 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 sql_pool_info: The updated SQL pool properties. Required. + :type sql_pool_info: 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: SqlPool or None or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.SqlPool or None + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( @@ -448,58 +476,74 @@ def update( resource_group_name: str, workspace_name: str, sql_pool_name: str, - sql_pool_info: "_models.SqlPoolPatchInfo", + sql_pool_info: Union[_models.SqlPoolPatchInfo, IO], **kwargs: Any - ) -> Optional["_models.SqlPool"]: + ) -> Optional[_models.SqlPool]: """Update SQL pool. Apply a partial update to 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param sql_pool_info: The updated SQL pool properties. - :type sql_pool_info: ~azure.mgmt.synapse.models.SqlPoolPatchInfo - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 - :return: SqlPool, or the result of cls(response) + :return: SqlPool or None or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.SqlPool or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.SqlPool"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(sql_pool_info, 'SqlPoolPatchInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SqlPool]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(sql_pool_info, (IO, bytes)): + _content = sql_pool_info + else: + _json = self._serialize.body(sql_pool_info, "SqlPoolPatchInfo") request = build_update_request( - subscription_id=self._config.subscription_id, 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, - template_url=self.update.metadata['url'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -509,70 +553,163 @@ def update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SqlPool', pipeline_response) + deserialized = self._deserialize("SqlPool", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}"} # type: ignore def _create_initial( self, resource_group_name: str, workspace_name: str, sql_pool_name: str, - sql_pool_info: "_models.SqlPool", + sql_pool_info: Union[_models.SqlPool, IO], **kwargs: Any - ) -> Optional["_models.SqlPool"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.SqlPool"]] + ) -> Optional[_models.SqlPool]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(sql_pool_info, 'SqlPool') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SqlPool]] - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(sql_pool_info, (IO, bytes)): + _content = sql_pool_info + else: + _json = self._serialize.body(sql_pool_info, "SqlPool") + + request = build_create_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, - template_url=self._create_initial.metadata['url'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response - if response.status_code not in [200, 202, 404]: + if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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 = self._deserialize("SqlPool", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}"} # type: ignore + @overload + def begin_create( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + sql_pool_info: _models.SqlPool, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SqlPool]: + """Create SQL pool. + + Create 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 sql_pool_info: The SQL pool to create. Required. + :type sql_pool_info: ~azure.mgmt.synapse.models.SqlPool + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + workspace_name: str, + sql_pool_name: str, + sql_pool_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SqlPool]: + """Create SQL pool. + + Create 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 sql_pool_info: The SQL pool to create. Required. + :type sql_pool_info: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either SqlPool or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.SqlPool] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( @@ -580,24 +717,25 @@ def begin_create( resource_group_name: str, workspace_name: str, sql_pool_name: str, - sql_pool_info: "_models.SqlPool", + sql_pool_info: Union[_models.SqlPool, IO], **kwargs: Any - ) -> LROPoller["_models.SqlPool"]: + ) -> LROPoller[_models.SqlPool]: """Create SQL pool. Create 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param sql_pool_info: The SQL pool to create. - :type sql_pool_info: ~azure.mgmt.synapse.models.SqlPool - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 @@ -608,126 +746,127 @@ def begin_create( 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPool"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPool] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, sql_pool_info=sql_pool_info, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('SqlPool', pipeline_response) + deserialized = self._deserialize("SqlPool", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}"} # type: ignore def _delete_initial( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> Optional[Any]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[Any]] + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> Optional[JSON]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[JSON]] + + 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'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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('object', pipeline_response) + deserialized = self._deserialize("object", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('object', pipeline_response) + deserialized = self._deserialize("object", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}"} # type: ignore @distributed_trace def begin_delete( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> LROPoller[Any]: + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> LROPoller[JSON]: """Delete SQL pool. Delete 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -736,106 +875,107 @@ def begin_delete( :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either any or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[any] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An instance of LROPoller that returns either JSON or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[JSON] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Any] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[JSON] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('object', pipeline_response) + deserialized = self._deserialize("object", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}"} # type: ignore @distributed_trace def list_by_workspace( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> Iterable["_models.SqlPoolInfoListResult"]: + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> Iterable["_models.SqlPool"]: """List SQL pools. List all SQL pools. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SqlPoolInfoListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.SqlPoolInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SqlPoolInfoListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SqlPoolInfoListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore else: - - request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -849,10 +989,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -863,83 +1001,77 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_workspace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools"} # type: ignore + list_by_workspace.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools"} # type: ignore def _pause_initial( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> Optional[Any]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[Any]] + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> Optional[JSON]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_pause_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[JSON]] + + 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'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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('object', pipeline_response) + deserialized = self._deserialize("object", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _pause_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/pause"} # type: ignore - + _pause_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/pause"} # type: ignore @distributed_trace def begin_pause( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> LROPoller[Any]: + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> LROPoller[JSON]: """Pause SQL pool. Pause 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -948,122 +1080,123 @@ def begin_pause( :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either any or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[any] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An instance of LROPoller that returns either JSON or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[JSON] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Any] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[JSON] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._pause_initial( + raw_result = self._pause_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('object', pipeline_response) + deserialized = self._deserialize("object", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_pause.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/pause"} # type: ignore + begin_pause.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/pause"} # type: ignore def _resume_initial( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> Optional[Any]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[Any]] + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> Optional[JSON]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_resume_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[JSON]] + + 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'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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('object', pipeline_response) + deserialized = self._deserialize("object", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _resume_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/resume"} # type: ignore - + _resume_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/resume"} # type: ignore @distributed_trace def begin_resume( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> LROPoller[Any]: + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> LROPoller[JSON]: """Resume SQL pool. Resume 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -1072,58 +1205,65 @@ def begin_resume( :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either any or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[any] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An instance of LROPoller that returns either JSON or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[JSON] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Any] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[JSON] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._resume_initial( + raw_result = self._resume_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, sql_pool_name=sql_pool_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('object', pipeline_response) + deserialized = self._deserialize("object", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_resume.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/resume"} # type: ignore + begin_resume.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/resume"} # type: ignore - @distributed_trace + @overload def rename( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, workspace_name: str, sql_pool_name: str, - parameters: "_models.ResourceMoveDefinition", + parameters: _models.ResourceMoveDefinition, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Rename a SQL pool. @@ -1131,50 +1271,130 @@ def rename( # pylint: disable=inconsistent-return-statements 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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: SQL pool name. + :param sql_pool_name: SQL pool name. Required. :type sql_pool_name: str - :param parameters: The resource move definition for renaming this Sql pool. + :param parameters: The resource move definition for renaming this Sql pool. Required. :type parameters: ~azure.mgmt.synapse.models.ResourceMoveDefinition - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(parameters, 'ResourceMoveDefinition') + 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( - subscription_id=self._config.subscription_id, 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, - template_url=self.rename.metadata['url'], + content=_content, + template_url=self.rename.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1184,5 +1404,4 @@ def rename( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - rename.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/move"} # type: ignore - + rename.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlPools/{sqlPoolName}/move"} # type: ignore 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 20bd5bf56e1c..ed8a865919ba 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 @@ -6,210 +6,201 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/administrators/activeDirectory") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/administrators/activeDirectory", + ) # 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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, workspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/administrators/activeDirectory") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/administrators/activeDirectory", + ) # 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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - **kwargs: Any + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, workspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/administrators/activeDirectory") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/administrators/activeDirectory", + ) # 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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class WorkspaceAadAdminsOperations(object): - """WorkspaceAadAdminsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceAadAdminsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`workspace_aad_admins` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> "_models.WorkspaceAadAdminInfo": + def get(self, resource_group_name: str, workspace_name: str, **kwargs: Any) -> _models.WorkspaceAadAdminInfo: """Gets a workspace active directory admin. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: WorkspaceAadAdminInfo, or the result of cls(response) + :return: WorkspaceAadAdminInfo or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.WorkspaceAadAdminInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceAadAdminInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkspaceAadAdminInfo] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -217,90 +208,177 @@ def get( 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/administrators/activeDirectory"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/administrators/activeDirectory"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, workspace_name: str, - aad_admin_info: "_models.WorkspaceAadAdminInfo", + aad_admin_info: Union[_models.WorkspaceAadAdminInfo, IO], **kwargs: Any - ) -> "_models.WorkspaceAadAdminInfo": - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceAadAdminInfo"] + ) -> _models.WorkspaceAadAdminInfo: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(aad_admin_info, 'WorkspaceAadAdminInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkspaceAadAdminInfo] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(aad_admin_info, (IO, bytes)): + _content = aad_admin_info + else: + _json = self._serialize.body(aad_admin_info, "WorkspaceAadAdminInfo") + + request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("WorkspaceAadAdminInfo", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('WorkspaceAadAdminInfo', pipeline_response) + deserialized = self._deserialize("WorkspaceAadAdminInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/administrators/activeDirectory"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/administrators/activeDirectory"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + aad_admin_info: _models.WorkspaceAadAdminInfo, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkspaceAadAdminInfo]: + """Creates or updates a workspace active directory admin. + + :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 aad_admin_info: Workspace active directory administrator properties. Required. + :type aad_admin_info: ~azure.mgmt.synapse.models.WorkspaceAadAdminInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + aad_admin_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkspaceAadAdminInfo]: + """Creates or updates a workspace active directory admin. + :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 aad_admin_info: Workspace active directory administrator properties. Required. + :type aad_admin_info: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WorkspaceAadAdminInfo or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.WorkspaceAadAdminInfo] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( self, resource_group_name: str, workspace_name: str, - aad_admin_info: "_models.WorkspaceAadAdminInfo", + aad_admin_info: Union[_models.WorkspaceAadAdminInfo, IO], **kwargs: Any - ) -> LROPoller["_models.WorkspaceAadAdminInfo"]: + ) -> LROPoller[_models.WorkspaceAadAdminInfo]: """Creates or updates a workspace active directory admin. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param aad_admin_info: Workspace active directory administrator properties. - :type aad_admin_info: ~azure.mgmt.synapse.models.WorkspaceAadAdminInfo - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 @@ -312,109 +390,110 @@ def begin_create_or_update( :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] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceAadAdminInfo"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkspaceAadAdminInfo] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, aad_admin_info=aad_admin_info, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WorkspaceAadAdminInfo', pipeline_response) + deserialized = self._deserialize("WorkspaceAadAdminInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/administrators/activeDirectory"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/administrators/activeDirectory"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any + self, resource_group_name: str, workspace_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + 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'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/administrators/activeDirectory"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/administrators/activeDirectory"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, workspace_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a workspace active directory admin. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -425,41 +504,47 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/administrators/activeDirectory"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/administrators/activeDirectory"} # 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 9ec6d9752dcb..8f8ebe1f5fcf 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 @@ -6,176 +6,172 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/managedIdentitySqlControlSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/managedIdentitySqlControlSettings/default", + ) # 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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, workspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/managedIdentitySqlControlSettings/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/managedIdentitySqlControlSettings/default", + ) # 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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - -class WorkspaceManagedIdentitySqlControlSettingsOperations(object): - """WorkspaceManagedIdentitySqlControlSettingsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceManagedIdentitySqlControlSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`workspace_managed_identity_sql_control_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> "_models.ManagedIdentitySqlControlSettingsModel": + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> _models.ManagedIdentitySqlControlSettingsModel: """Get Managed Identity Sql Control Settings. Get Managed Identity Sql Control Settings. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagedIdentitySqlControlSettingsModel, or the result of cls(response) + :return: ManagedIdentitySqlControlSettingsModel or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ManagedIdentitySqlControlSettingsModel - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedIdentitySqlControlSettingsModel"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagedIdentitySqlControlSettingsModel] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -183,91 +179,187 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/managedIdentitySqlControlSettings/default"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/managedIdentitySqlControlSettings/default"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, workspace_name: str, - managed_identity_sql_control_settings: "_models.ManagedIdentitySqlControlSettingsModel", + managed_identity_sql_control_settings: Union[_models.ManagedIdentitySqlControlSettingsModel, IO], **kwargs: Any - ) -> Optional["_models.ManagedIdentitySqlControlSettingsModel"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ManagedIdentitySqlControlSettingsModel"]] + ) -> Optional[_models.ManagedIdentitySqlControlSettingsModel]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(managed_identity_sql_control_settings, 'ManagedIdentitySqlControlSettingsModel') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ManagedIdentitySqlControlSettingsModel]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(managed_identity_sql_control_settings, (IO, bytes)): + _content = managed_identity_sql_control_settings + else: + _json = self._serialize.body( + managed_identity_sql_control_settings, "ManagedIdentitySqlControlSettingsModel" + ) - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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('ManagedIdentitySqlControlSettingsModel', pipeline_response) + deserialized = self._deserialize("ManagedIdentitySqlControlSettingsModel", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/managedIdentitySqlControlSettings/default"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/managedIdentitySqlControlSettings/default"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + managed_identity_sql_control_settings: _models.ManagedIdentitySqlControlSettingsModel, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedIdentitySqlControlSettingsModel]: + """Create or update Managed Identity Sql Control Settings. + Create or update Managed Identity Sql Control Settings. + + :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 managed_identity_sql_control_settings: Managed Identity Sql Control Settings. Required. + :type managed_identity_sql_control_settings: + ~azure.mgmt.synapse.models.ManagedIdentitySqlControlSettingsModel + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: + ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.ManagedIdentitySqlControlSettingsModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + managed_identity_sql_control_settings: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedIdentitySqlControlSettingsModel]: + """Create or update Managed Identity Sql Control Settings. + + Create or update Managed Identity Sql Control Settings. + + :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 managed_identity_sql_control_settings: Managed Identity Sql Control Settings. Required. + :type managed_identity_sql_control_settings: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ManagedIdentitySqlControlSettingsModel or + the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.ManagedIdentitySqlControlSettingsModel] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( self, resource_group_name: str, workspace_name: str, - managed_identity_sql_control_settings: "_models.ManagedIdentitySqlControlSettingsModel", + managed_identity_sql_control_settings: Union[_models.ManagedIdentitySqlControlSettingsModel, IO], **kwargs: Any - ) -> LROPoller["_models.ManagedIdentitySqlControlSettingsModel"]: + ) -> LROPoller[_models.ManagedIdentitySqlControlSettingsModel]: """Create or update Managed Identity Sql Control Settings. Create or update Managed Identity Sql Control Settings. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param managed_identity_sql_control_settings: Managed Identity Sql Control Settings. + :param managed_identity_sql_control_settings: Managed Identity Sql Control Settings. Is either + a model type or a IO type. Required. :type managed_identity_sql_control_settings: - ~azure.mgmt.synapse.models.ManagedIdentitySqlControlSettingsModel - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + ~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 @@ -280,47 +372,52 @@ def begin_create_or_update( the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.ManagedIdentitySqlControlSettingsModel] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedIdentitySqlControlSettingsModel"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagedIdentitySqlControlSettingsModel] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, managed_identity_sql_control_settings=managed_identity_sql_control_settings, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ManagedIdentitySqlControlSettingsModel', pipeline_response) + deserialized = self._deserialize("ManagedIdentitySqlControlSettingsModel", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/managedIdentitySqlControlSettings/default"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/managedIdentitySqlControlSettings/default"} # 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 aefe9127afdb..f6f96b396247 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 @@ -6,169 +6,167 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, workspace_name: str, blob_auditing_policy_name: Union[str, "_models.BlobAuditingPolicyName"], + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/auditingSettings/{blobAuditingPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/auditingSettings/{blobAuditingPolicyName}", + ) # 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'), - "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, 'str'), + "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"), + "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, +def build_create_or_update_request( resource_group_name: str, workspace_name: str, blob_auditing_policy_name: Union[str, "_models.BlobAuditingPolicyName"], - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/auditingSettings/{blobAuditingPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/auditingSettings/{blobAuditingPolicyName}", + ) # 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'), - "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, 'str'), + "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"), + "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_workspace_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/auditingSettings") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/auditingSettings", + ) # 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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class WorkspaceManagedSqlServerBlobAuditingPoliciesOperations(object): - """WorkspaceManagedSqlServerBlobAuditingPoliciesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceManagedSqlServerBlobAuditingPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`workspace_managed_sql_server_blob_auditing_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( @@ -177,103 +175,120 @@ def get( workspace_name: str, blob_auditing_policy_name: Union[str, "_models.BlobAuditingPolicyName"], **kwargs: Any - ) -> "_models.ServerBlobAuditingPolicy": + ) -> _models.ServerBlobAuditingPolicy: """Get server's blob auditing policy. Get a workspace managed sql server's blob auditing policy. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param blob_auditing_policy_name: The name of the blob auditing policy. + :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 api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServerBlobAuditingPolicy, or the result of cls(response) + :return: ServerBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ServerBlobAuditingPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerBlobAuditingPolicy"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServerBlobAuditingPolicy] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/auditingSettings/{blobAuditingPolicyName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/auditingSettings/{blobAuditingPolicyName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, workspace_name: str, blob_auditing_policy_name: Union[str, "_models.BlobAuditingPolicyName"], - parameters: "_models.ServerBlobAuditingPolicy", + parameters: Union[_models.ServerBlobAuditingPolicy, IO], **kwargs: Any - ) -> Optional["_models.ServerBlobAuditingPolicy"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ServerBlobAuditingPolicy"]] + ) -> Optional[_models.ServerBlobAuditingPolicy]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ServerBlobAuditingPolicy') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ServerBlobAuditingPolicy]] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServerBlobAuditingPolicy") + + request = build_create_or_update_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, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -282,15 +297,96 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ServerBlobAuditingPolicy', pipeline_response) + deserialized = self._deserialize("ServerBlobAuditingPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/auditingSettings/{blobAuditingPolicyName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/auditingSettings/{blobAuditingPolicyName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + blob_auditing_policy_name: Union[str, "_models.BlobAuditingPolicyName"], + parameters: _models.ServerBlobAuditingPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerBlobAuditingPolicy]: + """Create or Update server's blob auditing policy. + + Create or Update a workspace managed sql server's blob auditing policy. + + :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 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: ~azure.mgmt.synapse.models.ServerBlobAuditingPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + blob_auditing_policy_name: Union[str, "_models.BlobAuditingPolicyName"], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerBlobAuditingPolicy]: + """Create or Update server's blob auditing policy. + + Create or Update a workspace managed sql server's blob auditing policy. + + :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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -298,24 +394,26 @@ def begin_create_or_update( resource_group_name: str, workspace_name: str, blob_auditing_policy_name: Union[str, "_models.BlobAuditingPolicyName"], - parameters: "_models.ServerBlobAuditingPolicy", + parameters: Union[_models.ServerBlobAuditingPolicy, IO], **kwargs: Any - ) -> LROPoller["_models.ServerBlobAuditingPolicy"]: + ) -> LROPoller[_models.ServerBlobAuditingPolicy]: """Create or Update server's blob auditing policy. Create or Update a workspace managed sql server's blob auditing policy. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param blob_auditing_policy_name: The name of the blob auditing policy. + :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. - :type parameters: ~azure.mgmt.synapse.models.ServerBlobAuditingPolicy - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 @@ -327,108 +425,107 @@ def begin_create_or_update( :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] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerBlobAuditingPolicy"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServerBlobAuditingPolicy] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, blob_auditing_policy_name=blob_auditing_policy_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServerBlobAuditingPolicy', pipeline_response) + deserialized = self._deserialize("ServerBlobAuditingPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/auditingSettings/{blobAuditingPolicyName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/auditingSettings/{blobAuditingPolicyName}"} # type: ignore @distributed_trace def list_by_workspace( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> Iterable["_models.ServerBlobAuditingPolicyListResult"]: + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> Iterable["_models.ServerBlobAuditingPolicy"]: """List workspace server's blob auditing policies. List workspace managed sql server's blob auditing policies. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServerBlobAuditingPolicyListResult or the result - of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.ServerBlobAuditingPolicyListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ServerBlobAuditingPolicy or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.ServerBlobAuditingPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServerBlobAuditingPolicyListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerBlobAuditingPolicyListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore else: - - request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -442,10 +539,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -455,8 +550,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_workspace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/auditingSettings"} # type: ignore + list_by_workspace.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/auditingSettings"} # type: ignore 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 db03602e0f37..808a2ec77302 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 @@ -6,224 +6,328 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_update_request_initial( - subscription_id: str, + +def build_update_request( resource_group_name: str, workspace_name: str, dedicated_sq_lminimal_tls_settings_name: Union[str, "_models.DedicatedSQLMinimalTlsSettingsName"], - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/dedicatedSQLminimalTlsSettings/{dedicatedSQLminimalTlsSettingsName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/dedicatedSQLminimalTlsSettings/{dedicatedSQLminimalTlsSettingsName}", + ) # 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'), - "dedicatedSQLminimalTlsSettingsName": _SERIALIZER.url("dedicated_sq_lminimal_tls_settings_name", dedicated_sq_lminimal_tls_settings_name, 'str'), + "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"), + "dedicatedSQLminimalTlsSettingsName": _SERIALIZER.url( + "dedicated_sq_lminimal_tls_settings_name", dedicated_sq_lminimal_tls_settings_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, resource_group_name: str, workspace_name: str, dedicated_sq_lminimal_tls_settings_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/dedicatedSQLminimalTlsSettings/{dedicatedSQLminimalTlsSettingsName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/dedicatedSQLminimalTlsSettings/{dedicatedSQLminimalTlsSettingsName}", + ) # 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'), - "dedicatedSQLminimalTlsSettingsName": _SERIALIZER.url("dedicated_sq_lminimal_tls_settings_name", dedicated_sq_lminimal_tls_settings_name, 'str'), + "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"), + "dedicatedSQLminimalTlsSettingsName": _SERIALIZER.url( + "dedicated_sq_lminimal_tls_settings_name", dedicated_sq_lminimal_tls_settings_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/dedicatedSQLminimalTlsSettings") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/dedicatedSQLminimalTlsSettings", + ) # 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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class WorkspaceManagedSqlServerDedicatedSQLMinimalTlsSettingsOperations(object): - """WorkspaceManagedSqlServerDedicatedSQLMinimalTlsSettingsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceManagedSqlServerDedicatedSQLMinimalTlsSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`workspace_managed_sql_server_dedicated_sql_minimal_tls_settings` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _update_initial( self, resource_group_name: str, workspace_name: str, dedicated_sq_lminimal_tls_settings_name: Union[str, "_models.DedicatedSQLMinimalTlsSettingsName"], - parameters: "_models.DedicatedSQLminimalTlsSettings", + parameters: Union[_models.DedicatedSQLminimalTlsSettings, IO], **kwargs: Any - ) -> Optional["_models.DedicatedSQLminimalTlsSettings"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DedicatedSQLminimalTlsSettings"]] + ) -> Optional[_models.DedicatedSQLminimalTlsSettings]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'DedicatedSQLminimalTlsSettings') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.DedicatedSQLminimalTlsSettings]] - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "DedicatedSQLminimalTlsSettings") + + 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, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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 = self._deserialize("DedicatedSQLminimalTlsSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/dedicatedSQLminimalTlsSettings/{dedicatedSQLminimalTlsSettingsName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/dedicatedSQLminimalTlsSettings/{dedicatedSQLminimalTlsSettingsName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + workspace_name: str, + dedicated_sq_lminimal_tls_settings_name: Union[str, "_models.DedicatedSQLMinimalTlsSettingsName"], + parameters: _models.DedicatedSQLminimalTlsSettings, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DedicatedSQLminimalTlsSettings]: + """Update server's tls settings. + + Update workspace managed sql server's minimal tls settings. + + :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 dedicated_sq_lminimal_tls_settings_name: The name of the dedicated sql minimal tls + settings. "default" Required. + :type dedicated_sq_lminimal_tls_settings_name: str or + ~azure.mgmt.synapse.models.DedicatedSQLMinimalTlsSettingsName + :param parameters: minimal tls settings. Required. + :type parameters: ~azure.mgmt.synapse.models.DedicatedSQLminimalTlsSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: + ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.DedicatedSQLminimalTlsSettings] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + workspace_name: str, + dedicated_sq_lminimal_tls_settings_name: Union[str, "_models.DedicatedSQLMinimalTlsSettingsName"], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DedicatedSQLminimalTlsSettings]: + """Update server's tls settings. + + Update workspace managed sql server's minimal tls settings. + :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 dedicated_sq_lminimal_tls_settings_name: The name of the dedicated sql minimal tls + settings. "default" Required. + :type dedicated_sq_lminimal_tls_settings_name: str or + ~azure.mgmt.synapse.models.DedicatedSQLMinimalTlsSettingsName + :param parameters: minimal tls settings. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DedicatedSQLminimalTlsSettings or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.DedicatedSQLminimalTlsSettings] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -231,26 +335,27 @@ def begin_update( resource_group_name: str, workspace_name: str, dedicated_sq_lminimal_tls_settings_name: Union[str, "_models.DedicatedSQLMinimalTlsSettingsName"], - parameters: "_models.DedicatedSQLminimalTlsSettings", + parameters: Union[_models.DedicatedSQLminimalTlsSettings, IO], **kwargs: Any - ) -> LROPoller["_models.DedicatedSQLminimalTlsSettings"]: + ) -> LROPoller[_models.DedicatedSQLminimalTlsSettings]: """Update server's tls settings. Update workspace managed sql server's minimal tls settings. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str :param dedicated_sq_lminimal_tls_settings_name: The name of the dedicated sql minimal tls - settings. + settings. "default" Required. :type dedicated_sq_lminimal_tls_settings_name: str or ~azure.mgmt.synapse.models.DedicatedSQLMinimalTlsSettingsName - :param parameters: minimal tls settings. - :type parameters: ~azure.mgmt.synapse.models.DedicatedSQLminimalTlsSettings - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 @@ -263,104 +368,107 @@ def begin_update( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.DedicatedSQLminimalTlsSettings] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedSQLminimalTlsSettings"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DedicatedSQLminimalTlsSettings] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, dedicated_sq_lminimal_tls_settings_name=dedicated_sq_lminimal_tls_settings_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DedicatedSQLminimalTlsSettings', pipeline_response) + deserialized = self._deserialize("DedicatedSQLminimalTlsSettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/dedicatedSQLminimalTlsSettings/{dedicatedSQLminimalTlsSettingsName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/dedicatedSQLminimalTlsSettings/{dedicatedSQLminimalTlsSettingsName}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - workspace_name: str, - dedicated_sq_lminimal_tls_settings_name: str, - **kwargs: Any - ) -> "_models.DedicatedSQLminimalTlsSettings": + self, resource_group_name: str, workspace_name: str, dedicated_sq_lminimal_tls_settings_name: str, **kwargs: Any + ) -> _models.DedicatedSQLminimalTlsSettings: """Get server's minimal tls settings. Get workspace managed sql server's minimal tls settings. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str :param dedicated_sq_lminimal_tls_settings_name: The name of the dedicated sql minimal tls - settings. + settings. Required. :type dedicated_sq_lminimal_tls_settings_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DedicatedSQLminimalTlsSettings, or the result of cls(response) + :return: DedicatedSQLminimalTlsSettings or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.DedicatedSQLminimalTlsSettings - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedSQLminimalTlsSettings"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DedicatedSQLminimalTlsSettings] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -368,72 +476,67 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/dedicatedSQLminimalTlsSettings/{dedicatedSQLminimalTlsSettingsName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/dedicatedSQLminimalTlsSettings/{dedicatedSQLminimalTlsSettingsName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> Iterable["_models.DedicatedSQLminimalTlsSettingsListResult"]: + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> Iterable["_models.DedicatedSQLminimalTlsSettings"]: """List workspace server's minimal tls settings. List workspace managed sql server's minimal tls settings. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DedicatedSQLminimalTlsSettingsListResult or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.DedicatedSQLminimalTlsSettingsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DedicatedSQLminimalTlsSettings or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.DedicatedSQLminimalTlsSettings] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DedicatedSQLminimalTlsSettingsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedSQLminimalTlsSettingsListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -447,10 +550,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -461,8 +562,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/dedicatedSQLminimalTlsSettings"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/dedicatedSQLminimalTlsSettings"} # type: ignore 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 fb5fcfec2068..395f9d023dc6 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 @@ -6,201 +6,199 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, workspace_name: str, encryption_protector_name: Union[str, "_models.EncryptionProtectorName"], + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector/{encryptionProtectorName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector/{encryptionProtectorName}", + ) # 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'), - "encryptionProtectorName": _SERIALIZER.url("encryption_protector_name", encryption_protector_name, 'str'), + "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"), + "encryptionProtectorName": _SERIALIZER.url("encryption_protector_name", encryption_protector_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, +def build_create_or_update_request( resource_group_name: str, workspace_name: str, encryption_protector_name: Union[str, "_models.EncryptionProtectorName"], - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector/{encryptionProtectorName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector/{encryptionProtectorName}", + ) # 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'), - "encryptionProtectorName": _SERIALIZER.url("encryption_protector_name", encryption_protector_name, 'str'), + "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"), + "encryptionProtectorName": _SERIALIZER.url("encryption_protector_name", encryption_protector_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector", + ) # 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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_revalidate_request_initial( - subscription_id: str, +def build_revalidate_request( resource_group_name: str, workspace_name: str, encryption_protector_name: Union[str, "_models.EncryptionProtectorName"], + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector/{encryptionProtectorName}/revalidate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector/{encryptionProtectorName}/revalidate", + ) # 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'), - "encryptionProtectorName": _SERIALIZER.url("encryption_protector_name", encryption_protector_name, 'str'), + "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"), + "encryptionProtectorName": _SERIALIZER.url("encryption_protector_name", encryption_protector_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - **kwargs - ) - -class WorkspaceManagedSqlServerEncryptionProtectorOperations(object): - """WorkspaceManagedSqlServerEncryptionProtectorOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +class WorkspaceManagedSqlServerEncryptionProtectorOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`workspace_managed_sql_server_encryption_protector` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( @@ -209,50 +207,54 @@ def get( workspace_name: str, encryption_protector_name: Union[str, "_models.EncryptionProtectorName"], **kwargs: Any - ) -> "_models.EncryptionProtector": + ) -> _models.EncryptionProtector: """Get workspace server's encryption protector. Get workspace managed sql server's encryption protector. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param encryption_protector_name: The name of the encryption protector. + :param encryption_protector_name: The name of the encryption protector. "current" Required. :type encryption_protector_name: str or ~azure.mgmt.synapse.models.EncryptionProtectorName - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EncryptionProtector, or the result of cls(response) + :return: EncryptionProtector or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.EncryptionProtector - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionProtector"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionProtector] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -260,70 +262,165 @@ 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector/{encryptionProtectorName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector/{encryptionProtectorName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, workspace_name: str, encryption_protector_name: Union[str, "_models.EncryptionProtectorName"], - parameters: "_models.EncryptionProtector", + parameters: Union[_models.EncryptionProtector, IO], **kwargs: Any - ) -> Optional["_models.EncryptionProtector"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.EncryptionProtector"]] + ) -> Optional[_models.EncryptionProtector]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'EncryptionProtector') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.EncryptionProtector]] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "EncryptionProtector") + + request = build_create_or_update_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, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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 = self._deserialize("EncryptionProtector", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector/{encryptionProtectorName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector/{encryptionProtectorName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + encryption_protector_name: Union[str, "_models.EncryptionProtectorName"], + parameters: _models.EncryptionProtector, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.EncryptionProtector]: + """Updates workspace server's encryption protector. + + Updates workspace managed sql server's encryption protector. + + :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 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: ~azure.mgmt.synapse.models.EncryptionProtector + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + encryption_protector_name: Union[str, "_models.EncryptionProtectorName"], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.EncryptionProtector]: + """Updates workspace server's encryption protector. + Updates workspace managed sql server's encryption protector. + + :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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -331,24 +428,26 @@ def begin_create_or_update( resource_group_name: str, workspace_name: str, encryption_protector_name: Union[str, "_models.EncryptionProtectorName"], - parameters: "_models.EncryptionProtector", + parameters: Union[_models.EncryptionProtector, IO], **kwargs: Any - ) -> LROPoller["_models.EncryptionProtector"]: + ) -> LROPoller[_models.EncryptionProtector]: """Updates workspace server's encryption protector. Updates workspace managed sql server's encryption protector. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param encryption_protector_name: The name of the encryption protector. + :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. - :type parameters: ~azure.mgmt.synapse.models.EncryptionProtector - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 @@ -360,107 +459,106 @@ def begin_create_or_update( :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] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionProtector"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionProtector] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, encryption_protector_name=encryption_protector_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('EncryptionProtector', pipeline_response) + deserialized = self._deserialize("EncryptionProtector", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector/{encryptionProtectorName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector/{encryptionProtectorName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> Iterable["_models.EncryptionProtectorListResult"]: + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> Iterable["_models.EncryptionProtector"]: """Get list of encryption protectors for the server. Get list of encryption protectors for workspace managed sql server. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EncryptionProtectorListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.EncryptionProtectorListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionProtectorListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionProtectorListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -474,10 +572,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -487,11 +583,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector"} # type: ignore def _revalidate_initial( # pylint: disable=inconsistent-return-statements self, @@ -500,31 +594,37 @@ def _revalidate_initial( # pylint: disable=inconsistent-return-statements encryption_protector_name: Union[str, "_models.EncryptionProtectorName"], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_revalidate_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + 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'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -534,11 +634,10 @@ def _revalidate_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _revalidate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector/{encryptionProtectorName}/revalidate"} # type: ignore - + _revalidate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector/{encryptionProtectorName}/revalidate"} # type: ignore @distributed_trace - def begin_revalidate( # pylint: disable=inconsistent-return-statements + def begin_revalidate( self, resource_group_name: str, workspace_name: str, @@ -550,14 +649,12 @@ def begin_revalidate( # pylint: disable=inconsistent-return-statements Revalidates workspace managed sql server's existing encryption protector. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param encryption_protector_name: The name of the encryption protector. + :param encryption_protector_name: The name of the encryption protector. "current" Required. :type encryption_protector_name: str or ~azure.mgmt.synapse.models.EncryptionProtectorName - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -568,42 +665,46 @@ def begin_revalidate( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._revalidate_initial( + raw_result = self._revalidate_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, encryption_protector_name=encryption_protector_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_revalidate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector/{encryptionProtectorName}/revalidate"} # type: ignore + begin_revalidate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/encryptionProtector/{encryptionProtectorName}/revalidate"} # 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 ad10e499714e..a289934b4aa3 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 @@ -6,169 +6,167 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, workspace_name: str, blob_auditing_policy_name: Union[str, "_models.BlobAuditingPolicyName"], + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/extendedAuditingSettings/{blobAuditingPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/extendedAuditingSettings/{blobAuditingPolicyName}", + ) # 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'), - "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, 'str'), + "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"), + "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, +def build_create_or_update_request( resource_group_name: str, workspace_name: str, blob_auditing_policy_name: Union[str, "_models.BlobAuditingPolicyName"], - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/extendedAuditingSettings/{blobAuditingPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/extendedAuditingSettings/{blobAuditingPolicyName}", + ) # 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'), - "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, 'str'), + "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"), + "blobAuditingPolicyName": _SERIALIZER.url("blob_auditing_policy_name", blob_auditing_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_workspace_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/extendedAuditingSettings") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/extendedAuditingSettings", + ) # 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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class WorkspaceManagedSqlServerExtendedBlobAuditingPoliciesOperations(object): - """WorkspaceManagedSqlServerExtendedBlobAuditingPoliciesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceManagedSqlServerExtendedBlobAuditingPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`workspace_managed_sql_server_extended_blob_auditing_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( @@ -177,103 +175,120 @@ def get( workspace_name: str, blob_auditing_policy_name: Union[str, "_models.BlobAuditingPolicyName"], **kwargs: Any - ) -> "_models.ExtendedServerBlobAuditingPolicy": + ) -> _models.ExtendedServerBlobAuditingPolicy: """Get server's extended blob auditing policy. Get a workspace SQL server's extended blob auditing policy. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param blob_auditing_policy_name: The name of the blob auditing policy. + :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 api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ExtendedServerBlobAuditingPolicy, or the result of cls(response) + :return: ExtendedServerBlobAuditingPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ExtendedServerBlobAuditingPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtendedServerBlobAuditingPolicy"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ExtendedServerBlobAuditingPolicy] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/extendedAuditingSettings/{blobAuditingPolicyName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/extendedAuditingSettings/{blobAuditingPolicyName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, workspace_name: str, blob_auditing_policy_name: Union[str, "_models.BlobAuditingPolicyName"], - parameters: "_models.ExtendedServerBlobAuditingPolicy", + parameters: Union[_models.ExtendedServerBlobAuditingPolicy, IO], **kwargs: Any - ) -> Optional["_models.ExtendedServerBlobAuditingPolicy"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ExtendedServerBlobAuditingPolicy"]] + ) -> Optional[_models.ExtendedServerBlobAuditingPolicy]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ExtendedServerBlobAuditingPolicy') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ExtendedServerBlobAuditingPolicy]] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExtendedServerBlobAuditingPolicy") + + request = build_create_or_update_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, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -282,15 +297,98 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ExtendedServerBlobAuditingPolicy', pipeline_response) + deserialized = self._deserialize("ExtendedServerBlobAuditingPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/extendedAuditingSettings/{blobAuditingPolicyName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/extendedAuditingSettings/{blobAuditingPolicyName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + blob_auditing_policy_name: Union[str, "_models.BlobAuditingPolicyName"], + parameters: _models.ExtendedServerBlobAuditingPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ExtendedServerBlobAuditingPolicy]: + """Create or Update server's extended blob auditing policy. + Create or Update a workspace managed sql server's extended blob auditing policy. + + :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 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: ~azure.mgmt.synapse.models.ExtendedServerBlobAuditingPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: + ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.ExtendedServerBlobAuditingPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + blob_auditing_policy_name: Union[str, "_models.BlobAuditingPolicyName"], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ExtendedServerBlobAuditingPolicy]: + """Create or Update server's extended blob auditing policy. + + Create or Update a workspace managed sql server's extended blob auditing policy. + + :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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: + ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.ExtendedServerBlobAuditingPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -298,24 +396,26 @@ def begin_create_or_update( resource_group_name: str, workspace_name: str, blob_auditing_policy_name: Union[str, "_models.BlobAuditingPolicyName"], - parameters: "_models.ExtendedServerBlobAuditingPolicy", + parameters: Union[_models.ExtendedServerBlobAuditingPolicy, IO], **kwargs: Any - ) -> LROPoller["_models.ExtendedServerBlobAuditingPolicy"]: + ) -> LROPoller[_models.ExtendedServerBlobAuditingPolicy]: """Create or Update server's extended blob auditing policy. Create or Update a workspace managed sql server's extended blob auditing policy. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param blob_auditing_policy_name: The name of the blob auditing policy. + :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. - :type parameters: ~azure.mgmt.synapse.models.ExtendedServerBlobAuditingPolicy - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 @@ -328,108 +428,108 @@ def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.ExtendedServerBlobAuditingPolicy] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtendedServerBlobAuditingPolicy"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ExtendedServerBlobAuditingPolicy] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, blob_auditing_policy_name=blob_auditing_policy_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ExtendedServerBlobAuditingPolicy', pipeline_response) + deserialized = self._deserialize("ExtendedServerBlobAuditingPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/extendedAuditingSettings/{blobAuditingPolicyName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/extendedAuditingSettings/{blobAuditingPolicyName}"} # type: ignore @distributed_trace def list_by_workspace( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> Iterable["_models.ExtendedServerBlobAuditingPolicyListResult"]: + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> Iterable["_models.ExtendedServerBlobAuditingPolicy"]: """List server's extended blob auditing policies. List workspace managed sql server's extended blob auditing policies. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExtendedServerBlobAuditingPolicyListResult or the - result of cls(response) + :return: An iterator like instance of either ExtendedServerBlobAuditingPolicy or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.ExtendedServerBlobAuditingPolicyListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.ExtendedServerBlobAuditingPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ExtendedServerBlobAuditingPolicyListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtendedServerBlobAuditingPolicyListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore else: - - request = build_list_by_workspace_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -443,10 +543,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -456,8 +554,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_workspace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/extendedAuditingSettings"} # type: ignore + list_by_workspace.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/extendedAuditingSettings"} # type: ignore 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 9309eeb05f09..6939fc1162ef 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 @@ -8,174 +8,170 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/recoverableSqlPools") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/recoverableSqlPools", + ) # 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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, sql_pool_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/recoverableSqlPools/{sqlPoolName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/recoverableSqlPools/{sqlPoolName}", + ) # 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'), + "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 = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class WorkspaceManagedSqlServerRecoverableSqlPoolsOperations(object): - """WorkspaceManagedSqlServerRecoverableSqlPoolsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceManagedSqlServerRecoverableSqlPoolsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`workspace_managed_sql_server_recoverable_sql_pools` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> Iterable["_models.RecoverableSqlPoolListResult"]: + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> Iterable["_models.RecoverableSqlPool"]: """Get list of recoverable sql pools for the server. Get list of recoverable sql pools for workspace managed sql server. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RecoverableSqlPoolListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.RecoverableSqlPoolListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RecoverableSqlPoolListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecoverableSqlPoolListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -189,10 +185,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -202,75 +196,72 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/recoverableSqlPools"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/recoverableSqlPools"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - workspace_name: str, - sql_pool_name: str, - **kwargs: Any - ) -> "_models.RecoverableSqlPool": + self, resource_group_name: str, workspace_name: str, sql_pool_name: str, **kwargs: Any + ) -> _models.RecoverableSqlPool: """Get recoverable sql pools for the server. Get recoverable sql pools for workspace managed sql server. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param sql_pool_name: The name of the sql pool. + :param sql_pool_name: The name of the sql pool. Required. :type sql_pool_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RecoverableSqlPool, or the result of cls(response) + :return: RecoverableSqlPool or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.RecoverableSqlPool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecoverableSqlPool"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RecoverableSqlPool] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/recoverableSqlPools/{sqlPoolName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/recoverableSqlPools/{sqlPoolName}"} # 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 2537ed59bbe3..668f1f3f85b3 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 @@ -6,169 +6,167 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, workspace_name: str, security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyNameAutoGenerated"], + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/securityAlertPolicies/{securityAlertPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/securityAlertPolicies/{securityAlertPolicyName}", + ) # 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'), - "securityAlertPolicyName": _SERIALIZER.url("security_alert_policy_name", security_alert_policy_name, 'str'), + "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"), + "securityAlertPolicyName": _SERIALIZER.url("security_alert_policy_name", security_alert_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, +def build_create_or_update_request( resource_group_name: str, workspace_name: str, security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyNameAutoGenerated"], - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/securityAlertPolicies/{securityAlertPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/securityAlertPolicies/{securityAlertPolicyName}", + ) # 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'), - "securityAlertPolicyName": _SERIALIZER.url("security_alert_policy_name", security_alert_policy_name, 'str'), + "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"), + "securityAlertPolicyName": _SERIALIZER.url("security_alert_policy_name", security_alert_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/securityAlertPolicies") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/securityAlertPolicies", + ) # 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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class WorkspaceManagedSqlServerSecurityAlertPolicyOperations(object): - """WorkspaceManagedSqlServerSecurityAlertPolicyOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceManagedSqlServerSecurityAlertPolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`workspace_managed_sql_server_security_alert_policy` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( @@ -177,104 +175,121 @@ def get( workspace_name: str, security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyNameAutoGenerated"], **kwargs: Any - ) -> "_models.ServerSecurityAlertPolicy": + ) -> _models.ServerSecurityAlertPolicy: """Get server's security alert policy. Get a workspace managed sql server's security alert policy. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param security_alert_policy_name: The name of the security alert policy. + :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 api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServerSecurityAlertPolicy, or the result of cls(response) + :return: ServerSecurityAlertPolicy or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ServerSecurityAlertPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerSecurityAlertPolicy"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServerSecurityAlertPolicy] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/securityAlertPolicies/{securityAlertPolicyName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/securityAlertPolicies/{securityAlertPolicyName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, workspace_name: str, security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyNameAutoGenerated"], - parameters: "_models.ServerSecurityAlertPolicy", + parameters: Union[_models.ServerSecurityAlertPolicy, IO], **kwargs: Any - ) -> Optional["_models.ServerSecurityAlertPolicy"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ServerSecurityAlertPolicy"]] + ) -> Optional[_models.ServerSecurityAlertPolicy]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(parameters, 'ServerSecurityAlertPolicy') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ServerSecurityAlertPolicy]] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServerSecurityAlertPolicy") + + request = build_create_or_update_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, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -283,15 +298,98 @@ def _create_or_update_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ServerSecurityAlertPolicy', pipeline_response) + deserialized = self._deserialize("ServerSecurityAlertPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/securityAlertPolicies/{securityAlertPolicyName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/securityAlertPolicies/{securityAlertPolicyName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyNameAutoGenerated"], + parameters: _models.ServerSecurityAlertPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerSecurityAlertPolicy]: + """Create or Update server's threat detection policy. + Create or Update a workspace managed sql server's threat detection policy. + + :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 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. Required. + :type parameters: ~azure.mgmt.synapse.models.ServerSecurityAlertPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyNameAutoGenerated"], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ServerSecurityAlertPolicy]: + """Create or Update server's threat detection policy. + + Create or Update a workspace managed sql server's threat detection policy. + + :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 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. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServerSecurityAlertPolicy or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.ServerSecurityAlertPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -299,25 +397,27 @@ def begin_create_or_update( resource_group_name: str, workspace_name: str, security_alert_policy_name: Union[str, "_models.SecurityAlertPolicyNameAutoGenerated"], - parameters: "_models.ServerSecurityAlertPolicy", + parameters: Union[_models.ServerSecurityAlertPolicy, IO], **kwargs: Any - ) -> LROPoller["_models.ServerSecurityAlertPolicy"]: + ) -> LROPoller[_models.ServerSecurityAlertPolicy]: """Create or Update server's threat detection policy. Create or Update a workspace managed sql server's threat detection policy. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param security_alert_policy_name: The name of the security alert policy. + :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. - :type parameters: ~azure.mgmt.synapse.models.ServerSecurityAlertPolicy - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 @@ -329,108 +429,107 @@ def begin_create_or_update( :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] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerSecurityAlertPolicy"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServerSecurityAlertPolicy] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, security_alert_policy_name=security_alert_policy_name, parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ServerSecurityAlertPolicy', pipeline_response) + deserialized = self._deserialize("ServerSecurityAlertPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/securityAlertPolicies/{securityAlertPolicyName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/securityAlertPolicies/{securityAlertPolicyName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> Iterable["_models.ServerSecurityAlertPolicyListResult"]: + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> Iterable["_models.ServerSecurityAlertPolicy"]: """Get server's threat detection policies. Get workspace managed sql server's threat detection policies. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServerSecurityAlertPolicyListResult or the result - of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.ServerSecurityAlertPolicyListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ServerSecurityAlertPolicy or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.ServerSecurityAlertPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServerSecurityAlertPolicyListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerSecurityAlertPolicyListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -444,10 +543,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -457,8 +554,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/securityAlertPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/securityAlertPolicies"} # type: ignore 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 40142d5fc1a1..3195a97a46b1 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 @@ -8,136 +8,134 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlUsages") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlUsages", + ) # 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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class WorkspaceManagedSqlServerUsagesOperations(object): - """WorkspaceManagedSqlServerUsagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceManagedSqlServerUsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`workspace_managed_sql_server_usages` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> Iterable["_models.ServerUsageListResult"]: + def list(self, resource_group_name: str, workspace_name: str, **kwargs: Any) -> Iterable["_models.ServerUsage"]: """Get list of usages metric for the server. Get list of server usages metric for workspace managed sql server. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServerUsageListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.ServerUsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServerUsageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerUsageListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -151,10 +149,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -164,8 +160,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlUsages"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlUsages"} # type: ignore 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 80910fd1e3ef..3df6aee48394 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 @@ -6,199 +6,203 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, workspace_name: str, vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", + ) # 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'), - "vulnerabilityAssessmentName": _SERIALIZER.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), + "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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, resource_group_name: str, workspace_name: str, vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", + ) # 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'), - "vulnerabilityAssessmentName": _SERIALIZER.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), + "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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - subscription_id: str, resource_group_name: str, workspace_name: str, vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}", + ) # 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'), - "vulnerabilityAssessmentName": _SERIALIZER.url("vulnerability_assessment_name", vulnerability_assessment_name, 'str'), + "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"), + "vulnerabilityAssessmentName": _SERIALIZER.url( + "vulnerability_assessment_name", vulnerability_assessment_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_list_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/vulnerabilityAssessments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/vulnerabilityAssessments", + ) # 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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class WorkspaceManagedSqlServerVulnerabilityAssessmentsOperations(object): - """WorkspaceManagedSqlServerVulnerabilityAssessmentsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceManagedSqlServerVulnerabilityAssessmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`workspace_managed_sql_server_vulnerability_assessments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( @@ -207,66 +211,140 @@ def get( workspace_name: str, vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], **kwargs: Any - ) -> "_models.ServerVulnerabilityAssessment": + ) -> _models.ServerVulnerabilityAssessment: """Get server's vulnerability assessment. Get workspace managed sql server's vulnerability assessment. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param vulnerability_assessment_name: The name of the vulnerability assessment. + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServerVulnerabilityAssessment, or the result of cls(response) + :return: ServerVulnerabilityAssessment or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ServerVulnerabilityAssessment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerVulnerabilityAssessment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServerVulnerabilityAssessment] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}"} # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + parameters: _models.ServerVulnerabilityAssessment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ServerVulnerabilityAssessment: + """Create or Update server's vulnerability assessment. + Create or Update workspace managed sql server's vulnerability assessment. + + :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 vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. + :type vulnerability_assessment_name: str or + ~azure.mgmt.synapse.models.VulnerabilityAssessmentName + :param parameters: Properties for vulnerability assessment. Required. + :type parameters: ~azure.mgmt.synapse.models.ServerVulnerabilityAssessment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + workspace_name: str, + vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ServerVulnerabilityAssessment: + """Create or Update server's vulnerability assessment. + + Create or Update workspace managed sql server's vulnerability assessment. + + :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 vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. + :type vulnerability_assessment_name: str or + ~azure.mgmt.synapse.models.VulnerabilityAssessmentName + :param parameters: Properties for vulnerability assessment. 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: ServerVulnerabilityAssessment or the result of cls(response) + :rtype: ~azure.mgmt.synapse.models.ServerVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update( @@ -274,59 +352,76 @@ def create_or_update( resource_group_name: str, workspace_name: str, vulnerability_assessment_name: Union[str, "_models.VulnerabilityAssessmentName"], - parameters: "_models.ServerVulnerabilityAssessment", + parameters: Union[_models.ServerVulnerabilityAssessment, IO], **kwargs: Any - ) -> "_models.ServerVulnerabilityAssessment": + ) -> _models.ServerVulnerabilityAssessment: """Create or Update server's vulnerability assessment. Create or Update workspace managed sql server's vulnerability assessment. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param vulnerability_assessment_name: The name of the vulnerability assessment. + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :param parameters: Properties for vulnerability assessment. - :type parameters: ~azure.mgmt.synapse.models.ServerVulnerabilityAssessment - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 - :return: ServerVulnerabilityAssessment, or the result of cls(response) + :return: ServerVulnerabilityAssessment or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.ServerVulnerabilityAssessment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerVulnerabilityAssessment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServerVulnerabilityAssessment] - _json = self._serialize.body(parameters, 'ServerVulnerabilityAssessment') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServerVulnerabilityAssessment") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, 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, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -334,18 +429,17 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ServerVulnerabilityAssessment', pipeline_response) + deserialized = self._deserialize("ServerVulnerabilityAssessment", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ServerVulnerabilityAssessment', pipeline_response) + deserialized = self._deserialize("ServerVulnerabilityAssessment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -360,45 +454,50 @@ def delete( # pylint: disable=inconsistent-return-statements Remove workspace managed sql server's vulnerability assessment. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param vulnerability_assessment_name: The name of the vulnerability assessment. + :param vulnerability_assessment_name: The name of the vulnerability assessment. "default" + Required. :type vulnerability_assessment_name: str or ~azure.mgmt.synapse.models.VulnerabilityAssessmentName - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, 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'], + 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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -408,65 +507,60 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/vulnerabilityAssessments/{vulnerabilityAssessmentName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> Iterable["_models.ServerVulnerabilityAssessmentListResult"]: + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> Iterable["_models.ServerVulnerabilityAssessment"]: """Lists the vulnerability assessment policies associated with a server. Lists the vulnerability assessment policies associated with a workspace managed sql server. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ServerVulnerabilityAssessmentListResult or the - result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.ServerVulnerabilityAssessmentListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ServerVulnerabilityAssessment or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.ServerVulnerabilityAssessment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServerVulnerabilityAssessmentListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerVulnerabilityAssessmentListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - workspace_name=workspace_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -480,10 +574,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -493,8 +585,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/vulnerabilityAssessments"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/vulnerabilityAssessments"} # type: ignore 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 9b6c38f4832d..20c941e32189 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 @@ -6,210 +6,201 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlAdministrators/activeDirectory") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlAdministrators/activeDirectory", + ) # 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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, workspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlAdministrators/activeDirectory") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlAdministrators/activeDirectory", + ) # 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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - **kwargs: Any + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, workspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlAdministrators/activeDirectory") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlAdministrators/activeDirectory", + ) # 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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class WorkspaceSqlAadAdminsOperations(object): - """WorkspaceSqlAadAdminsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspaceSqlAadAdminsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`workspace_sql_aad_admins` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> "_models.WorkspaceAadAdminInfo": + def get(self, resource_group_name: str, workspace_name: str, **kwargs: Any) -> _models.WorkspaceAadAdminInfo: """Gets a workspace SQL active directory admin. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: WorkspaceAadAdminInfo, or the result of cls(response) + :return: WorkspaceAadAdminInfo or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.WorkspaceAadAdminInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceAadAdminInfo"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkspaceAadAdminInfo] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -217,90 +208,177 @@ def get( 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlAdministrators/activeDirectory"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlAdministrators/activeDirectory"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, workspace_name: str, - aad_admin_info: "_models.WorkspaceAadAdminInfo", + aad_admin_info: Union[_models.WorkspaceAadAdminInfo, IO], **kwargs: Any - ) -> "_models.WorkspaceAadAdminInfo": - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceAadAdminInfo"] + ) -> _models.WorkspaceAadAdminInfo: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(aad_admin_info, 'WorkspaceAadAdminInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkspaceAadAdminInfo] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(aad_admin_info, (IO, bytes)): + _content = aad_admin_info + else: + _json = self._serialize.body(aad_admin_info, "WorkspaceAadAdminInfo") + + request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("WorkspaceAadAdminInfo", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('WorkspaceAadAdminInfo', pipeline_response) + deserialized = self._deserialize("WorkspaceAadAdminInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlAdministrators/activeDirectory"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlAdministrators/activeDirectory"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + aad_admin_info: _models.WorkspaceAadAdminInfo, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkspaceAadAdminInfo]: + """Creates or updates a workspace SQL active directory admin. + + :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 aad_admin_info: Workspace active directory administrator properties. Required. + :type aad_admin_info: ~azure.mgmt.synapse.models.WorkspaceAadAdminInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + aad_admin_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkspaceAadAdminInfo]: + """Creates or updates a workspace SQL active directory admin. + :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 aad_admin_info: Workspace active directory administrator properties. Required. + :type aad_admin_info: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either WorkspaceAadAdminInfo or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.WorkspaceAadAdminInfo] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( self, resource_group_name: str, workspace_name: str, - aad_admin_info: "_models.WorkspaceAadAdminInfo", + aad_admin_info: Union[_models.WorkspaceAadAdminInfo, IO], **kwargs: Any - ) -> LROPoller["_models.WorkspaceAadAdminInfo"]: + ) -> LROPoller[_models.WorkspaceAadAdminInfo]: """Creates or updates a workspace SQL active directory admin. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param aad_admin_info: Workspace active directory administrator properties. - :type aad_admin_info: ~azure.mgmt.synapse.models.WorkspaceAadAdminInfo - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 @@ -312,109 +390,110 @@ def begin_create_or_update( :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] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceAadAdminInfo"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkspaceAadAdminInfo] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, aad_admin_info=aad_admin_info, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('WorkspaceAadAdminInfo', pipeline_response) + deserialized = self._deserialize("WorkspaceAadAdminInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlAdministrators/activeDirectory"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlAdministrators/activeDirectory"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any + self, resource_group_name: str, workspace_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + 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'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlAdministrators/activeDirectory"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlAdministrators/activeDirectory"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, workspace_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes a workspace SQL active directory admin. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -425,41 +504,47 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlAdministrators/activeDirectory"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}/sqlAdministrators/activeDirectory"} # 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 c7f2c8f48ce4..4527950b9bcd 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 @@ -6,324 +6,292 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - accept = "application/json" +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces", + ) # 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), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - **kwargs: Any + resource_group_name: str, workspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}", + ) # 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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, workspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}", + ) # 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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, workspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}", + ) # 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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - workspace_name: str, - **kwargs: Any + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, workspace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}", + ) # 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'), + "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"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-06-01") # type: str +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Synapse/workspaces") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class WorkspacesOperations(object): - """WorkspacesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.synapse.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkspacesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.synapse.SynapseManagementClient`'s + :attr:`workspaces` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.WorkspaceInfoListResult"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Workspace"]: """Returns a list of workspaces in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkspaceInfoListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.WorkspaceInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkspaceInfoListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceInfoListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -337,10 +305,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -351,57 +317,54 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> "_models.Workspace": + def get(self, resource_group_name: str, workspace_name: str, **kwargs: Any) -> _models.Workspace: """Gets a workspace. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Workspace, or the result of cls(response) + :return: Workspace or the result of cls(response) :rtype: ~azure.mgmt.synapse.models.Workspace - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Workspace"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Workspace] - request = build_get_request( - subscription_id=self._config.subscription_id, 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'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -409,90 +372,175 @@ def get( 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) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}"} # type: ignore def _update_initial( self, resource_group_name: str, workspace_name: str, - workspace_patch_info: "_models.WorkspacePatchInfo", + workspace_patch_info: Union[_models.WorkspacePatchInfo, IO], **kwargs: Any - ) -> "_models.Workspace": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Workspace"] + ) -> _models.Workspace: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(workspace_patch_info, 'WorkspacePatchInfo') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Workspace] - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workspace_patch_info, (IO, bytes)): + _content = workspace_patch_info + else: + _json = self._serialize.body(workspace_patch_info, "WorkspacePatchInfo") + + request = build_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("Workspace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Workspace', pipeline_response) + deserialized = self._deserialize("Workspace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + workspace_name: str, + workspace_patch_info: _models.WorkspacePatchInfo, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Workspace]: + """Updates a workspace. + + :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 workspace_patch_info: Workspace patch request properties. Required. + :type workspace_patch_info: ~azure.mgmt.synapse.models.WorkspacePatchInfo + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: 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: + """ + @overload + def begin_update( + self, + resource_group_name: str, + workspace_name: str, + workspace_patch_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Workspace]: + """Updates a workspace. + + :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 workspace_patch_info: Workspace patch request properties. Required. + :type workspace_patch_info: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Workspace or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.Workspace] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( self, resource_group_name: str, workspace_name: str, - workspace_patch_info: "_models.WorkspacePatchInfo", + workspace_patch_info: Union[_models.WorkspacePatchInfo, IO], **kwargs: Any - ) -> LROPoller["_models.Workspace"]: + ) -> LROPoller[_models.Workspace]: """Updates a workspace. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param workspace_patch_info: Workspace patch request properties. - :type workspace_patch_info: ~azure.mgmt.synapse.models.WorkspacePatchInfo - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 @@ -503,125 +551,143 @@ def begin_update( 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Workspace"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Workspace] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, workspace_patch_info=workspace_patch_info, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('Workspace', pipeline_response) + deserialized = self._deserialize("Workspace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}"} # type: ignore def _create_or_update_initial( - self, - resource_group_name: str, - workspace_name: str, - workspace_info: "_models.Workspace", - **kwargs: Any - ) -> "_models.Workspace": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Workspace"] + self, resource_group_name: str, workspace_name: str, workspace_info: Union[_models.Workspace, IO], **kwargs: Any + ) -> _models.Workspace: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(workspace_info, 'Workspace') + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Workspace] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workspace_info, (IO, bytes)): + _content = workspace_info + else: + _json = self._serialize.body(workspace_info, "Workspace") + + request = build_create_or_update_request( resource_group_name=resource_group_name, workspace_name=workspace_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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) + deserialized = self._deserialize("Workspace", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Workspace', pipeline_response) + deserialized = self._deserialize("Workspace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, workspace_name: str, - workspace_info: "_models.Workspace", + workspace_info: _models.Workspace, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.Workspace"]: + ) -> LROPoller[_models.Workspace]: """Creates or updates a workspace. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :param workspace_info: Workspace create or update request properties. + :param workspace_info: Workspace create or update request properties. Required. :type workspace_info: ~azure.mgmt.synapse.models.Workspace - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -632,118 +698,186 @@ def begin_create_or_update( 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Workspace"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + workspace_name: str, + workspace_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Workspace]: + """Creates or updates a workspace. + + :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 workspace_info: Workspace create or update request properties. Required. + :type workspace_info: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Workspace or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.synapse.models.Workspace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, workspace_name: str, workspace_info: Union[_models.Workspace, IO], **kwargs: Any + ) -> LROPoller[_models.Workspace]: + """Creates or updates a workspace. + + :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 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. + :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: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Workspace] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, workspace_info=workspace_info, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('Workspace', pipeline_response) + deserialized = self._deserialize("Workspace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}"} # type: ignore def _delete_initial( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> Optional[Any]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[Any]] + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> Optional[_models.Workspace]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.Workspace]] + + 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'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + 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('object', pipeline_response) + deserialized = self._deserialize("Workspace", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('object', pipeline_response) + deserialized = self._deserialize("Workspace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}"} # type: ignore @distributed_trace def begin_delete( - self, - resource_group_name: str, - workspace_name: str, - **kwargs: Any - ) -> LROPoller[Any]: + self, resource_group_name: str, workspace_name: str, **kwargs: Any + ) -> LROPoller[_models.Workspace]: """Deletes a workspace. :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. + :param workspace_name: The name of the workspace. Required. :type workspace_name: str - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -752,93 +886,95 @@ def begin_delete( :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either any or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[any] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Any] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Workspace] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, workspace_name=workspace_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('object', pipeline_response) + deserialized = self._deserialize("Workspace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Synapse/workspaces/{workspaceName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.WorkspaceInfoListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Workspace"]: """Returns a list of workspaces in a subscription. - :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkspaceInfoListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.synapse.models.WorkspaceInfoListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :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: """ - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkspaceInfoListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceInfoListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -852,10 +988,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -866,8 +1000,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Synapse/workspaces"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Synapse/workspaces"} # type: ignore